py7zr


Namepy7zr JSON
Version 0.21.0 PyPI version JSON
download
home_page
SummaryPure python 7-zip library
upload_time2024-03-02 01:31:41
maintainer
docs_urlNone
author
requires_python>=3.7
licenseLGPL-2.1-or-later
keywords compression 7zip lzma zstandard ppmd lzma2 bcj archive
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======================================
|logo| py7zr -- a 7z library on python
======================================

.. |logo| image:: logo.svg
    :width: 80pt
    :height: 80pt
    :target: https://pypi.org/project/py7zr

.. image:: https://readthedocs.org/projects/py7zr/badge/?version=latest
  :target: https://py7zr.readthedocs.io/en/latest/?badge=latest

.. image:: https://badge.fury.io/py/py7zr.svg
  :target: https://badge.fury.io/py/py7zr

.. image:: https://img.shields.io/pypi/dd/py7zr
  :target: https://pypi.org/project/py7zr

.. image:: https://img.shields.io/conda/vn/conda-forge/py7zr
  :target: https://anaconda.org/conda-forge/py7zr

.. image:: https://github.com/miurahr/py7zr/workflows/Run%20Tox%20tests/badge.svg
  :target: https://github.com/miurahr/py7zr/actions

.. image:: https://dev.azure.com/miurahr/github/_apis/build/status/miurahr.py7zr?branchName=master
  :target: https://dev.azure.com/miurahr/github/_build/latest?definitionId=14&branchName=master

.. image:: https://coveralls.io/repos/github/miurahr/py7zr/badge.svg?branch=master
  :target: https://coveralls.io/github/miurahr/py7zr?branch=master

.. image:: https://img.shields.io/pypi/l/py7zr
  :target: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  
.. image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg
  :target: https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md
  
.. image:: https://snyk.io/advisor/python/py7zr/badge.svg
  :target: https://snyk.io/advisor/python/py7zr
  :alt: py7zr
  

py7zr is a library and utility to support 7zip archive compression, decompression,
encryption and decryption written by Python programming language.

Discussion Forum
================

You are welcome to join discussions on project forum/builtin-board at
https://github.com/miurahr/py7zr/discussions

You can see announcements of new releases, questions and answers, and
new feature ideas. When you doubt for usage of py7zr library with unclear
manuals, please feel easy to raise question on forum.

Security Notice
===============

Please find a `Security Policy`_ of this project.

Version 0.20.0, 0.19.0, 0.18.10 or before has a `vulnerability for path traversal`_  attack.
Details are on "CVE-2022-44900: path traversal vulnerability in py7zr" `disclose article`_ .

Affected versions  are vulnerable to Directory Traversal due to insufficient checks in the 'py7zr.py' and 'helpers.py' files

You are recommend to update immediately to version 0.20.2 or later, 0.19.2 or 0.18.12

.. _`vulnerability for path traversal`: https://security.snyk.io/vuln/SNYK-PYTHON-PY7ZR-3092461

I really appreciate Mr. Matteo Cosentino for notification and corporation on security improvement.

.. _`disclose article`: https://lessonsec.com/cve/cve-2022-44900/

.. _`Security Policy` : https://py7zr.readthedocs.io/en/latest/SECURITY.html

Compression algorithms
======================

``py7zr`` supports algorithms and filters which `lzma module`_ and `liblzma`_ support,
and supports BZip2 and Deflate that are implemented in python core libraries,
It also supports ZStandard, Brotli and PPMd with third party libraries.

``py7zr`` is also able to encrypt and decrypt data using 3rd party encryption library.


Supported algorithms
--------------------

* compress
    * LZMA2
    * LZMA
    * Bzip2
    * Deflate
    * Copy
    * ZStandard
    * Brotli
    * PPMd
    * Enhanced Deflate (Experimental)

* crypt
    * 7zAES

* Filters
    * Delta
    * BCJ(X86,ARMT,ARM,PPC,SPARC,IA64)

