Skip to content

Commit

Permalink
Fix PEP 561 tests for latest pip (#11356)
Browse files Browse the repository at this point in the history
In pip 21.3 the build argument is removed, so this uses an environment
variable to still work on older versions.
  • Loading branch information
emmatyping authored Oct 21, 2021
1 parent e942bc8 commit 9a2838d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mypy/test/testpep561.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def install_package(pkg: str,
working_dir = os.path.join(package_path, pkg)
with tempfile.TemporaryDirectory() as dir:
if use_pip:
install_cmd = [python_executable, '-m', 'pip', 'install', '-b', '{}'.format(dir)]
install_cmd = [python_executable, '-m', 'pip', 'install']
if editable:
install_cmd.append('-e')
install_cmd.append('.')
Expand All @@ -72,7 +72,16 @@ def install_package(pkg: str,
install_cmd.append('develop')
else:
install_cmd.append('install')
proc = subprocess.run(install_cmd, cwd=working_dir, stdout=PIPE, stderr=PIPE)
# Note that newer versions of pip (21.3+) don't
# follow this env variable, but this is for compatibility
env = {'PIP_BUILD': dir}
# Inherit environment for Windows
env.update(os.environ)
proc = subprocess.run(install_cmd,
cwd=working_dir,
stdout=PIPE,
stderr=PIPE,
env=env)
if proc.returncode != 0:
raise Exception(proc.stdout.decode('utf-8') + proc.stderr.decode('utf-8'))

Expand Down

0 comments on commit 9a2838d

Please sign in to comment.