Skip to main content

Python interface to libarchive

Project description

https://travis-ci.org/Changaco/python-libarchive-c.svg

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

CC0 Public Domain Dedication

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libarchive-c-3.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

libarchive_c-3.1-py2.py3-none-any.whl (12.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file libarchive-c-3.1.tar.gz.

File metadata

  • Download URL: libarchive-c-3.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for libarchive-c-3.1.tar.gz
Algorithm Hash digest
SHA256 618a7ecfbfb58ca15e11e3138d4a636498da3b6bc212811af158298530fbb87e
MD5 8c62da42a8b9bd24642e5430427e6f5a
BLAKE2b-256 53d5bee2190570a2b4c372a022f16ebfc2313ff717a023f277f5d6f9ebf281a2

See more details on using hashes here.

File details

Details for the file libarchive_c-3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: libarchive_c-3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for libarchive_c-3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8a74f2c853f1e5d8f16a01c2582aff1007fcc46f458234656db0842690438ae7
MD5 9059117d476ff66fbf42b1f6e15de594
BLAKE2b-256 1da1da16f595b8accca267f90172b3136c0dc9ce72a028da6533b65df4121c9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page