Python interface to libarchive
Project description
A Python interface to libarchive. It uses the standard ctypes module to dynamically load and access the C library.
Installation
pip install libarchive-c
Compatibility
python
python-libarchive-c is currently tested with python 3.6, 3.7, 3.8, and 3.9.
If you find an incompatibility with older versions you can send us a small patch, but we won’t accept big changes.
libarchive
python-libarchive-c may not work properly with obsolete versions of libarchive such as the ones included in MacOS. In that case you can install a recent version of libarchive (e.g. with brew install libarchive on MacOS) and use the LIBARCHIVE environment variable to point python-libarchive-c to it:
export LIBARCHIVE=/usr/local/Cellar/libarchive/3.3.3/lib/libarchive.13.dylib
Usage
Import:
import libarchive
To extract an archive to the current directory:
libarchive.extract_file('test.zip')
extract_memory extracts from a buffer instead, and extract_fd extracts from a file descriptor.
To read an archive:
with libarchive.file_reader('test.7z') as archive: for entry in archive: for block in entry.get_blocks(): ...
memory_reader reads from a memory buffer instead, and fd_reader reads from a file descriptor.
To create an archive:
with libarchive.file_writer('test.tar.gz', 'ustar', 'gzip') as archive: archive.add_files('libarchive/', 'README.rst')
memory_writer writes to a memory buffer instead, fd_writer writes to a file descriptor, and custom_writer sends the data to a callback function.
You can also find more thorough examples in the tests/ directory.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for libarchive_c-3.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffd5a47439e2f5aa1733ee420a36da3eb249e6e38acf949bc1b6670b47882e6c |
|
MD5 | 4d9e4b549e181c203125fe47728e4e64 |
|
BLAKE2b-256 | 32e964fbd164931a262b2e36547aefcc8c89c60f35acb28cb2494ecde1fd8a1a |