From 36e10647c7b435d722fbf5ce43048669190c89e4 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 19 Oct 2021 06:46:15 -0700 Subject: [PATCH 1/2] Fix PEP 561 tests for latest pip In pip 21.3 the build argument is removed, so this uses an environment variable to still work on older versions. --- mypy/test/testpep561.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mypy/test/testpep561.py b/mypy/test/testpep561.py index adbbaefb8de4d..bc61f1ae87473 100644 --- a/mypy/test/testpep561.py +++ b/mypy/test/testpep561.py @@ -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('.') @@ -72,7 +72,13 @@ 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) + 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}) if proc.returncode != 0: raise Exception(proc.stdout.decode('utf-8') + proc.stderr.decode('utf-8')) From 404e9147a769296ae12c0d384e7f017401a19b5c Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 19 Oct 2021 21:13:24 -0700 Subject: [PATCH 2/2] Inherit environment for PEP 561 tests --- mypy/test/testpep561.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mypy/test/testpep561.py b/mypy/test/testpep561.py index bc61f1ae87473..d30d94c49beec 100644 --- a/mypy/test/testpep561.py +++ b/mypy/test/testpep561.py @@ -72,13 +72,16 @@ def install_package(pkg: str, install_cmd.append('develop') else: install_cmd.append('install') + # 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, - # Note that newer versions of pip (21.3+) don't - # follow this env variable, but this is for compatibility - env={'PIP_BUILD': dir}) + env=env) if proc.returncode != 0: raise Exception(proc.stdout.decode('utf-8') + proc.stderr.decode('utf-8'))