2121The script is executed within Docker after the image pip has been upgraded.
2222upgrade_ensurepip expects setuptools to be bundled as well, but Python 3.12+
2323only ships pip in ensurepip/_bundled.
24+
25+ After downloading, removes other pip-* files from _bundled so only the wheel
26+ matching the installed pip version remains. Worker harness startup (boot.go)
27+ creates a venv via ensurepip, so that wheel must be present.
2428"""
2529
2630import subprocess
@@ -34,8 +38,8 @@ def main():
3438 ep_path = Path (ensurepip .__file__ )
3539 wheel_dir = ep_path .parent / '_bundled'
3640 pip_version = subprocess .check_output (
37- [sys .executable , '-m' , 'pip' , '--version' ],
38- text = True ). split ()[ 1 ]
41+ [sys .executable , '-m' , 'pip' , '--version' ], text = True ). split ()[ 1 ]
42+ expected_wheel_name = 'pip-{}-py3-none-any.whl' . format ( pip_version )
3943 subprocess .check_call ([
4044 sys .executable ,
4145 '-m' ,
@@ -46,6 +50,13 @@ def main():
4650 str (wheel_dir ),
4751 '--no-deps' ,
4852 ])
53+ for path in wheel_dir .glob ('pip-*' ):
54+ if path .name != expected_wheel_name :
55+ path .unlink ()
56+ if not (wheel_dir / expected_wheel_name ).is_file ():
57+ sys .exit (
58+ 'ensurepip bundled pip wheel missing after install: {}' .format (
59+ wheel_dir / expected_wheel_name ))
4960 lines = ep_path .read_text ().splitlines ()
5061 pip_line = None
5162 for idx , line in enumerate (lines ):
0 commit comments