Skip to main content

Pure python 7-zip decompression(restricted) library

Project description

py7zr

https://readthedocs.org/projects/py7zr/badge/?version=latest https://badge.fury.io/py/py7zr.svg https://travis-ci.org/miurahr/py7zr.svg?branch=master https://ci.appveyor.com/api/projects/status/966k084122lhs3i6?svg=true https://dev.azure.com/miurahr/github/_apis/build/status/miurahr.py7zr?branchName=master https://coveralls.io/repos/github/miurahr/py7zr/badge.svg?branch=master

Pure python 7-zip implementation

Dependency

It uses a standard lzma module and its API supported. It also uses type definitions introduced in Python3.6.

Minimum required version is Python 3.5.

Version recommendations are:

  • CPython 3.7.5, CPython 3.8.0 and later.

  • PyPy3.6-7.2.0 and later.

Following fixes are included in above versions and python3.6 series is not fixed it.

  • BPO-21872: LZMA library sometimes fails to decompress a file

  • PyPy3-3088: lzma.LZMADecomporessor.decompress does not respect max_length

Document

Here is a readthedocs manual document.

Usage

You can run command script py7zr like as follows;

$ py7zr l test.7z

py7zr is a library which can use in your pyhton application. Here is a code snippet how to decompress some file in your applicaiton.

import py7zr

def decompress(file):
    archive = py7zr.Archive(file)
    archive.extractall(path="/tmp")

py7zr also support shutil unpack interface.

frpm py7zr import unpack_7zarchive
import shutil

shutil.register_unpack_format('7zip', ['.7z'], unpack_7zarchive)
shutil.unpack_archive('test.7z', '/tmp')

License

  • Copyright (C) 2019 Hiroshi Miura

  • 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

Py7zr ChangeLog

All notable changes to this project will be documented in this file.

Unreleased

Added

Changed

Fixed

Deprecated

Removed

Security

v0.5a3

Support producing 7zip archive.

Fixed

  • Write: Produce a good archive file for multiple target files.

Removed

  • Drop py7zr.properties.FileAttributes; please use stat.FILE_ATTRIBUTES_*

v0.5a2

Changed

  • Move setuptools config in setup.cfg

v0.5a1

Added

  • Experimental support for compression and archiving.

  • SevenZipFile: accept pathlib.Path as a file argument.

  • Unit test: read and write UTF-16LE string for filename

Changed

  • Test: Use tmp_path fixture which is pytest default one.

Fixed

  • Skip rare case when directory already exist, that can happen multiple process working in same working directory.

  • SignatureHeader function: write nextheaderofs and nextheadersize as real_uint64.

  • docs: description of start header structure.

v0.4

Added

  • unit test for NullHandler, BufferHandler, FileHandler.

Changed

  • NullHandler, BufferHandler, FileHandler: open() now takes mode argument.

v0.4a2

Added

  • Support for pypy3 (pypy3.5-7.0) and later(pypy3.6-7.1 or later).

Changed

Fixed

  • Update README to indicate supported python version as 3.5 and later, pypy3 7.1 and later.

v0.4a1

Added

  • Update document to add 7zformat descriptions.

Changed

  • Remove print functions from API and moves CLI
    • API should not output anything other than error message. * Introduce FileInfo class to represent file attributes inside archive. * Introduce ArchiveInfo class to represent archive attributes. * provide archiveinfo() method to provide ArchiveInfo object. * now list() method returns List[FileInfo]

    • Every print things moves to Cli class.

  • Update tests according to API change.

  • Update documents to refrect API changes.

v0.3.5

Changed

  • Use seek&truncate for padding trailer if needed.

v0.3.4

Added

  • Docs: class diagram, design note, 7z formats and presentations.

  • Test for a target includes padding file.

Changed

  • Test file package naming.

Fixed

  • Fix infinite loop when archive file need padding data for extraction.

v0.3.3

Added

  • Add test for zerofile with multi-foler archive.

