-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
[Feature Request]: Add zstd support in tarfile #81276
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
Comments
Zstandard is getting more and more popular. It could be awesome if tarfile support this compression format for .tar.zst file. |
Curious about this as well. |
Is there any progress with this feature development? Arch Linux uses Python tar library for its toolset. Arch devs are looking to add ZSTD support to the toolset but it needs this feature to be implemented. |
This requires the stdlib to contain a Zstandard module. You can ask in the Idea forum: |
The tarfile module supports arbitrary compressions by using the stream mode. You only need to use a third-party library which provides zstd support. Recent versions of the tar utility has options to explicit support of new compressions: --lzip, --lzma, --lzop, --zstd, so corresponding modes can be added to the tarfile module. But it needs to include the support of these compressions in the stdlib. It should be discussed on the Python-ideas mailing list. https://mail.python.org/mailman3/lists/python-ideas.python.org/ |
There are two zstd modules on pypi:
The first one is too simple. The second one is powerful, but has too many APIs: IMO these are not necessary for stdlib. In addition, it needs to add something, such as the I looked at the zstd API, it's a bit simpler than lzma/bz2/zlib. If spend a month, should be able to make a zstd module for stdlib. Then discuss the detailed API on Python-Ideas. I once wanted to do this job, but it seems my time does not allow it. If anyone wants to do this work, please reply here. FYI, Python 3.10 schedule: |
I have spent two weeks, almost complete the code, a preview: Write directly for stdlib, since there are already zstd modules on pypi. Can also use these: |
@animalize wrote a The other main contender zstandard is very advanced, but doesn't try to adapt to the stdlib |
@animalize The PR you created is between branches on your own fork, is there any chance you could submit that PR against CPython upstream? |
Was looking whether zstd support was being worked on or if I could help, similar to the existing bzip and related modules that are super convenient to have in stdlib (thanks to whoever made those, in case they're around!). Happy to see u/animalize worked on it but... their user is deleted now? :( Does anyone have a copy of the code and know what license it was under? Edit: I also signed up for and replied on the related discourse forum thread: https://discuss.python.org/t/integrate-zstd-compression-in-tarfile-module/7013 |
So, uh, by proxy does that mean that I dunno if perhaps someone at Github could return an archive of that repo / PR? Worst case, the source code tarball can be downloaded from PyPI and then the PR turning it into a module can be rewritten. The license is declared as 3-clause BSD. |
@lgommans You can see animalize's changes on the Wayback Machine (be patient, it takes a while to load): https://web.archive.org/web/20231214201705/https://github.com/animalize/cpython/pull/8/files |
@dralley https://web.archive.org/web/20231126145554/https://github.com/animalize/pyzstd shows the repo was still active at least as late as November 2023, and had two other contributors. Checking their forks, and poking around some other links:
|
animalize was definitely gone by mid-December (I tried to look it up). I use indygreg's zstandard. The documentation buries the one-shot APIs a little, but they work great. |
|
For those still searching for a quick solution (based on zstandard):
This is not perfect and does not handle file objects, but it may be good enough for some use cases. I am the author of this code and explicitly grant a MIT license on it as the original tarfile.py also is MIT licensed. |
Doesn't tarfile say "However, such a TarFile object is limited in that it does not allow random access" for this stream mode? So while it may be sufficient, there are significant limitations compared to real zstd support. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: