-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add ability to unzip artifacts zipped with zstd #527
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| # Monkey patches - import these first to register handlers globally | ||
| import zipfile_zstd # noqa: F401 - Registers zstd compression support with zipfile module. Should not be required after upgrading to python 3.14 | ||
|
|
||
| __version__ = "0.0.1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,3 +125,22 @@ def test_max_file_size(self, hackernews_xcarchive: Path) -> None: | |
| # iOS fixture is ~32MB uncompressed, so limit of 10MB should fail | ||
| with pytest.raises(UnreasonableZipError, match="exceeding the limit of 10.0MB"): | ||
| check_reasonable_zip(zf, max_uncompressed_size=10 * 1024 * 1024) | ||
|
|
||
| def test_extract_zstd_zip(self) -> None: | ||
| """Test that zstd-compressed zips can be extracted.""" | ||
| with tempfile.NamedTemporaryFile(suffix=".zip") as temp_file: | ||
| temp_path = Path(temp_file.name) | ||
|
|
||
| # Create a zstd-compressed zip (compression method 93) | ||
| with zipfile.ZipFile(temp_path, "w") as zf: | ||
| zf.writestr("test.txt", "content", compress_type=93) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can this use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Unfortunately no - the standard library zipfile module doesn't define ZIP_ZSTANDARD. The zipfile_zstd package only adds the decompression handler, not the constant."
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps this will exist in the python 3.14 world though.. |
||
|
|
||
| try: | ||
| provider = ZipProvider(temp_path) | ||
| temp_dir = provider.extract_to_temp_directory() | ||
|
|
||
| assert temp_dir.exists() | ||
| assert (temp_dir / "test.txt").exists() | ||
| assert (temp_dir / "test.txt").read_text() == "content" | ||
| finally: | ||
| temp_path.unlink(missing_ok=True) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we get zstd for free in Python 3.14, not sure if you looked into that option: https://docs.python.org/3/library/compression.zstd.html#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried upgrading us to 3.14, but that requires upgrading
confluent-kafkato 2.12 which then conflicts withsentry-arroyowhich has that package pinned to <2.10.0... so not possible right nowhen we're off of arroyo though.. lol