.. note::
  * A feature handling symbolic link is basically compatible with ``p7zip`` implementation,
    but not work with original 7-zip because the original does not implement the feature.
  * ``py7zr`` try checking symbolic links strictly and raise ValueError when bad link is requested,
    but it does **not** guarantee to block all the bad cases.
  * ZStandard and Brotli is not default methods of 7-zip, so these archives are considered
    not to be compatible with original 7-zip on windows/p7zip on linux/mac.
  * Enhanced Deflate is also known as `DEFLATE64` :sup:`TM` that is a registered trademark of `PKWARE, Inc.`
  * Enhanced Deflate is tested only on CPython. It is disabled on PyPy.

Not supported algorithms
------------------------

* BCJ2 (Standard `lzma module`_ does not provide).


Install
=======

You can install py7zr as usual other libraries using pip.

.. code-block:: shell

    $ pip install py7zr

OR, alternatively using conda:

.. code-block:: shell

    $ conda install -c conda-forge py7zr

Documents
=========

User manuals
------------

* `User Guide`_ for latest version.

* `API Guide`_ for latest version.

* `Manual`_ for stable version.

Developer guide
---------------

* `Contribution guidelines`_ for this project.

* `Contribution guidelines(html)`_  for this project.

* `Code of conduct`_ for this project.

* `Code of conduct(html)`_ for this project.

* `7z file specification`_ that py7zr stand on.


.. _`User Guide`: https://py7zr.readthedocs.io/en/latest/user_guide.html

.. _`API Guide` : https://py7zr.readthedocs.io/en/latest/api.html

.. _`Manual` : https://py7zr.readthedocs.io/en/stable/

.. _`Contribution guidelines(html)` : https://py7zr.readthedocs.io/en/latest/contribution.html

.. _`Contribution guidelines` : docs/contribution.rst

.. _`Code  of conduct` : docs/CODE_OF_CONDUCT.rst

.. _`Code  of conduct(html)` : https://py7zr.readthedocs.io/en/latest/CODE_OF_CONDUCT.html

.. _`7z file specification` : https://py7zr.readthedocs.io/en/latest/archive_format.html


CLI Usage
=========

You can run command script py7zr like as follows;

* List archive contents

.. code-block:: shell

    $ py7zr l test.7z

* Extract archive

.. code-block:: shell

    $ py7zr x test.7z

* Extract archive with password

.. code-block:: shell

    $ py7zr x -P test.7z
      password?: ****

* Create and compress to archive

.. code-block:: shell

    $ py7zr c target.7z test_dir

* Create multi-volume archive

.. code-block:: shell

    $ py7zr c -v 500k target.7z test_dir

* Test archive

.. code-block:: shell

    $ py7zr t test.7z

* Append files to archive

.. code-block:: shell

    $ py7zr a test.7z test_dir

* Show information

.. code-block:: shell

    $ py7zr i

* Show version

.. code-block:: shell

    $ py7zr --version


SevenZipFile Class Usage
========================

py7zr is a library which can use in your python application.

Decompression/Decryption
------------------------

Here is a code snippet how to decompress some file in your application.

.. code-block:: python

    import py7zr

    archive = py7zr.SevenZipFile('sample.7z', mode='r')
    archive.extractall(path="/tmp")
    archive.close()



You can also use 'with' block because py7zr provide context manager(v0.6 and later).

.. code-block:: python

    import py7zr

    with py7zr.SevenZipFile('sample.7z', mode='r') as z:
        z.extractall()

    with py7zr.SevenZipFile('target.7z', 'w') as z:
        z.writeall('./base_dir')


``py7zr`` also supports extraction of single or selected files by 'extract(targets=['file path'])'.
Note: if you specify only a file but not a parent directory, it will fail.

