Skip to content

Commit 17755cc

Browse files
emmatypingIvan Levkivskyi
authored and
Ivan Levkivskyi
committed
Fix PEP 561 tests for latest pip (#11356)
In pip 21.3 the build argument is removed, so this uses an environment variable to still work on older versions.
1 parent febec71 commit 17755cc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

mypy/test/testpep561.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def install_package(pkg: str,
6262
working_dir = os.path.join(package_path, pkg)
6363
with tempfile.TemporaryDirectory() as dir:
6464
if use_pip:
65-
install_cmd = [python_executable, '-m', 'pip', 'install', '-b', '{}'.format(dir)]
65+
install_cmd = [python_executable, '-m', 'pip', 'install']
6666
if editable:
6767
install_cmd.append('-e')
6868
install_cmd.append('.')
@@ -72,7 +72,16 @@ def install_package(pkg: str,
7272
install_cmd.append('develop')
7373
else:
7474
install_cmd.append('install')
75-
proc = subprocess.run(install_cmd, cwd=working_dir, stdout=PIPE, stderr=PIPE)
75+
# Note that newer versions of pip (21.3+) don't
76+
# follow this env variable, but this is for compatibility
77+
env = {'PIP_BUILD': dir}
78+
# Inherit environment for Windows
79+
env.update(os.environ)
80+
proc = subprocess.run(install_cmd,
81+
cwd=working_dir,
82+
stdout=PIPE,
83+
stderr=PIPE,
84+
env=env)
7685
if proc.returncode != 0:
7786
raise Exception(proc.stdout.decode('utf-8') + proc.stderr.decode('utf-8'))
7887

0 commit comments

Comments
 (0)