From 20c98d06602a98d7bd1e56b853ddf08674b6946a Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 9 Mar 2025 21:42:19 -0700 Subject: [PATCH] Enable true Zip64 support. Allow the full range of PEXes under the Zip64 limit even on old Pythons. --- pex/common.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pex/common.py b/pex/common.py index 49f42e22d..b45d1cad8 100644 --- a/pex/common.py +++ b/pex/common.py @@ -183,6 +183,16 @@ def teardown(self): _MKDTEMP_SINGLETON = MktempTeardownRegistry() +# When Zip64 support was added to Python long ago, the limit was set to +# half of what it should be. Pex is always dealing with zips it creates +# via Python and so it does not need to worry about zip implemntations +# that don't support 4GB; so we monkeypatch our way out of this +# historical baggage to get working <= 4GB PEXes even on Python 2.7. +# +# See: https://github.com/python/cpython/issues/43003 +setattr(zipfile, "ZIP64_LIMIT", (1 << 32) - 1) + + class ZipFileEx(ZipFile): """A ZipFile that works around several issues in the stdlib.