.. code-block:: python

    import py7zr
    import re

    filter_pattern = re.compile(r'<your/target/file_and_directories/regex/expression>')
    with py7zr.SevenZipFile('archive.7z', 'r') as archive:
        allfiles = archive.getnames()
        selective_files = [f for f in allfiles if filter_pattern.match(f)]
        archive.extract(targets=selective_files)


py7zr support an extraction of password protected archive.(v0.6 and later)

.. code-block:: python

    import py7zr

    with py7zr.SevenZipFile('encrypted.7z', mode='r', password='secret') as z:
        z.extractall()

Compression/Encryption
----------------------

Here is a code snippet how to produce archive.

.. code-block:: python

    import py7zr

    with py7zr.SevenZipFile('target.7z', 'w') as archive:
        archive.writeall('/path/to/base_dir', 'base')


To create encrypted archive, please pass a password.

.. code-block:: python

    import py7zr

    with py7zr.SevenZipFile('target.7z', 'w', password='secret') as archive:
        archive.writeall('/path/to/base_dir', 'base')


To create archive with algorithms such as zstandard, you can call with custom filter.

.. code-block:: python

    import py7zr

    my_filters = [{"id": py7zr.FILTER_ZSTD}]
    another_filters = [{"id": py7zr.FILTER_ARM}, {"id": py7zr.FILTER_LZMA2, "preset": 7}]
    with py7zr.SevenZipFile('target.7z', 'w', filters=my_filters) as archive:
        archive.writeall('/path/to/base_dir', 'base')


shutil helper
=============

py7zr also support `shutil`  interface.

.. code-block:: python

    from py7zr import pack_7zarchive, unpack_7zarchive
    import shutil

    # register file format at first.
    shutil.register_archive_format('7zip', pack_7zarchive, description='7zip archive')
    shutil.register_unpack_format('7zip', ['.7z'], unpack_7zarchive)

    # extraction
    shutil.unpack_archive('test.7z', '/tmp')

    # compression
    shutil.make_archive('target', '7zip', 'src')


Requirements
============

`py7zr` uses a python3 standard `lzma module`_ for extraction and compression.
The standard lzma module uses `liblzma`_ that support core compression algorithm of 7zip.

Minimum required version is Python 3.7.

``py7zr`` tested on Linux, macOS, Windows and Ubuntu aarch64.

It hopefully works on M1 Mac too.

Recommended versions are:

- CPython 3.7.5, CPython 3.8.0 and later.
- PyPy3.7-7.3.3 and later.

Following fixes are included in these versions, and it is not fixed on python3.6.

- `BPO-21872`_: LZMA library sometimes fails to decompress a file
- `PyPy3-3090`_: lzma.LZMADecomporessor.decompress does not respect max_length
- `PyPy3-3242`_: '_lzma_cffi' has no function named 'lzma_stream_encoder'

Following improvements are included in CPython 3.10

- `BPO-41486`_: Faster bz2/lzma/zlib via new output buffering

.. _`lzma module`: https://docs.python.org/3/library/lzma.html
.. _`liblzma`: https://tukaani.org/xz/
.. _`BPO-21872`: https://bugs.python.org/issue21872
.. _`BPO-41486`: https://bugs.python.org/issue41486
.. _`PyPy3-3090`: https://foss.heptapod.net/pypy/pypy/-/issues/3090
.. _`PyPy3-3242`: https://foss.heptapod.net/pypy/pypy/-/issues/3242



Dependencies
============

There are several dependencies to support algorithms and CLI expressions.

===================== ===============================
Package               Purpose
===================== ===============================
`PyCryptodomex`_      7zAES encryption
`PyZstd`_             ZStandard compression
`PyPPMd`_             PPMd compression
`Brotli`_             Brotli compression (CPython)
`BrotliCFFI`_         Brotli compression (PyPy)
`inflate64`_          Enhanced deflate compression
`pybcj`_              BCJ filters
`multivolumefile`_    Multi-volume archive read/write
`texttable`_          CLI formatter
===================== ===============================


