63
63
},
64
64
}
65
65
66
+ # This is the oldest version of pip we will distribute as a zipapp.
67
+ # Pip 22.3 was the first pip to support being shipped as a zipapp,
68
+ # but we may in future choose to increase this value to stop shipping
69
+ # very old pip versions (if we find the overhead of shipping every
70
+ # version is too high).
71
+ OLDEST_ZIPAPP = Version ("22.3" )
72
+
66
73
# Scripts here use the "moved" template, with the key being the file path and
67
74
# value being the path on bootstrap.pypa.io that the user should use instead.
68
75
#
@@ -278,12 +285,18 @@ def generate_moved(destination: str, *, location: str, console: Console):
278
285
f .write (rendered_template )
279
286
280
287
288
+ def zipapp_location (pip_version : Version ) -> Path :
289
+ zipapp_dir = Path ("public/zipapp" )
290
+ # Ensure that the zipapp directory is present
291
+ zipapp_dir .mkdir (exist_ok = True )
292
+ return zipapp_dir / f"pip-{ pip_version } .pyz"
293
+
294
+
281
295
def generate_zipapp (pip_version : Version , * , console : Console , pip_versions : Dict [Version , Tuple [str , str ]]) -> None :
282
296
wheel_url , wheel_hash = pip_versions [pip_version ]
283
297
console .log (f" Downloading [green]{ Path (wheel_url ).name } " )
284
298
original_wheel = download_wheel (wheel_url , wheel_hash )
285
-
286
- zipapp_name = "public/pip.pyz"
299
+ zipapp_name = zipapp_location (pip_version )
287
300
288
301
console .log (f" Creating [green]{ zipapp_name } " )
289
302
with open (zipapp_name , "wb" ) as f :
@@ -332,6 +345,12 @@ def generate_zipapp(pip_version: Version, *, console: Console, pip_versions: Dic
332
345
dest .writestr (main_info , zipapp_main )
333
346
334
347
348
+ def generate_zipapp_for_current (pip_version : Version ) -> None :
349
+ zipapp_name = zipapp_location (pip_version )
350
+ unversioned_name = "public/pip.pyz"
351
+ shutil .copy (zipapp_name , unversioned_name )
352
+
353
+
335
354
def main () -> None :
336
355
console = Console ()
337
356
with console .status ("Fetching pip versions..." ):
@@ -353,8 +372,12 @@ def main() -> None:
353
372
status .update (f"Working on [magenta]{ legacy } " )
354
373
generate_moved (legacy , console = console , location = current )
355
374
356
- with console .status ("Generating zipapp..." ) as status :
357
- generate_zipapp (max (pip_versions ), console = console , pip_versions = pip_versions )
375
+ with console .status ("Generating zipapps..." ) as status :
376
+ for version in pip_versions :
377
+ if version < OLDEST_ZIPAPP :
378
+ continue
379
+ generate_zipapp (version , console = console , pip_versions = pip_versions )
380
+ generate_zipapp_for_current (max (pip_versions ))
358
381
359
382
360
383
if __name__ == "__main__" :
0 commit comments