Skip to content

Commit 00765de

Browse files
committed
feat: Add force_zip64 option
1 parent 06f6f31 commit 00765de

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Unreleased changes template.
7474
### Added
7575
* Add support for riscv64 linux platform.
7676
* (toolchains) Add python 3.13.2 and 3.12.9 toolchains
77+
* Add force_zip64 option for python wheel creation
7778

7879
{#v0-0-0-removed}
7980
### Removed

Diff for: python/private/py_wheel.bzl

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ Workspace status keys are expanded using `{NAME}` format, for example:
5454
For the available keys, see https://bazel.build/docs/user-manual#workspace-status
5555
""",
5656
),
57+
"force_zip64": attr.bool(
58+
default = False,
59+
doc = "Force zip64.",
60+
),
5761
"platform": attr.string(
5862
default = "any",
5963
doc = """\
@@ -513,6 +517,8 @@ def _py_wheel_impl(ctx):
513517
"--data_files",
514518
filename + ";" + target_files[0].path,
515519
)
520+
if ctx.attr.force_zip64:
521+
args.add("--force_zip64")
516522

517523
ctx.actions.run(
518524
mnemonic = "PyWheel",

Diff for: tools/wheelmaker.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ def __init__(
107107
distribution_prefix: str,
108108
strip_path_prefixes=None,
109109
compression=zipfile.ZIP_DEFLATED,
110+
force_zip64=False,
110111
**kwargs,
111112
):
112113
self._distribution_prefix = distribution_prefix
114+
self._force_zip64 = force_zip64
113115

114116
self._strip_path_prefixes = strip_path_prefixes or []
115117
# Entries for the RECORD file as (filename, hash, size) tuples.
@@ -154,7 +156,7 @@ def arcname_from(name):
154156
hash = hashlib.sha256()
155157
size = 0
156158
with open(real_filename, "rb") as fsrc:
157-
with self.open(zinfo, "w") as fdst:
159+
with self.open(zinfo, "w", force_zip64=self._force_zip64) as fdst:
158160
while True:
159161
block = fsrc.read(2**20)
160162
if not block:
@@ -241,6 +243,7 @@ def __init__(
241243
compress,
242244
outfile=None,
243245
strip_path_prefixes=None,
246+
force_zip64=False,
244247
):
245248
self._name = name
246249
self._version = normalize_pep440(version)
@@ -250,6 +253,7 @@ def __init__(
250253
self._platform = platform
251254
self._outfile = outfile
252255
self._strip_path_prefixes = strip_path_prefixes
256+
self._force_zip64 = force_zip64
253257
self._compress = compress
254258
self._wheelname_fragment_distribution_name = escape_filename_distribution_name(
255259
self._name
@@ -268,6 +272,7 @@ def __enter__(self):
268272
distribution_prefix=self._distribution_prefix,
269273
strip_path_prefixes=self._strip_path_prefixes,
270274
compression=zipfile.ZIP_DEFLATED if self._compress else zipfile.ZIP_STORED,
275+
force_zip64=self._force_zip64,
271276
)
272277
return self
273278

@@ -478,6 +483,11 @@ def parse_args() -> argparse.Namespace:
478483
type=Path,
479484
help="Pass in the stamp info file for stamping",
480485
)
486+
output_group.add_argument(
487+
"--force_zip64",
488+
action="store_true",
489+
help="Forces usage of zip64",
490+
)
481491

482492
return parser.parse_args(sys.argv[1:])
483493

@@ -536,6 +546,7 @@ def main() -> None:
536546
outfile=arguments.out,
537547
strip_path_prefixes=strip_prefixes,
538548
compress=not arguments.no_compress,
549+
force_zip64=arguments.force_zip64,
539550
) as maker:
540551
for package_filename, real_filename in all_files:
541552
maker.add_file(package_filename, real_filename)

0 commit comments

Comments
 (0)