.. _`Pycryptodomex` : https://www.pycryptodome.org/en/latest/index.html
.. _`PyZstd` : https://pypi.org/project/pyzstd
.. _`PyPPMd` : https://pypi.org/project/pyppmd
.. _`Brotli` : https://pypi.org/project/brotli
.. _`BrotliCFFI` : https://pypi.org/project/brotlicffi
.. _`inflate64` : https://pypi.org/project/inflate64
.. _`pybcj` : https://pypi.org/project/pybcj
.. _`multivolumefile` : https://pypi.org/project/multivolumefile
.. _`texttable` : https://pypi.org/project/texttable


Performance
===========

You can find a compression and decompression benchmark results at
[Github issue](https://github.com/miurahr/py7zr/issues/297) and [wiki page](https://github.com/miurahr/py7zr/wiki/Benchmarks)

py7zr works well, but slower than ``7-zip`` and ``p7zip`` C/C++ implementation by several reasons.
When compression/decompression **speed** is important, it is recommended to use these
alternatives through ``subprocess.run`` python interface.

py7zr consumes some memory to decompress and compress data. It requires about 300MiB - 700MiB free memory to work well at least.


Use Cases
=========

- `aqtinstall`_ Another (unofficial) Qt (aqt) CLI Installer on multi-platforms.
- PreNLP_ Preprocessing Library for Natural Language Processing
- mlox_  a tool for sorting and analyzing Morrowind plugin load order

.. _aqtinstall: https://github.com/miurahr/aqtinstall
.. _PreNLP: https://github.com/lyeoni/prenlp
.. _mlox: https://github.com/mlox/mlox

License
=======

* Copyright (C) 2019-2024 Hiroshi Miura

* pylzma Copyright (c) 2004-2015 by Joachim Bauch
* 7-Zip Copyright (C) 1999-2010 Igor Pavlov
* LZMA SDK Copyright (C) 1999-2010 Igor Pavlov

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

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "py7zr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "compression,7zip,lzma,zstandard,ppmd,lzma2,bcj,archive",
    "author": "",
    "author_email": "Hiroshi Miura <miurahr@linux.com>",
    "download_url": "https://files.pythonhosted.org/packages/fa/5c/44db15249a140e62589ea5c3980fba9988a8d73297575255f3a28dfc3ad4/py7zr-0.21.0.tar.gz",
    "platform": null,
    "description": "======================================\n|logo| py7zr -- a 7z library on python\n======================================\n\n.. |logo| image:: logo.svg\n    :width: 80pt\n    :height: 80pt\n    :target: https://pypi.org/project/py7zr\n\n.. image:: https://readthedocs.org/projects/py7zr/badge/?version=latest\n  :target: https://py7zr.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://badge.fury.io/py/py7zr.svg\n  :target: https://badge.fury.io/py/py7zr\n\n.. image:: https://img.shields.io/pypi/dd/py7zr\n  :target: https://pypi.org/project/py7zr\n\n.. image:: https://img.shields.io/conda/vn/conda-forge/py7zr\n  :target: https://anaconda.org/conda-forge/py7zr\n\n.. image:: https://github.com/miurahr/py7zr/workflows/Run%20Tox%20tests/badge.svg\n  :target: https://github.com/miurahr/py7zr/actions\n\n.. image:: https://dev.azure.com/miurahr/github/_apis/build/status/miurahr.py7zr?branchName=master\n  :target: https://dev.azure.com/miurahr/github/_build/latest?definitionId=14&branchName=master\n\n.. image:: https://coveralls.io/repos/github/miurahr/py7zr/badge.svg?branch=master\n  :target: https://coveralls.io/github/miurahr/py7zr?branch=master\n\n.. image:: https://img.shields.io/pypi/l/py7zr\n  :target: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html\n  \n.. image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg\n  :target: https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md\n  \n.. image:: https://snyk.io/advisor/python/py7zr/badge.svg\n  :target: https://snyk.io/advisor/python/py7zr\n  :alt: py7zr\n  \n\npy7zr is a library and utility to support 7zip archive compression, decompression,\nencryption and decryption written by Python programming language.\n\nDiscussion Forum\n================\n\nYou are welcome to join discussions on project forum/builtin-board at\nhttps://github.com/miurahr/py7zr/discussions\n\nYou can see announcements of new releases, questions and answers, and\nnew feature ideas. When you doubt for usage of py7zr library with unclear\nmanuals, please feel easy to raise question on forum.\n\nSecurity Notice\n===============\n\nPlease find a `Security Policy`_ of this project.\n\nVersion 0.20.0, 0.19.0, 0.18.10 or before has a `vulnerability for path traversal`_  attack.\nDetails are on \"CVE-2022-44900: path traversal vulnerability in py7zr\" `disclose article`_ .\n\nAffected versions  are vulnerable to Directory Traversal due to insufficient checks in the 'py7zr.py' and 'helpers.py' files\n\nYou are recommend to update immediately to version 0.20.2 or later, 0.19.2 or 0.18.12\n\n.. _`vulnerability for path traversal`: https://security.snyk.io/vuln/SNYK-PYTHON-PY7ZR-3092461\n\nI really appreciate Mr. Matteo Cosentino for notification and corporation on security improvement.\n\n.. _`disclose article`: https://lessonsec.com/cve/cve-2022-44900/\n\n.. _`Security Policy` : https://py7zr.readthedocs.io/en/latest/SECURITY.html\n\nCompression algorithms\n======================\n\n``py7zr`` supports algorithms and filters which `lzma module`_ and `liblzma`_ support,\nand supports BZip2 and Deflate that are implemented in python core libraries,\nIt also supports ZStandard, Brotli and PPMd with third party libraries.\n\n``py7zr`` is also able to encrypt and decrypt data using 3rd party encryption library.\n\n\nSupported algorithms\n--------------------\n\n* compress\n    * LZMA2\n    * LZMA\n    * Bzip2\n    * Deflate\n    * Copy\n    * ZStandard\n    * Brotli\n    * PPMd\n    * Enhanced Deflate (Experimental)\n\n* crypt\n    * 7zAES\n\n* Filters\n    * Delta\n    * BCJ(X86,ARMT,ARM,PPC,SPARC,IA64)\n\n.. note::\n  * A feature handling symbolic link is basically compatible with ``p7zip`` implementation,\n    but not work with original 7-zip because the original does not implement the feature.\n  * ``py7zr`` try checking symbolic links strictly and raise ValueError when bad link is requested,\n    but it does **not** guarantee to block all the bad cases.\n  * ZStandard and Brotli is not default methods of 7-zip, so these archives are considered\n    not to be compatible with original 7-zip on windows/p7zip on linux/mac.\n  * Enhanced Deflate is also known as `DEFLATE64` :sup:`TM` that is a registered trademark of `PKWARE, Inc.`\n  * Enhanced Deflate is tested only on CPython. It is disabled on PyPy.\n\nNot supported algorithms\n------------------------\n\n* BCJ2 (Standard `lzma module`_ does not provide).\n\n\nInstall\n=======\n\nYou can install py7zr as usual other libraries using pip.\n\n.. code-block:: shell\n\n    $ pip install py7zr\n\nOR, alternatively using conda:\n\n.. code-block:: shell\n\n    $ conda install -c conda-forge py7zr\n\nDocuments\n=========\n\nUser manuals\n------------\n\n* `User Guide`_ for latest version.\n\n* `API Guide`_ for latest version.\n\n* `Manual`_ for stable version.\n\nDeveloper guide\n---------------\n\n* `Contribution guidelines`_ for this project.\n\n* `Contribution guidelines(html)`_  for this project.\n\n* `Code of conduct`_ for this project.\n\n* `Code of conduct(html)`_ for this project.\n\n* `7z file specification`_ that py7zr stand on.\n\n\n.. _`User Guide`: https://py7zr.readthedocs.io/en/latest/user_guide.html\n\n.. _`API Guide` : https://py7zr.readthedocs.io/en/latest/api.html\n\n.. _`Manual` : https://py7zr.readthedocs.io/en/stable/\n\n.. _`Contribution guidelines(html)` : https://py7zr.readthedocs.io/en/latest/contribution.html\n\n.. _`Contribution guidelines` : docs/contribution.rst\n\n.. _`Code  of conduct` : docs/CODE_OF_CONDUCT.rst\n\n.. _`Code  of conduct(html)` : https://py7zr.readthedocs.io/en/latest/CODE_OF_CONDUCT.html\n\n.. _`7z file specification` : https://py7zr.readthedocs.io/en/latest/archive_format.html\n\n\nCLI Usage\n=========\n\nYou can run command script py7zr like as follows;\n\n* List archive contents\n\n.. code-block:: shell\n\n    $ py7zr l test.7z\n\n* Extract archive\n\n.. code-block:: shell\n\n    $ py7zr x test.7z\n\n* Extract archive with password\n\n.. code-block:: shell\n\n    $ py7zr x -P test.7z\n      password?: ****\n\n* Create and compress to archive\n\n.. code-block:: shell\n\n    $ py7zr c target.7z test_dir\n\n* Create multi-volume archive\n\n.. code-block:: shell\n\n    $ py7zr c -v 500k target.7z test_dir\n\n* Test archive\n\n.. code-block:: shell\n\n    $ py7zr t test.7z\n\n* Append files to archive\n\n.. code-block:: shell\n\n    $ py7zr a test.7z test_dir\n\n* Show information\n\n.. code-block:: shell\n\n    $ py7zr i\n\n* Show version\n\n.. code-block:: shell\n\n    $ py7zr --version\n\n\nSevenZipFile Class Usage\n========================\n\npy7zr is a library which can use in your python application.\n\nDecompression/Decryption\n------------------------\n\nHere is a code snippet how to decompress some file in your application.\n\n.. code-block:: python\n\n    import py7zr\n\n    archive = py7zr.SevenZipFile('sample.7z', mode='r')\n    archive.extractall(path=\"/tmp\")\n    archive.close()\n\n\n\nYou can also use 'with' block because py7zr provide context manager(v0.6 and later).\n\n.. code-block:: python\n\n    import py7zr\n\n    with py7zr.SevenZipFile('sample.7z', mode='r') as z:\n        z.extractall()\n\n    with py7zr.SevenZipFile('target.7z', 'w') as z:\n        z.writeall('./base_dir')\n\n\n``py7zr`` also supports extraction of single or selected files by 'extract(targets=['file path'])'.\nNote: if you specify only a file but not a parent directory, it will fail.\n\n.. code-block:: python\n\n    import py7zr\n    import re\n\n    filter_pattern = re.compile(r'<your/target/file_and_directories/regex/expression>')\n    with py7zr.SevenZipFile('archive.7z', 'r') as archive:\n        allfiles = archive.getnames()\n        selective_files = [f for f in allfiles if filter_pattern.match(f)]\n        archive.extract(targets=selective_files)\n\n\npy7zr support an extraction of password protected archive.(v0.6 and later)\n\n.. code-block:: python\n\n    import py7zr\n\n    with py7zr.SevenZipFile('encrypted.7z', mode='r', password='secret') as z:\n        z.extractall()\n\nCompression/Encryption\n----------------------\n\nHere is a code snippet how to produce archive.\n\n.. code-block:: python\n\n    import py7zr\n\n    with py7zr.SevenZipFile('target.7z', 'w') as archive:\n        archive.writeall('/path/to/base_dir', 'base')\n\n\nTo create encrypted archive, please pass a password.\n\n.. code-block:: python\n\n    import py7zr\n\n    with py7zr.SevenZipFile('target.7z', 'w', password='secret') as archive:\n        archive.writeall('/path/to/base_dir', 'base')\n\n\nTo create archive with algorithms such as zstandard, you can call with custom filter.\n\n.. code-block:: python\n\n    import py7zr\n\n    my_filters = [{\"id\": py7zr.FILTER_ZSTD}]\n    another_filters = [{\"id\": py7zr.FILTER_ARM}, {\"id\": py7zr.FILTER_LZMA2, \"preset\": 7}]\n    with py7zr.SevenZipFile('target.7z', 'w', filters=my_filters) as archive:\n        archive.writeall('/path/to/base_dir', 'base')\n\n\nshutil helper\n=============\n\npy7zr also support `shutil`  interface.\n\n.. code-block:: python\n\n    from py7zr import pack_7zarchive, unpack_7zarchive\n    import shutil\n\n    # register file format at first.\n    shutil.register_archive_format('7zip', pack_7zarchive, description='7zip archive')\n    shutil.register_unpack_format('7zip', ['.7z'], unpack_7zarchive)\n\n    # extraction\n    shutil.unpack_archive('test.7z', '/tmp')\n\n    # compression\n    shutil.make_archive('target', '7zip', 'src')\n\n\nRequirements\n============\n\n`py7zr` uses a python3 standard `lzma module`_ for extraction and compression.\nThe standard lzma module uses `liblzma`_ that support core compression algorithm of 7zip.\n\nMinimum required version is Python 3.7.\n\n``py7zr`` tested on Linux, macOS, Windows and Ubuntu aarch64.\n\nIt hopefully works on M1 Mac too.\n\nRecommended versions are:\n\n- CPython 3.7.5, CPython 3.8.0 and later.\n- PyPy3.7-7.3.3 and later.\n\nFollowing fixes are included in these versions, and it is not fixed on python3.6.\n\n- `BPO-21872`_: LZMA library sometimes fails to decompress a file\n- `PyPy3-3090`_: lzma.LZMADecomporessor.decompress does not respect max_length\n- `PyPy3-3242`_: '_lzma_cffi' has no function named 'lzma_stream_encoder'\n\nFollowing improvements are included in CPython 3.10\n\n- `BPO-41486`_: Faster bz2/lzma/zlib via new output buffering\n\n.. _`lzma module`: https://docs.python.org/3/library/lzma.html\n.. _`liblzma`: https://tukaani.org/xz/\n.. _`BPO-21872`: https://bugs.python.org/issue21872\n.. _`BPO-41486`: https://bugs.python.org/issue41486\n.. _`PyPy3-3090`: https://foss.heptapod.net/pypy/pypy/-/issues/3090\n.. _`PyPy3-3242`: https://foss.heptapod.net/pypy/pypy/-/issues/3242\n\n\n\nDependencies\n============\n\nThere are several dependencies to support algorithms and CLI expressions.\n\n===================== ===============================\nPackage               Purpose\n===================== ===============================\n`PyCryptodomex`_      7zAES encryption\n`PyZstd`_             ZStandard compression\n`PyPPMd`_             PPMd compression\n`Brotli`_             Brotli compression (CPython)\n`BrotliCFFI`_         Brotli compression (PyPy)\n`inflate64`_          Enhanced deflate compression\n`pybcj`_              BCJ filters\n`multivolumefile`_    Multi-volume archive read/write\n`texttable`_          CLI formatter\n===================== ===============================\n\n\n.. _`Pycryptodomex` : https://www.pycryptodome.org/en/latest/index.html\n.. _`PyZstd` : https://pypi.org/project/pyzstd\n.. _`PyPPMd` : https://pypi.org/project/pyppmd\n.. _`Brotli` : https://pypi.org/project/brotli\n.. _`BrotliCFFI` : https://pypi.org/project/brotlicffi\n.. _`inflate64` : https://pypi.org/project/inflate64\n.. _`pybcj` : https://pypi.org/project/pybcj\n.. _`multivolumefile` : https://pypi.org/project/multivolumefile\n.. _`texttable` : https://pypi.org/project/texttable\n\n\nPerformance\n===========\n\nYou can find a compression and decompression benchmark results at\n[Github issue](https://github.com/miurahr/py7zr/issues/297) and [wiki page](https://github.com/miurahr/py7zr/wiki/Benchmarks)\n\npy7zr works well, but slower than ``7-zip`` and ``p7zip`` C/C++ implementation by several reasons.\nWhen compression/decompression **speed** is important, it is recommended to use these\nalternatives through ``subprocess.run`` python interface.\n\npy7zr consumes some memory to decompress and compress data. It requires about 300MiB - 700MiB free memory to work well at least.\n\n\nUse Cases\n=========\n\n- `aqtinstall`_ Another (unofficial) Qt (aqt) CLI Installer on multi-platforms.\n- PreNLP_ Preprocessing Library for Natural Language Processing\n- mlox_  a tool for sorting and analyzing Morrowind plugin load order\n\n.. _aqtinstall: https://github.com/miurahr/aqtinstall\n.. _PreNLP: https://github.com/lyeoni/prenlp\n.. _mlox: https://github.com/mlox/mlox\n\nLicense\n=======\n\n* Copyright (C) 2019-2024 Hiroshi Miura\n\n* pylzma Copyright (c) 2004-2015 by Joachim Bauch\n* 7-Zip Copyright (C) 1999-2010 Igor Pavlov\n* LZMA SDK Copyright (C) 1999-2010 Igor Pavlov\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n\n",
    "bugtrack_url": null,
    "license": "LGPL-2.1-or-later",
    "summary": "Pure python 7-zip library",
    "version": "0.21.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/miurahr/py7zr/issues",
        "Changelog": "https://py7zr.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://py7zr.readthedocs.io/en/stable/",
        "Homepage": "https://py7zr.readthedocs.io/",
        "Source": "https://github.com/miurahr/py7zr"
    },
    "split_keywords": [
        "compression",
        "7zip",
        "lzma",
        "zstandard",
        "ppmd",
        "lzma2",
        "bcj",
        "archive"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e738783a9591807e1e5fd9cd92ce6e0fe49a4ba5a84fed0f552599881017faa6",
                "md5": "82aa5b5681393daa01afc71b581624b6",
                "sha256": "ea6ded2e5c6d8539e3406cb3b0317192b32af59cff13eaf87702acc36a274da6"
            },
            "downloads": -1,
            "filename": "py7zr-0.21.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82aa5b5681393daa01afc71b581624b6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 67553,
            "upload_time": "2024-03-02T01:31:38",
            "upload_time_iso_8601": "2024-03-02T01:31:38.078639Z",
            "url": "https://files.pythonhosted.org/packages/e7/38/783a9591807e1e5fd9cd92ce6e0fe49a4ba5a84fed0f552599881017faa6/py7zr-0.21.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa5c44db15249a140e62589ea5c3980fba9988a8d73297575255f3a28dfc3ad4",
                "md5": "f39d829ee88fd09244d60b21473dfe4e",
                "sha256": "213a9cc46940fb8f63b4163643a8f5b36bbc798134746c3992d3bc6b14edab87"
            },
            "downloads": -1,
            "filename": "py7zr-0.21.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f39d829ee88fd09244d60b21473dfe4e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4991253,
            "upload_time": "2024-03-02T01:31:41",
            "upload_time_iso_8601": "2024-03-02T01:31:41.354713Z",
            "url": "https://files.pythonhosted.org/packages/fa/5c/44db15249a140e62589ea5c3980fba9988a8d73297575255f3a28dfc3ad4/py7zr-0.21.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-02 01:31:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "miurahr",
    "github_project": "py7zr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "py7zr"
}
        
Elapsed time: 0.20485s