Skip to main content

Library to (un)pack archives and (de)compress files

Project description

pipeline coverage




Python library providing an API to unpack/decompress and pack/compress directories and files. It’s a wrapper around the supported archive and compression formats.

Supported Archives:

Archives are always unpacked to a new directory!
  • rar

    • application/rar
    • application/x-rar
  • zip

    • application/zip
    • application/x-zip
  • tar

    no compression (See usage examples below for an example of adding compression)

    • application/tar
    • application/x-tar

Supported Compressions:

  • gz
    • application/gzip
    • application/x-gzip
  • xz
    • application/xz
    • application/x-xz
  • bz2
    • application/bzip
    • application/x-bzip


pip install xtract

See the quickstart documentation for more detailed installation instructions.

Usage Examples

The convenience function xtract can be used to unpack/decompress anything:

>>> from xtract import xtract
>>> xtract('my-directory.tar.gz')

Use the all switch to loop until FileTypeNotSupported is raised:

>>> xtract('my-directory.tar.gz', all=True)

Compress a file:

>>> from xtract import bz2
>>> bz2('my-file.txt', delete_source=True)

Every function returns the destination (if successful) to chain them:

This creates an intermediate .tar file! Use delete_source=True to delete it afterwards.
>>> from xtract import tar, gzip
>>> gzip(
>>>     tar('my-directory', ['file1.txt', 'file2.txt']),
>>>     delete_source=True
>>> )

See the manual for more examples.


Copyright (c) 2017 Mathias Stelzer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <>.

Project details

Download files

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

Files for xtract, version 0.1a3
Filename, size File type Python version Upload date Hashes
Filename, size xtract-0.1a3-py2.py3-none-any.whl (13.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size xtract-0.1a3.tar.gz (20.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page