@@ -46,6 +46,18 @@ def virtualenv(python_executable: str = sys.executable) -> Iterator[tuple[str, s
46
46
yield venv_dir , os .path .abspath (os .path .join (venv_dir , "bin" , "python" ))
47
47
48
48
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
+
49
61
def install_package (
50
62
pkg : str , python_executable : str = sys .executable , editable : bool = False
51
63
) -> None :
@@ -93,6 +105,9 @@ def test_pep561(testcase: DataDrivenTestCase) -> None:
93
105
assert pkgs , "No packages to install for PEP 561 test?"
94
106
with virtualenv (python ) as venv :
95
107
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" )
96
111
for pkg in pkgs :
97
112
install_package (pkg , python_executable , editable )
98
113
0 commit comments