PyLZMA
Platform independent python bindings for the LZMA compression library.
PyLZMA
Impressed by the spectacular compression ratios of the Inno Setup compiler, I wanted to use the great compression algorithm LZMA in my own Python programs. As the LZMA SDK by Igor Pavlov is Open Source, it was no problem writing some Python wrappers for the C library. They currently run fine both on Windows and Linux, so hopefully, I can provide a tool that enables the user to read and create 7-zip compatible archives on Linux (as this is not supported by the original 7-zip).
Comparison
Here are the compression results of different data files with the zlib, bz2 and pylzma modules:
| Description | Original | zlib | bz2 | pylzma | ||||
| SVN export of version 0.1.0 | 542.720 | 100% | 97.923 | 18.04% | 79.660 | 14.68% | 74.009 | 13.64% |
| 20 JPEG wallpapers | 7.178.240 | 100% | 6.989.049 | 97.36% | 7.022.040 | 97.82% | 698.0443 | 97.24% |
| libxml2-2.6.22.tar | 34.232.320 | 100% | 4.567.489 | 13.34% | 3.408.457 | 9.96% | 2.475.885 | 7.23% |
Depending on your input data, the differences between zlib/bz2 and pylzma may be even bigger!
Features
- Compression / decompression of a single block of data
- Compression from a file-like object (must provide a read method)
- Streaming decompression through multiple calls to decompress
- An initial library that supports reading of 7-zip archives (both solid and non-solid)
- Compiles and runs on Windows, Linux and OSX
- Multithreaded compression on Windows
- Built with LZMA SDK 4.65
Download
You can download the binaries and the source code for the wrappers below.
For building, simply run:
python setup.py build
Afterwards, you will find a file pylzma.pyd in the directory build/lib.win32-<PythonVersion> that can get imported by Python. On linux, the file will be called pylzma.so and can be found in a directory called build/lib.linux-<arch>-<PythonVersion>.
Compilation has been tested with Microsoft Visual Studio 2003, GCC 3 (Linux, Cygwin), GCC 4 (Linux) but should work with any ANSI C compiler. Please let me know if you encounter any problems.
Installation using Python eggs
If you installed the EasyInstall package, you can install the latest version of pylzma using the following command:
easy_install pylzma
Refer to the EasyInstall documentation for further details about installing Python eggs.
Git repository
To get access to my development repository, head your browser to the following URL: http:/github.com/fancycode/pylzma
Third-party ports
You can find a port to FreeBSD on freshports.org.
A MacOS X port is maintained at darwinports.com.
Bugs
Please bring all issues to my Bugzilla bugtracker.
If you like this software, please give me some feedback!