Merge pull request #9920 from zip-ignore-timestamp

Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
This commit is contained in:
Tzu-ping Chung 2021-05-22 05:10:28 +08:00 committed by GitHub
commit 9b3bbee2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

1
news/9910.bugfix.rst Normal file
View File

@ -0,0 +1 @@
Allow ZIP to archive files with timestamps earlier than 1980.

View File

@ -58,7 +58,10 @@ def _create_standalone_pip() -> Iterator[str]:
with TempDirectory(kind="standalone-pip") as tmp_dir:
pip_zip = os.path.join(tmp_dir.path, "__env_pip__.zip")
with zipfile.ZipFile(pip_zip, "w") as zf:
kwargs = {}
if sys.version_info >= (3, 8):
kwargs["strict_timestamps"] = False
with zipfile.ZipFile(pip_zip, "w", **kwargs) as zf:
for child in source.rglob("*"):
zf.write(child, child.relative_to(source.parent).as_posix())
yield os.path.join(pip_zip, "pip")