@@ -46,6 +46,28 @@ 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 ) -> None :
50
+ """Install pip>=21.3.1. Required for editable installs with PEP 660."""
51
+ if (
52
+ sys .version_info >= (3 , 11 )
53
+ or (3 , 10 , 3 ) <= sys .version_info < (3 , 11 )
54
+ or (3 , 9 , 11 ) <= sys .version_info < (3 , 10 )
55
+ or (3 , 8 , 13 ) <= sys .version_info < (3 , 9 )
56
+ ):
57
+ # Skip for more recent Python releases which come with pip>=21.3.1
58
+ # out of the box - for performance reasons.
59
+ return
60
+
61
+ install_cmd = [python_executable , "-m" , "pip" , "install" , "pip>=21.3.1" ]
62
+ try :
63
+ with filelock .FileLock (pip_lock , timeout = pip_timeout ):
64
+ proc = subprocess .run (install_cmd , capture_output = True , env = os .environ )
65
+ except filelock .Timeout as err :
66
+ raise Exception (f"Failed to acquire { pip_lock } " ) from err
67
+ if proc .returncode != 0 :
68
+ raise Exception (proc .stdout .decode ("utf-8" ) + proc .stderr .decode ("utf-8" ))
69
+
70
+
49
71
def install_package (
50
72
pkg : str , python_executable : str = sys .executable , editable : bool = False
51
73
) -> None :
@@ -93,6 +115,9 @@ def test_pep561(testcase: DataDrivenTestCase) -> None:
93
115
assert pkgs , "No packages to install for PEP 561 test?"
94
116
with virtualenv (python ) as venv :
95
117
venv_dir , python_executable = venv
118
+ if editable :
119
+ # Editable installs with PEP 660 require pip>=21.3
120
+ upgrade_pip (python_executable )
96
121
for pkg in pkgs :
97
122
install_package (pkg , python_executable , editable )
98
123
0 commit comments