• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

libarchive/H20-Oct-2019-914710

libarchive_c.egg-info/H03-May-2022-8254

tests/H20-Oct-2019-1,4961,296

.gitattributesH A D29-Nov-201625 21

.gitignoreH A D29-Nov-201665 98

.travis.ymlH A D20-Oct-2019915 4334

LICENSE.mdH A D10-Jun-201851 21

MANIFEST.inH A D29-Nov-201619 21

MakefileH A D29-Nov-2016255 1410

PKG-INFOH A D20-Oct-20192.8 KiB8254

README.rstH A D06-Dec-20182 KiB7043

setup.cfgH A D20-Oct-2019136 139

setup.pyH A D20-Oct-2019617 2318

tox.iniH A D20-Oct-2019304 1715

version.pyH A D29-Nov-20161.3 KiB4627

README.rst

1.. image:: https://travis-ci.org/Changaco/python-libarchive-c.svg
2  :target: https://travis-ci.org/Changaco/python-libarchive-c
3
4A Python interface to libarchive. It uses the standard ctypes_ module to
5dynamically load and access the C library.
6
7.. _ctypes: https://docs.python.org/3/library/ctypes.html
8
9Installation
10============
11
12    pip install libarchive-c
13
14Compatibility
15=============
16
17python
18------
19
20python-libarchive-c is currently tested with python 2.7, 3.4, 3.5, and 3.6.
21
22If you find an incompatibility with older versions you can send us a small patch,
23but we won't accept big changes.
24
25libarchive
26----------
27
28python-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::
29
30    export LIBARCHIVE=/usr/local/Cellar/libarchive/3.3.3/lib/libarchive.13.dylib
31
32Usage
33=====
34
35Import::
36
37    import libarchive
38
39To extract an archive to the current directory::
40
41    libarchive.extract_file('test.zip')
42
43``extract_memory`` extracts from a buffer instead, and ``extract_fd`` extracts
44from a file descriptor.
45
46To read an archive::
47
48    with libarchive.file_reader('test.7z') as archive:
49        for entry in archive:
50            for block in entry.get_blocks():
51                ...
52
53``memory_reader`` reads from a memory buffer instead, and ``fd_reader`` reads
54from a file descriptor.
55
56To create an archive::
57
58    with libarchive.file_writer('test.tar.gz', 'ustar', 'gzip') as archive:
59        archive.add_files('libarchive/', 'README.rst')
60
61``memory_writer`` writes to a memory buffer instead, ``fd_writer`` writes to a
62file descriptor, and ``custom_writer`` sends the data to a callback function.
63
64You can also find more thorough examples in the ``tests/`` directory.
65
66License
67=======
68
69`CC0 Public Domain Dedication <http://creativecommons.org/publicdomain/zero/1.0/>`_
70