Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ END_UNRELEASED_TEMPLATE

{#v0-0-0-fixed}
### Fixed
* Nothing fixed.
* (zipapp) Resolve issue passing through compression settings in
`py_zippapp_binary` targets. ([#3646](https://github.com/bazel-contrib/rules_python/issues/3646))

{#v0-0-0-added}
### Added
Expand Down
2 changes: 1 addition & 1 deletion python/private/zipapp/py_zipapp_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _create_zip(ctx, py_runtime, py_executable, stage2_bootstrap):
format = "--legacy-external-runfiles=%s",
)
if ctx.attr.compression:
zipper_args.add(ctx.attr.compression, "--compression=%s")
zipper_args.add(ctx.attr.compression, format = "--compression=%s")
zipper_args.add("--runfiles-dir=runfiles")

actions_run(
Expand Down
21 changes: 21 additions & 0 deletions tests/py_zipapp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ py_test(
target_compatible_with = NOT_WINDOWS,
)

# Create the app with a supported level of compression
py_zipapp_binary(
name = "venv_zipapp_compressed",
binary = ":venv_bin",
compression = "4",
target_compatible_with = NOT_WINDOWS,
)

py_test(
name = "venv_zipapp_compressed_test",
srcs = ["venv_zipapp_test.py"],
data = [":venv_zipapp_compressed"],
env = {
"BZLMOD_ENABLED": str(int(BZLMOD_ENABLED)),
"COMPRESSED": "1",
"TEST_ZIPAPP": "$(location :venv_zipapp_compressed)",
},
main = "venv_zipapp_test.py",
target_compatible_with = NOT_WINDOWS,
)

py_binary(
name = "system_python_bin",
srcs = ["main.py"],
Expand Down
6 changes: 6 additions & 0 deletions tests/py_zipapp/venv_zipapp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def test_zipapp_structure(self):
zipapp_path = os.environ["TEST_ZIPAPP"]

with self._open_zipapp(zipapp_path) as zf:
info = zf.infolist()[0]
if os.getenv("COMPRESSED", "0") == "1":
self.assertEqual(info.compress_type, zipfile.ZIP_DEFLATED)
else:
self.assertEqual(info.compress_type, zipfile.ZIP_STORED)

namelist = zf.namelist()

if self._is_bzlmod_enabled():
Expand Down