Skip to content

Commit 2efac0d

Browse files
committed
Fix PEP 561 - editable install - test case
1 parent efe3272 commit 2efac0d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

mypy/test/testpep561.py

+15
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ def virtualenv(python_executable: str = sys.executable) -> Iterator[tuple[str, s
4646
yield venv_dir, os.path.abspath(os.path.join(venv_dir, "bin", "python"))
4747

4848

49+
def upgrade_pip(python_executable: str, version_str: str) -> None:
50+
"""Install a newer pip version."""
51+
install_cmd = [python_executable, "-m", "pip", "install", f"pip{version_str}"]
52+
try:
53+
with filelock.FileLock(pip_lock, timeout=pip_timeout):
54+
proc = subprocess.run(install_cmd, capture_output=True, env=os.environ)
55+
except filelock.Timeout as err:
56+
raise Exception(f"Failed to acquire {pip_lock}") from err
57+
if proc.returncode != 0:
58+
raise Exception(proc.stdout.decode("utf-8") + proc.stderr.decode("utf-8"))
59+
60+
4961
def install_package(
5062
pkg: str, python_executable: str = sys.executable, editable: bool = False
5163
) -> None:
@@ -93,6 +105,9 @@ def test_pep561(testcase: DataDrivenTestCase) -> None:
93105
assert pkgs, "No packages to install for PEP 561 test?"
94106
with virtualenv(python) as venv:
95107
venv_dir, python_executable = venv
108+
if editable:
109+
# Editable installs with PEP 660 require pip>=21.3
110+
upgrade_pip(python_executable, ">=21.3.1")
96111
for pkg in pkgs:
97112
install_package(pkg, python_executable, editable)
98113

0 commit comments

Comments
 (0)