Fixed

  • Fix zerofile extraction error with multithread mode(#24, thanks @Arten013)

v0.3.2

Added

  • typing hints

  • CI test with mypy

  • Unit test: SignatureHeader.write() method.

  • Unit test: unknown mode for SevenZipFile constructor.

  • Unit test: SevenZipFile.write() method.

Changed

  • Conditional priority not likely to be external in header.

  • Refactoring read_uint64().

Fixed

  • SignatureHeader.write(): fix exception to write 7zip version.

v0.3.1

Added

  • CLI i subcommand: show codec information.

  • Decompression performance test as regression test.

  • Add more unit test for helper functions.

Changed

  • List subcommand now do not show compressed file size in solid compression. This is as same behavior as p7zip command.

  • Merge io.py into archiveinfo.py

  • Drop internal intermediate queue, which is not used.

Fixed

  • Always overwrite when archive has multiple file with same name.

v0.3

Added

  • Add some code related to support write feature(wip).

  • Static check for import order in python sources and MANIFEST.in

Changed

  • Concurrent decompression with threading when an archive is in multi folder compression.

  • Pytest configurations are set in tox.ini

Fixed

  • Package now has test code and data.

v0.2.0

Fixed

  • Detect race condition on os.mkdir

v0.1.6

Fixed

  • Wrong file size when lzma+bcj compression.

v0.1.5

Fixed

  • Suppress warning: not dequeue from queue length 0

v0.1.4

Changed

  • When a directory exist for target, do not raise error, and when out of it raise exception

  • Refactoring FileArchivesList and FileArchive classes.

v0.1.3

Changed

  • When a directory exist for target, do not raise error, and when out of it raise exception

v0.1.2

Changed

  • Refactoring CLI with cli package and class.

Fixed

  • Archive with zero size file cause exception with file not found error(#4).

Removed

  • Drop unused code chunks.

  • Drop Digests class and related unit test.

v0.1.1

Added

  • Add write(), close() and testzip() dummy methods which raises NotImplementedError.

  • Add more unit tests for write functions.

Fixed

  • Fix Sphinx error in documentation.

  • SevenZipFile: Check mode before touch file.

  • Fix write_boolean() when array size is over 8.

  • Fix write_uint64() and read_uint64().

v0.1.0

Added

  • Introduce compression package.

  • Introduce SevenZipCompressor class.

  • Add write() method for each header class.

  • Add tests for write methods.

  • Add method for registering shutil.

Changed

  • Each header classes has __slots__ definitions for speed and memory optimization.

  • Rename to ‘io’ package from ‘archiveio’

  • Each header classes has classmethod ‘retrieve’ and constructor does not reading a archive file anymore.

  • Change to internalize _read() method for each header classes.

  • get_decompressor() method now become SevenZipDecompressor class.

  • Each header classes initializes members to None in constructor.

  • Method definitions map become an internal member of SevenZipDecompressor or SevenZipCompressor class.

  • Add test package compress

Fixed

  • Fix ArchiveProperties read function.

v0.0.8

Added

  • Test for CLI.

Changed

  • Improve main function.

  • Improve tests, checks outputs with sha256

v0.0.7

Added

  • CI test on AppVeyor.

Changed

  • Worker class refactoring.

Fixed

  • Fix test cases: bugzilla_16 and github_14.

  • Test: set timezone to UTC on Unix and do nothing on Windows.

v0.0.6

Fixed

  • Fix too many file descriptors opened error.

v0.0.5

Changed

  • Test: check sha256 for extracted files

Fixed

  • Fix decompressiong archive with LZMA2 and BCJ method

  • Fix decompressing multi block archive

  • Fix file mode on unix/linux.

v0.0.4

Added

  • Set file modes for extracted files.

  • More unit test.

Changed

  • Travis-CI test on python 3.7.

Fixed

  • Fix to set extracted files timestamp as same as archived.

v0.0.3

Added

  • PyPi package index.

Fixed

  • setup: set universal = 0 because only python 3 is supported.

v0.0.2

Changed

  • refactoring all the code.

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

py7zr-0.5a3.tar.gz (17.9 MB view hashes)

Uploaded Source

Built Distribution

py7zr-0.5a3-py3-none-any.whl (44.7 kB view hashes)

Uploaded Python 3

Supported by

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