Skip to content

Commit

Permalink
Ensure zipapp generation is reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmoore committed Sep 4, 2022
1 parent ee477d8 commit ee8a69d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file modified public/pip-22.2.2.pyz
Binary file not shown.
Binary file modified public/pip.pyz
Binary file not shown.
8 changes: 6 additions & 2 deletions scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from io import BytesIO
from pathlib import Path
from typing import Dict, Iterable, List, TextIO, Tuple
from zipfile import ZipFile
from zipfile import ZipFile, ZipInfo

import requests
from cachecontrol import CacheControl
Expand Down Expand Up @@ -341,7 +341,11 @@ def generate_zipapp(pip_version: Version, *, console: Console, pip_versions: Dic
console.log(f" Python requirement {py_req} too complex - check skipped")

# Write the main script
dest.writestr("__main__.py", ZIPAPP_MAIN.format(version_check=version_check))
# Use a ZipInfo object to ensure reproducibility - otherwise the current time
# is embedded in the file.
main_info = ZipInfo()
main_info.filename = "__main__.py"
dest.writestr(main_info, ZIPAPP_MAIN.format(version_check=version_check))

# Make the unversioned pip.pyz
shutil.copyfile(zipapp_name, "public/pip.pyz")
Expand Down

0 comments on commit ee8a69d

Please sign in to comment.