Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pkg_zip compression configurable #737

Merged
merged 4 commits into from
Aug 17, 2023
Merged

Conversation

flode
Copy link
Contributor

@flode flode commented Aug 17, 2023

Zip offers different compression algorithms and levels. For packaging, sometimes faster compression speed is more important than size. With pkg_tar, there is already the option to use a custom compressor, there's no similar option for pkg_zip yet.

This PR exposes the zip compression_level and compression_type arguments for pkg_zip, thus enabling the use case.

The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED

There's a new test case that verifies that the compression settings work by comparing the compressed file sizes.

The default compression level is the same as in this recent change for pkg_tar in #720

@flode flode requested review from aiuto and alexeagle as code owners August 17, 2023 11:52
@google-cla
Copy link

google-cla bot commented Aug 17, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Zip offers different compression algorithms and levels. For packaging,
sometimes faster compression speed is more important than size.
With pkg_tar, there is already the option to use a custom compressor.

For pkg_zip these use case are now possible with the exposed zip
compression_level and compression_type arguments in this PR.

There's a new test case that verifies that the compression settings work by
comparing the compressed file sizes.

The default compression level is the same as recently change for pkg_tar in
flode added 2 commits August 17, 2023 15:38
Python3.6 is already end-of-life but seems to still be used in the CI.
Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

I wish the markdown change for the documentation was also part of this PR. I'm new to maintaining rules_pkg, my understanding is the docs are only generated later, if at all (#716). I'll try to convince @aiuto that we should change it.

pkg/private/zip/build_zip.py Show resolved Hide resolved
pkg/private/zip/zip.bzl Outdated Show resolved Hide resolved
@flode
Copy link
Contributor Author

flode commented Aug 17, 2023

Awesome, thanks!

I wish the markdown change for the documentation was also part of this PR. I'm new to maintaining rules_pkg, my understanding is the docs are only generated later, if at all (#716). I'll try to convince @aiuto that we should change it.

I see there's some steps in docbuild/BUILD on how to regenerate the docs, running that now has some different changes in addition to mine. Not sure if having the docs as part of each commit is worth it. But docs should definitely be generated for each release.

@alexeagle alexeagle merged commit 6ad211b into bazelbuild:main Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants