Code Monkey home page Code Monkey logo

pylzma's Introduction

Python bindings for LZMA

  • PyLZMA Copyright (C) 2004-2015 Joachim Bauch
  • 7-Zip Copyright (C) 1999-2010 Igor Pavlov
  • LZMA SDK Copyright (C) 1999-2010 Igor Pavlov

Linux Build Status Windows Build Status

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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

For the latest releases of PyLZMA visit https://github.com/fancycode/pylzma

pylzma's People

Contributors

bovee avatar cool-rr avatar fancycode avatar pelayogmp avatar theofilis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pylzma's Issues

pylzma does not support large files (> 2GB)

I'm trying to use pylzma to decode a very large file, met following error,

... ...
dec = pylzma.decompressobj(maxlength=self._start+self.size)
OverflowError: signed integer is greater than maximum

I made following patch, while I'm not sure if my understand is correct, please help to review

diff --git a/src/pylzma/pylzma_decompress.c b/src/pylzma/pylzma_decompress.c
index c94bf3b..a28df61 100644
--- a/src/pylzma/pylzma_decompress.c
+++ b/src/pylzma/pylzma_decompress.c
@@ -42,7 +42,7 @@ pylzma_decompress(PyObject *self, PyObject *args, PyObject *kwargs)
{
unsigned char *data;
Byte *tmp;

  • int length, bufsize=BLOCK_SIZE, avail, totallength=-1;
  • SizeT length, bufsize=BLOCK_SIZE, avail, totallength=-1;
    PyObject *result=NULL;
    CLzmaDec state;
    ELzmaStatus status;
    @@ -51,8 +51,8 @@ pylzma_decompress(PyObject *self, PyObject *args, PyObject *kwargs)
    CMemoryOutStream outStream;
    // possible keywords for this function
    static char *kwlist[] = {"data", "bufsize", "maxlength", NULL};
  • if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|ii", kwlist, &data, &length, &bufsize, &totallength))
  • if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|ll", kwlist, &data, &length, &bufsize, &totallength))
    return NULL;

if (totallength != -1) {
diff --git a/src/pylzma/pylzma_decompress_compat.c b/src/pylzma/pylzma_decompress_compat.c
index 1fd8e60..df54c42 100644
--- a/src/pylzma/pylzma_decompress_compat.c
+++ b/src/pylzma/pylzma_decompress_compat.c
@@ -46,13 +46,13 @@ const char doc_decompress_compat[] =
PyObject *pylzma_decompress_compat(PyObject *self, PyObject *args)
{
char *data;

  • int length, blocksize=BLOCK_SIZE;
  • SizeT length, blocksize=BLOCK_SIZE;
    PyObject *result = NULL;
    lzma_stream stream;
    int res;
    char *output;
  • if (!PyArg_ParseTuple(args, "s#|i", &data, &length, &blocksize))
  • if (!PyArg_ParseTuple(args, "s#|l", &data, &length, &blocksize))
    return NULL;

memset(&stream, 0, sizeof(stream));
diff --git a/src/pylzma/pylzma_decompressobj.c b/src/pylzma/pylzma_decompressobj.c
index b860daf..6d0e2bc 100644
--- a/src/pylzma/pylzma_decompressobj.c
+++ b/src/pylzma/pylzma_decompressobj.c
@@ -31,15 +31,14 @@
static int
pylzma_decomp_init(CDecompressionObject *self, PyObject *args, PyObject *kwargs)
{

  • int max_length = -1;
  • SizeT max_length = -1;

// possible keywords for this function
static char *kwlist[] = {"maxlength", NULL};

  • if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &max_length))
  • if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|l", kwlist, &max_length))
    return -1;
  • if (max_length == 0 || max_length < -1) {
  • if (max_length <= 0) {
    PyErr_SetString(PyExc_ValueError, "the decompressed size must be greater than zero");
    return -1;
    }
    @@ -64,12 +63,12 @@ pylzma_decomp_decompress(CDecompressionObject *self, PyObject *args)
    PyObject *result=NULL;
    unsigned char *data;
    Byte *next_in, *next_out;
  • int length, res, bufsize=BLOCK_SIZE;
  • SizeT length, res, bufsize=BLOCK_SIZE;
    SizeT avail_in;
    SizeT inProcessed, outProcessed;
    ELzmaStatus status;
  • if (!PyArg_ParseTuple(args, "s#|i", &data, &length, &bufsize)){
  • if (!PyArg_ParseTuple(args, "s#|l", &data, &length, &bufsize)){
    return NULL;
    }

@@ -297,12 +296,12 @@ doc_decomp_reset[] =
static PyObject *
pylzma_decomp_reset(CDecompressionObject *self, PyObject *args, PyObject *kwargs)
{

  • int max_length = -1;
  • SizeT max_length = -1;

// possible keywords for this function
static char *kwlist[] = {"maxlength", NULL};

  • if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &max_length))
  • if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|l", kwlist, &max_length))
    return NULL;

LzmaDec_Free(&self->state, &allocator);
diff --git a/src/pylzma/pylzma_decompressobj_compat.c b/src/pylzma/pylzma_decompressobj_compat.c
index 6c9e876..048780a 100644
--- a/src/pylzma/pylzma_decompressobj_compat.c
+++ b/src/pylzma/pylzma_decompressobj_compat.c
@@ -38,9 +38,9 @@ static PyObject *pylzma_decomp_decompress(CCompatDecompressionObject *self, PyOb
{
PyObject *result=NULL;
char *data;

  • int length, old_length, start_total_out, res, max_length=BLOCK_SIZE;
  • SizeT length, old_length, start_total_out, res, max_length=BLOCK_SIZE;
  • if (!PyArg_ParseTuple(args, "s#|i", &data, &length, &max_length))
  • if (!PyArg_ParseTuple(args, "s#|l", &data, &length, &max_length))
    return NULL;

if (max_length < 0)

Reading multiple individual files from solid 7zips duplicates a lot of work

Hi, it seems when you decompress stuff from solid 7zips in py7zlib it decompresses the beginning part of the file several times. Would it be possible to memoize this?

I'm going to make a patch for this.

Also, I noticed if you change self._file.read(1024) (in _read_from_decompressor) to a bigger number like 16384 there's about a 2x perf improvement.

Support for LZMA2

There is an updated LZMA SDK (9.20), and has support for LZMA2, pylzma should be updated to support that.

Missing "RELEASE-VERSION"

root@hehe:~/pylzma-master# sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 144, in
version = get_git_version().decode('utf-8'),
File "/home/lol/pylzma-master/version.py", line 97, in get_git_version
raise ValueError("Cannot find the version number!")
ValueError: Cannot find the version number!

Can't install from git repo due to this missing.

AssertionError on extracting a file from a 7z archive

Can anyone help solving this issue?
I am using the current master version from git.

Traceback (most recent call last):
  File "/home/brij/Documents/moody/moody_ws/MoodyUtils/com/moody/qareaders/SOXmlParser.py", line 38, in <module>
    FileUtil.extractPostsXml(cfile, OUTPUT_XML)
  File "/home/brij/Documents/moody/moody_ws/MoodyUtils/com/moody/utils/FileUtil.py", line 66, in extractPostsXml
    o.write(arch.getmember("Posts.xml").read())
  File "/usr/local/lib/python2.7/dist-packages/pylzma-0.4.4_37_gbb2bdev-py2.7-linux-x86_64.egg/py7zlib.py", line 575, in read
    data = getattr(self, decoder)(coder, data)
  File "/usr/local/lib/python2.7/dist-packages/pylzma-0.4.4_37_gbb2bdev-py2.7-linux-x86_64.egg/py7zlib.py", line 646, in _read_bzip
    return self._read_from_decompressor(coder, dec, input)
  File "/usr/local/lib/python2.7/dist-packages/pylzma-0.4.4_37_gbb2bdev-py2.7-linux-x86_64.egg/py7zlib.py", line 611, in _read_from_decompressor
    assert len(tmp) > 0
AssertionError

Error while decompressing: 1 when decompressing .7z encrypted file

After creating a .7z file using (there was no file of that name prior to below, so only one file in the archive):

rc = subprocess.call([r"C:\Program Files\7-Zip\7z.exe", 'a', zfn, tfn, '-mhe', '-p%s' % pw2, '-t7z'])

I try to read it back in:

fp = open(zfn, 'rb')
archive = py7zlib.Archive7z(fp, password=pw2)
cf = archive.getmember(tfn).read()

During the 'archive=' statement, an exception is raised at line 748 in py7zlib.py:

'data += pylzma.decompress(props+tmp, maxlength=folder.unpacksizes[idx])'

raises an exception on the first pass. The message returned is "Error while decompressing: 1"
idx=0 and folder.unpacksizes[0]=96 at the time of the exception.

Thanks for any insight.

Empty files not extracted

For empty files in archive i need to use code like this , may be you can improve its by default ?

                # For empty files
                for fileinfo in a.archive.header.files.files:
                    if not fileinfo['emptystream']:
                        continue

                    name = fileinfo['filename']
                    print(name)

                    try:
                        unicode_name = as_unicode(name)
                    except UnicodeDecodeError:
                        unicode_name = name.decode('cp866').encode('UTF-8')

                    unicode_name = unicode_name.replace('\\', '/')

                    file_name = os.path.join(abs_extract_path, unicode_name)
                    dir_name = os.path.dirname(file_name)

                    if not os.path.exists(dir_name):
                        os.makedirs(dir_name)
                    if os.path.isdir(file_name):
                        continue

                    f2 = open(file_name, 'w')
                    f2.close()

Test data is not included in the pypi tarball

When attempting to run tests from the pypi tarball, they fail due to missing files:

======================================================================
ERROR: test_bugzilla_16 (tests.test_7zfiles.Test7ZipFiles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_7zfiles.py", line 212, in test_bugzilla_16
    fp = self._open_file(os.path.join(ROOT, 'data', 'bugzilla_16.7z'), 'rb')
  File "tests/test_7zfiles.py", line 67, in _open_file
    fp = open(filename, mode)
IOError: [Errno 2] No such file or directory: '/tmp/portage/dev-python/pylzma-0.4.9/work/pylzma-0.4.9/tests/data/bugzilla_16.7z'

======================================================================
ERROR: test_bugzilla_4 (tests.test_7zfiles.Test7ZipFiles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_7zfiles.py", line 130, in test_bugzilla_4
    fp = self._open_file(os.path.join(ROOT, 'data', 'bugzilla_4.7z'), 'rb')
  File "tests/test_7zfiles.py", line 67, in _open_file
    fp = open(filename, mode)
IOError: [Errno 2] No such file or directory: '/tmp/portage/dev-python/pylzma-0.4.9/work/pylzma-0.4.9/tests/data/bugzilla_4.7z'

[...]

Feature: Add support for streaming ArchiveFiles

I have some large files that I need to extract, given their size and that pylzma reads the entire file into memory, can a stream API be provided for py7zlib.ArchiveFile objects.

This could be via a read_streamed(chunk_size=...) -> Iterator[bytes] function or allowing a size to be entered into read - read(amount=None) -> bytes. Allowing users to roll their own read_streamed:

def read_streamed(archive, chunk_size):
    while True:
        data = archive.read(chunk_size)
        if not data:
            break
        yield data

This would allow:

  • Users to read large archived files, without breaking the computer.
  • Remove the need for #11 as users can implement this themselves.

Do not automatically skip directory entries

Directories might be empty and required by whatever is contained in the archive, as such skipping them from being included in the list of files shouldn't be a default behavior.

More over, the __init__ of Archive7z is so large that extending the class to circumvent that behavior is practically not possible.

Relevant code:

pylzma/py7zlib.py

Lines 983 to 986 in ccb0e7c

# Skip all directory entries.
attributes = info.get('attributes', None)
if attributes and attributes & FILE_ATTRIBUTE_DIRECTORY != 0:
continue

missing definitions when fail to import pytz

When fail to import pytz, there's a code the defines a class named UTC.
However, when running the tests, some of them fail, since an existing singleton is expected.
In addition, the redefined UTC class should be callable

Pylzma cannot decrypt encrypted headers from 7z

If I include the -mhe switch to encrypt headers, I get an 'invalid block data error' from Archive7z.__init__() in py7zlib.py.

In what may be a side note, in class Header.__init__() in the line self.properties = ArchiveProperties(file), ArchiveProperties is not defined in py7zlib.py.

Are encrypted headers not supported?
Thanks again for all of your help.

Incorrect stream properties (TypeError) while trying to decompress

Hi,

I'm having an issue trying to decompress the following archive using pylzma.

This is on Windows 10 with pylzma 0.5.0.

Towards the end of the archive, I'm getting a TypeError exception in decompressor.decompress.

Traceback:

Traceback:
  File "C:\Users\Rémy Roy\Projects\CDDA-Game-Launcher\cddagl\ui.py", line 4966, in timeout
    f.write(extracting_element.read())
  File "C:\Users\RMYROY~1\VIRTUA~1\CDDA-G~3\lib\site-packages\py7zlib.py", line 632, in read
    data = getattr(self, decoder)(coder, data, level, num_coders)
  File "C:\Users\RMYROY~1\VIRTUA~1\CDDA-G~3\lib\site-packages\py7zlib.py", line 702, in _read_lzma
    return self._read_from_decompressor(coder, dec, input, level, num_coders, with_cache=True)
  File "C:\Users\RMYROY~1\VIRTUA~1\CDDA-G~3\lib\site-packages\py7zlib.py", line 686, in _read_from_decompressor
    data = decompressor.decompress(input, self._start+size)

This is the relevant code that does the decompression:

from py7zlib import Archive7z

class Dummy():

    def decompress():
        self.extracting_zipfile = open(self.downloaded_file, 'rb')
        self.extracting_archive = Archive7z(self.extracting_zipfile)
        self.extracting_infolist = self.extracting_archive.getmembers()

        self.extracting_index = 0

        while (self.extracting_index < len(self.extracting_infolist)):

            extracting_element = self.extracting_infolist[
                self.extracting_index]
            destination = os.path.join(self.extract_dir,
                *extracting_element.filename.split('/'))
            dest_dir = os.path.dirname(destination)
            if not os.path.isdir(dest_dir):
                os.makedirs(dest_dir)
            with open(destination, 'wb') as f:
                f.write(extracting_element.read())
            self.extracting_index += 1

The real code that does the decompression can be found here.

Here is more information about that archive:

file-info

This seems related to #56 and maybe to what @victor3rc was talking in #32.

UnsupportedCompressionMethodError

I am using osx (10.11) and python 2.7 and I used keka to compress the files into an archive. The default pip version (pylzma-0.4.8) gives the error

invalid type '\x19'

This is fixed in the version from github, I can read the filenames and sizes!
...but reading the data always results into an exception with

UnsupportedCompressionMethodError: '!'

I saw the warning about multithreading, so my questions are:
Are files compressed with keka, (i also tried betterzip) just not readable due to a missing compression method?
Do I have to disable multithreading (how?) as suggested when running setup.py install to get this to work?

My code snippet
Code

Feature: py7zlib: archive file mode and format API

It is better that py7zlib have an API to retrieve file modes.
I've been working for it and PR soon.

And I'd like to propose supporting Unix file mode (rwx)
p7zip on UNIX has an attribute trick to store a file mode, when FILE_ATTRIBUTE_UNIX_EXTENSION bit is set, then store a mode in high 16bit.

https://github.com/warexify/p7zip/blob/master/CPP/7zip/Archive/7z/7zUpdate.cpp#L882

 // p7zip uses the trick to store posix attributes in high 16 bits
      if (ui.Attrib & 0x8000)
      {
        unsigned st_mode = ui.Attrib >> 16;
// st_mode = 00111;

Here is a proposal of API design.

f = fp.getmember(name)
if f.is_executable():
    print("%s is an executable" % name)
if f.is_readonly():
    print("%s is a read only file" % name)

There are some design issue that how it should be in Windows platform.
A question is whether it checks unix attribute extension only on Unix/Linux/Mac, or always checks it on any platform.

py7zlib fails when decompressing lzma2 bcj2 7z file

py7zlib fails when attempting decompression test with an attached file testcase.tar.gz (please extract a 7z file from .tgz) , that is


Scanning the drive for archives:
1 file, 250 bytes (1 KiB)

Listing archive: test_lzma2bcj2.7z

--
Path = test_lzma2bcj2.7z
Type = 7z
Physical Size = 250
Headers Size = 190
Method = LZMA2:12 BCJ2
Solid = +
Blocks = 1

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2006-03-16 06:54:41 D....            0            0  test
2006-03-16 06:43:36 ....A           33           60  test/test2.txt
2006-03-16 06:43:48 ....A           33               test1.txt
------------------- ----- ------------ ------------  ------------------------
2006-03-16 06:54:41                 66           60  2 files, 1 folders

test code

    def test_lzma2bcj2(self):
        fp = self._open_file(os.path.join(ROOT, 'data', 'test_lzma2bcj2.7z'), 'rb')
        archive = Archive7z(fp)
        self._test_decode_all(archive)

result

Error
Traceback (most recent call last):
  File "/usr/lib/python3.5/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib/python3.5/unittest/case.py", line 600, in run
    testMethod()
  File "/home/miurahr/projects/pylzma/tests/test_7zfiles.py", line 111, in test_lzma2bcj2
    self._test_decode_all(archive)
  File "/home/miurahr/projects/pylzma/tests/test_7zfiles.py", line 105, in _test_decode_all
    self.assertTrue(cf.checkcrc(), 'crc failed for %s' % (filename))
  File "/home/miurahr/projects/pylzma/py7zlib.py", line 776, in checkcrc
    data = self.read()
  File "/home/miurahr/projects/pylzma/py7zlib.py", line 632, in read
    data = getattr(self, decoder)(coder, data, level, num_coders)
  File "/home/miurahr/projects/pylzma/py7zlib.py", line 702, in _read_lzma
    return self._read_from_decompressor(coder, dec, input, level, num_coders, with_cache=True)
  File "/home/miurahr/projects/pylzma/py7zlib.py", line 686, in _read_from_decompressor
    data = decompressor.decompress(input, self._start+size)
ValueError: data error during decompression

When observing call in py7zlib:632 data = getattr(self, decoder)(coder, data, level, num_coders) which called three times.
In second call, it returns data =b'This file is located in a folder.This file is located in the root.' which has already decoded and then 3rd call fails.

UnsupportedCompressionMethodError

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.5/site-packages/pylzma-v0.4.8_14_gaea5dev_r0-py3.5-linux-i686.egg/py7zlib.py", line 612, in read
decoder = self._decoders.get(method, None)
py7zlib.UnsupportedCompressionMethodError: b'!'

mingw32 build environment interprets PYLZMA_VERSION as float

Using WinPython 2.7.6.4 32 bit and mingw32 I get the following error:

c:\temp\pylzma-0.4.6>python setup.py build
running build
running build_py
creating build
creating build\lib.win32-2.7
copying py7zlib.py -> build\lib.win32-2.7
running build_ext
adding support for multithreaded compression
building 'pylzma' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\src
creating build\temp.win32-2.7\Release\src\pylzma
creating build\temp.win32-2.7\Release\src\sdk
creating build\temp.win32-2.7\Release\src\7zip
creating build\temp.win32-2.7\Release\src\7zip\c
creating build\temp.win32-2.7\Release\src\compat
C:\sstrahl\Programme\WinPython-32bit-2.7.6.4\python-2.7.6\..\tools\mingw32\bin\gcc.exe -mdll -O -Wall -DWITH_COMPAT=1 -DPYLZMA_VERSION="0.4.6" -DCOMPRESS_MF_MT=1 -Isrc/sdk -IC:\sstrahl\Programme\WinPython-32bit-2.7.6.4\python-2.7.6\include -IC:\sstrahl\Programme\WinPython-32bit-2.7.6.4\python-2.7.6\PC -c src/pylzma/pylzma.c -o build\temp.win32-2.7\Release\src\pylzma\pylzma.o
src/pylzma/pylzma.c: In function 'initpylzma':
src/pylzma/pylzma.c:284:50: error: too many decimal points in number
error: command 'gcc' failed with exit status 1

When I change line 284 in pylzma.c from

PyModule_AddStringConstant(m, "__version__", PYLZMA_VERSION);

to

PyModule_AddStringConstant(m, "__version__", "PYLZMA_VERSION");

he does compile successfully. I am not an expert on the different build environment and therefore not sure if adding the " might be the needed fix as this could result in other problems like some pre-processors doing then two string castings like ""0.4.6""?

TypeError when opening an archive with "Encrypt file names"

Like title says:

File 'up.py', line 565 in _arc
  try: z = Archive7z(f)
File 'python2.6/site-packages/pylzma-0.4.4-py2.6-linux-i686.egg/py7zlib.py', line 661 in __init__
  data += pylzma.decompress(props+tmp, maxlength=folder.unpacksizes[idx])
TypeError: Error while decompressing: 1

Archive made with win32 7-zip 9.20 (right click->add to archive GUI) and ticking "Encrypt file names" in the password section.

Does not support compressed 7z files without filename

Hello,

I created a 7z archive using this command:

[16:04:59] /tmp> echo Hello | 7zr a -si world.7z 

7-Zip (A) [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)

Updating archive world.7z

Compressing  [Content]      

Everything is Ok

When opening the file, I got this:

In [16]: a = py7zlib.Archive7z(open('/tmp/world.7z', 'rb'))                                                                 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-1de16307edc2> in <module>()
----> 1 a = py7zlib.Archive7z(open('/tmp/world.7z', 'rb'))

/usr/lib/python2.7/site-packages/pylzma-0.4.4-py2.7-linux-x86_64.egg/py7zlib.py in __init__(self, file, password)
    713 
    714         self.numfiles = len(self.files)
--> 715         self.filenames = map(lambda x: x.filename, self.files)
    716 
    717     # interface like TarFile

/usr/lib/python2.7/site-packages/pylzma-0.4.4-py2.7-linux-x86_64.egg/py7zlib.py in <lambda>(x)
    713 
    714         self.numfiles = len(self.files)
--> 715         self.filenames = map(lambda x: x.filename, self.files)
    716 
    717     # interface like TarFile

AttributeError: 'ArchiveFile' object has no attribute 'filename'

self.filenames should be ['world'] in this specific case.

(Great lib!! Thanks a lot : )

Installation failed

Hi,
i'm on windows and i have tried cygwin and git bash : i get the following error

 python ez_setup.py
Extracting in c:\users\larbi\appdata\local\temp\tmppe3m_t
Now working in c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1
Installing Setuptools
running install
running bdist_egg
running egg_info
writing dependency_links to setuptools.egg-info\dependency_links.txt
writing requirements to setuptools.egg-info\requires.txt
writing setuptools.egg-info\PKG-INFO
writing top-level names to setuptools.egg-info\top_level.txt
writing entry points to setuptools.egg-info\entry_points.txt
reading manifest file 'setuptools.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'setuptools.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build
creating build\lib
copying pkg_resources.py -> build\lib
copying easy_install.py -> build\lib
creating build\lib\setuptools
copying setuptools\archive_util.py -> build\lib\setuptools
copying setuptools\compat.py -> build\lib\setuptools
copying setuptools\depends.py -> build\lib\setuptools
copying setuptools\dist.py -> build\lib\setuptools
copying setuptools\extension.py -> build\lib\setuptools
copying setuptools\lib2to3_ex.py -> build\lib\setuptools
copying setuptools\package_index.py -> build\lib\setuptools
copying setuptools\py26compat.py -> build\lib\setuptools
copying setuptools\py27compat.py -> build\lib\setuptools
copying setuptools\py31compat.py -> build\lib\setuptools
copying setuptools\sandbox.py -> build\lib\setuptools
copying setuptools\script template (dev).py -> build\lib\setuptools
copying setuptools\script template.py -> build\lib\setuptools
copying setuptools\site-patch.py -> build\lib\setuptools
copying setuptools\ssl_support.py -> build\lib\setuptools
copying setuptools\svn_utils.py -> build\lib\setuptools
copying setuptools\version.py -> build\lib\setuptools
copying setuptools\__init__.py -> build\lib\setuptools
creating build\lib\_markerlib
copying _markerlib\markers.py -> build\lib\_markerlib
copying _markerlib\__init__.py -> build\lib\_markerlib
creating build\lib\setuptools\command
copying setuptools\command\alias.py -> build\lib\setuptools\command
copying setuptools\command\bdist_egg.py -> build\lib\setuptools\command
copying setuptools\command\bdist_rpm.py -> build\lib\setuptools\command
copying setuptools\command\bdist_wininst.py -> build\lib\setuptools\command
copying setuptools\command\build_ext.py -> build\lib\setuptools\command
copying setuptools\command\build_py.py -> build\lib\setuptools\command
copying setuptools\command\develop.py -> build\lib\setuptools\command
copying setuptools\command\easy_install.py -> build\lib\setuptools\command
copying setuptools\command\egg_info.py -> build\lib\setuptools\command
copying setuptools\command\install.py -> build\lib\setuptools\command
copying setuptools\command\install_egg_info.py -> build\lib\setuptools\command
copying setuptools\command\install_lib.py -> build\lib\setuptools\command
copying setuptools\command\install_scripts.py -> build\lib\setuptools\command
copying setuptools\command\register.py -> build\lib\setuptools\command
copying setuptools\command\rotate.py -> build\lib\setuptools\command
copying setuptools\command\saveopts.py -> build\lib\setuptools\command
copying setuptools\command\sdist.py -> build\lib\setuptools\command
copying setuptools\command\setopt.py -> build\lib\setuptools\command
copying setuptools\command\test.py -> build\lib\setuptools\command
copying setuptools\command\upload_docs.py -> build\lib\setuptools\command
copying setuptools\command\__init__.py -> build\lib\setuptools\command
creating build\lib\setuptools\tests
copying setuptools\tests\doctest.py -> build\lib\setuptools\tests
copying setuptools\tests\environment.py -> build\lib\setuptools\tests
copying setuptools\tests\py26compat.py -> build\lib\setuptools\tests
copying setuptools\tests\script-with-bom.py -> build\lib\setuptools\tests
copying setuptools\tests\server.py -> build\lib\setuptools\tests
copying setuptools\tests\test_bdist_egg.py -> build\lib\setuptools\tests
copying setuptools\tests\test_build_ext.py -> build\lib\setuptools\tests
copying setuptools\tests\test_develop.py -> build\lib\setuptools\tests
copying setuptools\tests\test_dist_info.py -> build\lib\setuptools\tests
copying setuptools\tests\test_easy_install.py -> build\lib\setuptools\tests
copying setuptools\tests\test_egg_info.py -> build\lib\setuptools\tests
copying setuptools\tests\test_markerlib.py -> build\lib\setuptools\tests
copying setuptools\tests\test_packageindex.py -> build\lib\setuptools\tests
copying setuptools\tests\test_resources.py -> build\lib\setuptools\tests
copying setuptools\tests\test_sandbox.py -> build\lib\setuptools\tests
copying setuptools\tests\test_sdist.py -> build\lib\setuptools\tests
copying setuptools\tests\test_svn.py -> build\lib\setuptools\tests
copying setuptools\tests\test_test.py -> build\lib\setuptools\tests
copying setuptools\tests\test_upload_docs.py -> build\lib\setuptools\tests
copying setuptools\tests\__init__.py -> build\lib\setuptools\tests
copying setuptools\cli-32.exe -> build\lib\setuptools
copying setuptools\cli-64.exe -> build\lib\setuptools
copying setuptools\cli-arm-32.exe -> build\lib\setuptools
copying setuptools\cli.exe -> build\lib\setuptools
copying setuptools\gui-32.exe -> build\lib\setuptools
copying setuptools\gui-64.exe -> build\lib\setuptools
copying setuptools\gui-arm-32.exe -> build\lib\setuptools
copying setuptools\gui.exe -> build\lib\setuptools
copying setuptools\command\launcher manifest.xml -> build\lib\setuptools\command
creating build\bdist.win32
creating build\bdist.win32\egg
copying build\lib\easy_install.py -> build\bdist.win32\egg
copying build\lib\pkg_resources.py -> build\bdist.win32\egg
creating build\bdist.win32\egg\setuptools
copying build\lib\setuptools\archive_util.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\cli-32.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\cli-64.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\cli-arm-32.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\cli.exe -> build\bdist.win32\egg\setuptools
creating build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\alias.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\bdist_egg.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\bdist_rpm.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\bdist_wininst.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\build_ext.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\build_py.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\develop.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\easy_install.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\egg_info.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\install.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\install_egg_info.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\install_lib.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\install_scripts.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\launcher manifest.xml -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\register.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\rotate.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\saveopts.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\sdist.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\setopt.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\test.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\upload_docs.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\command\__init__.py -> build\bdist.win32\egg\setuptools\command
copying build\lib\setuptools\compat.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\depends.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\dist.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\extension.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\gui-32.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\gui-64.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\gui-arm-32.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\gui.exe -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\lib2to3_ex.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\package_index.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\py26compat.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\py27compat.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\py31compat.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\sandbox.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\script template (dev).py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\script template.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\site-patch.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\ssl_support.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\svn_utils.py -> build\bdist.win32\egg\setuptools
creating build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\doctest.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\environment.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\py26compat.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\script-with-bom.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\server.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_bdist_egg.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_build_ext.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_develop.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_dist_info.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_easy_install.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_egg_info.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_markerlib.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_packageindex.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_resources.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_sandbox.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_sdist.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_svn.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_test.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\test_upload_docs.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\tests\__init__.py -> build\bdist.win32\egg\setuptools\tests
copying build\lib\setuptools\version.py -> build\bdist.win32\egg\setuptools
copying build\lib\setuptools\__init__.py -> build\bdist.win32\egg\setuptools
creating build\bdist.win32\egg\_markerlib
copying build\lib\_markerlib\markers.py -> build\bdist.win32\egg\_markerlib
copying build\lib\_markerlib\__init__.py -> build\bdist.win32\egg\_markerlib
byte-compiling build\bdist.win32\egg\easy_install.py to easy_install.pyc
byte-compiling build\bdist.win32\egg\pkg_resources.py to pkg_resources.pyc
byte-compiling build\bdist.win32\egg\setuptools\archive_util.py to archive_util.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\alias.py to alias.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\bdist_egg.py to bdist_egg.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\bdist_rpm.py to bdist_rpm.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\bdist_wininst.py to bdist_wininst.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\build_ext.py to build_ext.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\build_py.py to build_py.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\develop.py to develop.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\easy_install.py to easy_install.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\egg_info.py to egg_info.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\install.py to install.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\install_egg_info.py to install_egg_info.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\install_lib.py to install_lib.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\install_scripts.py to install_scripts.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\register.py to register.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\rotate.py to rotate.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\saveopts.py to saveopts.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\sdist.py to sdist.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\setopt.py to setopt.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\test.py to test.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\upload_docs.py to upload_docs.pyc
byte-compiling build\bdist.win32\egg\setuptools\command\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\setuptools\compat.py to compat.pyc
byte-compiling build\bdist.win32\egg\setuptools\depends.py to depends.pyc
byte-compiling build\bdist.win32\egg\setuptools\dist.py to dist.pyc
byte-compiling build\bdist.win32\egg\setuptools\extension.py to extension.pyc
byte-compiling build\bdist.win32\egg\setuptools\lib2to3_ex.py to lib2to3_ex.pyc
byte-compiling build\bdist.win32\egg\setuptools\package_index.py to package_index.pyc
byte-compiling build\bdist.win32\egg\setuptools\py26compat.py to py26compat.pyc
byte-compiling build\bdist.win32\egg\setuptools\py27compat.py to py27compat.pyc
byte-compiling build\bdist.win32\egg\setuptools\py31compat.py to py31compat.pyc
byte-compiling build\bdist.win32\egg\setuptools\sandbox.py to sandbox.pyc
byte-compiling build\bdist.win32\egg\setuptools\script template (dev).py to script template (dev).pyc
byte-compiling build\bdist.win32\egg\setuptools\script template.py to script template.pyc
byte-compiling build\bdist.win32\egg\setuptools\site-patch.py to site-patch.pyc
byte-compiling build\bdist.win32\egg\setuptools\ssl_support.py to ssl_support.pyc
byte-compiling build\bdist.win32\egg\setuptools\svn_utils.py to svn_utils.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\doctest.py to doctest.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\environment.py to environment.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\py26compat.py to py26compat.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\script-with-bom.py to script-with-bom.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\server.py to server.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_bdist_egg.py to test_bdist_egg.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_build_ext.py to test_build_ext.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_develop.py to test_develop.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_dist_info.py to test_dist_info.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_easy_install.py to test_easy_install.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_egg_info.py to test_egg_info.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_markerlib.py to test_markerlib.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_packageindex.py to test_packageindex.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_resources.py to test_resources.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_sandbox.py to test_sandbox.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_sdist.py to test_sdist.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_svn.py to test_svn.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_test.py to test_test.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\test_upload_docs.py to test_upload_docs.pyc
byte-compiling build\bdist.win32\egg\setuptools\tests\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\setuptools\version.py to version.pyc
byte-compiling build\bdist.win32\egg\setuptools\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\_markerlib\markers.py to markers.pyc
byte-compiling build\bdist.win32\egg\_markerlib\__init__.py to __init__.pyc
creating build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\entry_points.txt -> build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
copying setuptools.egg-info\zip-safe -> build\bdist.win32\egg\EGG-INFO
creating dist
creating 'dist\setuptools-3.1-py2.7.egg' and adding 'build\bdist.win32\egg' to it
removing 'build\bdist.win32\egg' (and everything under it)
Processing setuptools-3.1-py2.7.egg
Removing c:\python27\lib\site-packages\setuptools-3.1-py2.7.egg
Copying setuptools-3.1-py2.7.egg to c:\python27\lib\site-packages
setuptools 3.1 is already the active version in easy-install.pth
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install.exe.manifest script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts
Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-3.1-py2.7.egg
Processing dependencies for setuptools==3.1
Traceback (most recent call last):
  File "setup.py", line 203, in <module>
    dist = setuptools.setup(**setup_params)
  File "C:\Python27\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\setuptools\command\install.py", line 74, in run
    self.do_egg_install()
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\setuptools\command\install.py", line 97, in do_egg_install
    cmd.run()
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\setuptools\command\easy_install.py", line 358, in run
    self.easy_install(spec, not self.no_deps)
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\setuptools\command\easy_install.py", line 574, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\setuptools\command\easy_install.py", line 625, in install_item
    self.process_distribution(spec, dist, deps)
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\setuptools\command\easy_install.py", line 671, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 633, in resolve
    requirements.extend(dist.requires(req.extras)[::-1])
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 2291, in requires
    dm = self._dep_map
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 2277, in _dep_map
    for extra,reqs in split_sections(self._get_metadata(name)):
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 2715, in split_sections
    for line in yield_lines(s):
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 1989, in yield_lines
    for ss in strs:
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 2305, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 1369, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 1361, in get_metadata
    return self._get(self._fn(self.egg_info,name))
  File "c:\users\larbi\appdata\local\temp\tmppe3m_t\setuptools-3.1\pkg_resources.py", line 1425, in _get
    return self.loader.get_data(path)
zipimport.ZipImportError: bad local file header in c:\python27\lib\site-packages\setuptools-3.1-py2.7.egg
Something went wrong during the installation.
See the error message above.

Installation fails via `pip3` on python 3.

From reading your blog, apparently there is python 3 support /somewhere/, but it's not present in the egg available via pip.

I installed the package fine by manually git-cloning and running setup.py, so it looks like the eggs on Pypy just need to be updated. They appear to have been last touched in 2011, so three years ago.

List index out of range creating an Archive7z object with a specific 7z file

When creating an Archive7z object with a .7z file pointer, an IndexError is raised:

    self.archive = py7zlib.Archive7z( fp )
  File "C:\Python27\lib\site-packages\pylzma-0.4.4-py2.7-win32.egg\py7zlib.py",
line 698, in __init__
    folder = folders[fidx]
IndexError: list index out of range

This can be reproduced with the Mplayer for Windows .7z file from http://downloads.sourceforge.net/project/mplayer-win32/MPlayer%20and%20MEncoder/revision%2034401/MPlayer-p4-svn-34401.7z. Other archive applications don't seem to have a problem parsing the same file.

Trying to catch the specific IndexError inside py7zlib and breaking or continuing results in a ValueError (data error occurred during decompression).

As I'm not familiar with the 7z encoding/compression scheme, it's quite possible that the file in question is malformed. In this case, py7zlib should probably raise a more descriptive/friendly error.

Problem decompressing encrypted 7z archive?

I think I may have found a problem when decompressing encrypted 7z archives. When trying to decompress a file I just did, I get the following error:

Traceback (most recent call last):
  File "test2.py", line 5, in <module>
    archive = Archive7z(f, password='abc')
  File "/usr/local/lib/python3.4/dist-packages/py7zlib.py", line 796, in __init__
    raise FormatError('invalid block data')
py7zlib.FormatError: invalid block data

The code I used for this was:

from py7zlib import Archive7z

with open('./abc.7z', 'rb') as f:
    archive = Archive7z(f, password='abc')

I was using python3.4 on Debian Jessie, and I installed pylzma trough python pip. The 7z archive was created from the command line with p7zip.

I attached the archive as a .zip because GitHub didn't accepted .7z files. abc.zip

Thanks for the help!

pylzma instalation failed on windows 7 os

pylzma instalation failed on windows 7 os

Error information i got on my terminal

C:\Users\vkosuri\Dropbox\projects\archivelibrary-master>pip install pylzma
Collecting pylzma
C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
:90: InsecurePlatformWarning: A true SSLContext object is not available. This pr
events urllib3 from configuring SSL appropriately and may cause certain SSL conn
ections to fail. For more information, see https://urllib3.readthedocs.org/en/la
test/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading pylzma-0.4.8.tar.gz (115kB)
    100% |################################| 118kB 225kB/s
Installing collected packages: pylzma
  Running setup.py install for pylzma
    Complete output from command C:\Python27\python.exe -c "import setuptools, t
okenize;__file__='c:\\users\\vkosuri\\appdata\\local\\temp\\pip-build-teeh7v\\py
lzma\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().re
place('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\vkosuri\appda
ta\local\temp\pip-7q_tjn-record\install-record.txt --single-version-externally-m
anaged --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    copying py7zlib.py -> build\lib.win-amd64-2.7
    running build_ext
    adding support for multithreaded compression
    building 'pylzma' extension
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\vkosuri\appdata\local\temp\pip-build-teeh7v\pylzma\setup.py
", line 192, in <module>
        zip_safe = False,
      File "C:\Python27\lib\distutils\core.py", line 151, in setup
        dist.run_commands()
      File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Python27\lib\site-packages\setuptools\command\install.py", line 6
1, in run
        return orig.install.run(self)
      File "C:\Python27\lib\distutils\command\install.py", line 563, in run
        self.run_command('build')
      File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Python27\lib\distutils\command\build.py", line 127, in run
        self.run_command(cmd_name)
      File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Python27\lib\distutils\command\build_ext.py", line 337, in run
        self.build_extensions()
      File "C:\Python27\lib\distutils\command\build_ext.py", line 446, in build_
extensions
        self.build_extension(ext)
      File "c:\users\vkosuri\appdata\local\temp\pip-build-teeh7v\pylzma\setup.py
", line 125, in build_extension
        _build_ext.build_extension(self, ext)
      File "C:\Python27\lib\distutils\command\build_ext.py", line 496, in build_
extension
        depends=ext.depends)
      File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
        self.initialize()
      File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize

        vc_env = query_vcvarsall(VERSION, plat_spec)
      File "C:\Python27\lib\site-packages\setuptools\msvc9_support.py", line 52,
 in query_vcvarsall
        return unpatched['query_vcvarsall'](version, *args, **kwargs)
      File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcva
rsall
        raise ValueError(str(list(result.keys())))
    ValueError: [u'path']

    ----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\us
ers\\vkosuri\\appdata\\local\\temp\\pip-build-teeh7v\\pylzma\\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record c:\users\vkosuri\appdata\local\temp\pip-7q_tjn
-record\install-record.txt --single-version-externally-managed --compile" failed
 with error code 1 in c:\users\vkosuri\appdata\local\temp\pip-build-teeh7v\pylzm
a
C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
:90: InsecurePlatformWarning: A true SSLContext object is not available. This pr
events urllib3 from configuring SSL appropriately and may cause certain SSL conn
ections to fail. For more information, see https://urllib3.readthedocs.org/en/la
test/security.html#insecureplatformwarning.
  InsecurePlatformWarning

Decompressing encrypted 7z file?

Hello,
I installed pylzma over Debian jessie by doing "pip install pylzma", and it seems that it is faling to decompress an encrypted 7z file that I just created.


import pylzma, os
from py7zlib import Archive7z

with open('./1.7z', 'rb') as f:
archive = Archive7z(f, password='abc') # the indentation over github is wrong


Traceback (most recent call last):
File "test.py", line 11, in
archive = Archive7z(f, password='abc')
File "/usr/local/lib/python2.7/dist-packages/py7zlib.py", line 742, in init
data += pylzma.decompress(props+tmp, maxlength=folder.unpacksizes[idx])
TypeError: Error while decompressing: 1


Is this a bug, or I'm doing something wrong?

Can't decompress the lzma1900.7z file using py7zlib.Archive7z

This is my code:

import sys

if (sys.version_info > (3, 0)):
    import urllib.request as urllib
else:
    import urllib2 as urllib

import os
import py7zlib

def download(url, output):
    data = urllib.urlopen(url)
    with open(output, "wb") as f:
        f.write(data.read())

def check_dir(dir):
    if (os.path.isdir(dir)):
        pass
    else:
        os.makedirs(dir)

def dec_7z(file_name, output):
    with open(file_name, 'rb') as f:
        archive = py7zlib.Archive7z(f)
        for name in archive.getnames():
            print(name)
            outfilename = os.path.join(output, name)
            outdir = os.path.dirname(outfilename)
            check_dir(outdir)
            with open(outfilename, 'wb') as outfile:
                outfile.write(archive.getmember(name).read())

url = "https://sourceforge.net/projects/sevenzip/files/LZMA%20SDK/lzma1900.7z/download"
file_name = "lzma1900.7z"

download(url, file_name)
dec_7z(file_name, "7z")

Run it, but get this:

...
Java/SevenZip/Compression/RangeCoder/Decoder.java
Java/SevenZip/Compression/RangeCoder/Encoder.java
Java/SevenZip/CRC.java
Java/SevenZip/ICodeProgress.java
Java/SevenZip/LzmaAlone.java
Traceback (most recent call last):
  File "down7z.py", line 37, in <module>
    dec_7z(file_name, "7z")
  File "down7z.py", line 31, in dec_7z
    outfile.write(archive.getmember(name).read())
  File "C:\ProgramData\Anaconda3\envs\py27\lib\site-packages\py7zlib.py", line 6
32, in read
    data = getattr(self, decoder)(coder, data, level, num_coders)
  File "C:\ProgramData\Anaconda3\envs\py27\lib\site-packages\py7zlib.py", line 7
02, in _read_lzma
    return self._read_from_decompressor(coder, dec, input, level, num_coders, wi
th_cache=True)
  File "C:\ProgramData\Anaconda3\envs\py27\lib\site-packages\py7zlib.py", line 6
70, in _read_from_decompressor
    tmp = decompressor.decompress(data)
ValueError: data error during decompression

And my env:

>uname
MINGW32_NT-6.1

>pip search pylzma
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Ple
ase upgrade your Python as Python 2.7 won't be maintained after that date. A fut
ure version of pip will drop support for Python 2.7.
pylzma (0.5.0)  - Python bindings for the LZMA library by Igor Pavlov.
  INSTALLED: 0.5.0 (latest)

Thanks!

Bugs Report : Incorrect stream properties

Bug 1 : TypeError: Incorrect stream properties

Log:
Decompress "songs/140097 Camellia - Bangin' Burst/BG.jpg" Successfully.
Decompress "songs/140097 Camellia - Bangin' Burst/Camellia - Bangin' Burst (Spy) [EXHAUST Lv.16].osu" Successfully.
Decompress "songs/140097 Camellia - Bangin' Burst/Camellia - Bangin' Burst (Spy) [KK's ADVANCED Lv.14].osu" Successfully.
Decompress "songs/140097 Camellia - Bangin' Burst/Camellia - Bangin' Burst (Spy) [S.Star's NOVICE Lv.9].osu" Successfully.
Decompress "songs/140097 Camellia - Bangin' Burst/Camellia - Bangin' Burst (Spy) [victorica's Extra Lv.15].osu" Successfully.
Decompress "songs/140097 Camellia - Bangin' Burst/Camellia - Bangin' Burst [EXH].mp3" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/bgmama.jpg" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/High Speed Music Team Sharpnel - M.A.M.A. (arcwinolivirus) [ExTra].osu" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/High Speed Music Team Sharpnel - M.A.M.A. (arcwinolivirus) [HD].osu" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/High Speed Music Team Sharpnel - M.A.M.A. (arcwinolivirus) [MX].osu" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/High Speed Music Team Sharpnel - M.A.M.A. (arcwinolivirus) [NM].osu" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/High Speed Music Team Sharpnel - M.A.M.A. (arcwinolivirus) [SHD].osu" Successfully.
Decompress "songs/176446 High Speed Music Team Sharpnel - MAMA/M.A.M.A.mp3" Successfully.
Decompress "songs/232126 Hatsune Miku - Lagamine Rin - The Lost Lovers/Hatsune Miku - Lagamine Rin - The Lost Lovers (OmariYumi) [Dead Line Carzy Mania 4K].jpg" Successfully.
Decompress "songs/232126 Hatsune Miku - Lagamine Rin - The Lost Lovers/Hatsune Miku - Lagamine Rin - The Lost Lovers (OmariYumi) [Dead Line Carzy Mania 4K].osu" Successfully.
Decompress "songs/232126 Hatsune Miku - Lagamine Rin - The Lost Lovers/The Lost Lovers.mp3" Successfully.
Decompress "songs/258121 Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix/46782672_p0.jpg" Successfully.
Decompress "songs/258121 Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix/Shanghai Kouchakan ~ Chinese Tea Orchid Remix.mp3" Successfully.
Decompress "songs/258121 Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix/Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix (SanadaYukimura) [ADVANCED].osu" Successfully.
Decompress "songs/258121 Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix/Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix (SanadaYukimura) [EXHAUST].osu" Successfully.
Decompress "songs/258121 Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix/Yooh - Shanghai Kouchakan ~ Chinese Tea Orchid Remix (SanadaYukimura) [NOVICE].osu" Successfully.
Decompress "songs/286738 Various Artists - 4K 2nd Dan/4K 2nd Dan.mp3" Successfully.
Decompress "songs/286738 Various Artists - 4K 2nd Dan/Dan2.jpg" Successfully.
Decompress "songs/286738 Various Artists - 4K 2nd Dan/Various Artists - 4K 2nd Dan (PortalLife) [2].osu" Successfully.
Decompress "songs/392965 IOSYS - Endless Tewi-ma Park/IOSYS - Endless Tewi-ma Park (arcwinolivirus) [Arcwin Lost Tewicated].osu" Successfully.
Decompress "songs/392965 IOSYS - Endless Tewi-ma Park/IOSYS - Endless Tewi-ma Park (arcwinolivirus) [Arcwin Tewicated].osu" Successfully.
Decompress "songs/392965 IOSYS - Endless Tewi-ma Park/losttewiBG.jpg" Successfully.
Decompress "songs/392965 IOSYS - Endless Tewi-ma Park/Touhou - Iosys Tewis Mapaku To Endless.mp3" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/audio.mp3" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/Colorful Sounds Port - ETERNAL DRAIN (Wh1teh) [Another].osu" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/Colorful Sounds Port - ETERNAL DRAIN (Wh1teh) [Beginner].osu" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/Colorful Sounds Port - ETERNAL DRAIN (Wh1teh) [Black Another].osu" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/Colorful Sounds Port - ETERNAL DRAIN (Wh1teh) [Eternal].osu" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/Colorful Sounds Port - ETERNAL DRAIN (Wh1teh) [Hyper].osu" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/Colorful Sounds Port - ETERNAL DRAIN (Wh1teh) [Normal].osu" Successfully.
Decompress "songs/468353 Colorful Sounds Port - ETERNAL DRAIN/eternal_title_v2.jpg" Successfully.
Decompress "songs/548193 Various Artists - 4k 3rd dan v2/dan3.png" Successfully.
Decompress "songs/548193 Various Artists - 4k 3rd dan v2/Dan_3.jpg" Successfully.
Decompress "songs/548193 Various Artists - 4k 3rd dan v2/Thirddan.mp3" Successfully.
Decompress "songs/548193 Various Artists - 4k 3rd dan v2/Various Artists - 4k 3rd dan v2 (Yuudachi-kun) [d-3].osu" Successfully.
Decompress "songs/548650 Various Artists - 4k 2nd dan v2/dan2.png" Successfully.
Decompress "songs/548650 Various Artists - 4k 2nd dan v2/Dan_2.jpg" Successfully.
Decompress "songs/548650 Various Artists - 4k 2nd dan v2/seconddan.mp3" Successfully.
Decompress "songs/548650 Various Artists - 4k 2nd dan v2/Various Artists - 4k 2nd dan v2 (Yuudachi-kun) [d-2].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/background.jpg" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/M-A 1.1x.mp3" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/M-A 1.2x.mp3" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/M-A 1.3x.mp3" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/M-A 1.4x.mp3" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/M-A.mp3" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Expert Lv.15 1.1x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Expert Lv.15 1.2x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Expert Lv.15 1.3x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Expert Lv.15 1.4x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Expert Lv.15].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Hard Lv.14 1.1x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Hard Lv.14 1.2x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Hard Lv.14 1.3x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Hard Lv.14 1.4x].osu" Successfully.
Decompress "songs/565125 Team Musical Masterpiece - M-A/Team Musical Masterpiece - M-A (Night Bunny 7) [IcyWorld's Hard Lv.14].osu" Successfully.
Decompress "songs/746792 Chaoz Fantasy - Chaoz Fantasy/Chaoz Fantasy - Chaoz Fantasy (StarDust_4) [Insane].osu" Successfully.
Decompress "songs/746792 Chaoz Fantasy - Chaoz Fantasy/keluodiya.mp3" Successfully.
Decompress "songs/746792 Chaoz Fantasy - Chaoz Fantasy/keluodiya.png" Successfully.
Traceback (most recent call last):
File ".\mainPrg.py", line 8, in
archiveClass.decompressArchive(archiveClass.openArchive("songs.7z"))
File "C:\Users\Vinyl\Desktop\py7ztest\archive7zip.py", line 33, in decompressArchive
if (not cf.checkcrc()):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 776, in checkcrc
data = self.read()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 632, in read
data = getattr(self, decoder)(coder, data, level, num_coders)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 702, in _read_lzma
return self._read_from_decompressor(coder, dec, input, level, num_coders, with_cache=True)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 686, in _read_from_decompressor
data = decompressor.decompress(input, self._start+size)
TypeError: Incorrect stream properties

Bug 2 : ValueError: data error during decompression

Decompress "ProcessMonitor/Eula.txt" Successfully.
Decompress "ProcessMonitor/procmon.chm" Successfully.
Traceback (most recent call last):
File ".\mainPrg.py", line 8, in
archiveClass.decompressArchive(archiveClass.openArchive("ProcessMonitor.7z"))
File "C:\Users\Vinyl\Desktop\py7ztest\archive7zip.py", line 33, in decompressArchive
if (not cf.checkcrc()):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 776, in checkcrc
data = self.read()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 632, in read
data = getattr(self, decoder)(coder, data, level, num_coders)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 702, in _read_lzma
return self._read_from_decompressor(coder, dec, input, level, num_coders, with_cache=True)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\py7zlib.py", line 686, in _read_from_decompressor
data = decompressor.decompress(input, self._start+size)
ValueError: data error during decompression

Test Archive File :
https://mega.nz/#!2lAjgQyZ!Eir74Z_eSS68tz53l9Y-enr0mTOzMSFVZXbfU81CIBE

segmentation fault on tab expansion on decompressobj_compat instance

All i need is to decompress lzma with uncompressed size in header and without EOS marker,
according to specification

In [1]: import pylzma

In [2]: dec = pylzma.decompressobj_compat()

In [3]: dec.decompress
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-4355ac622de5> in <module>()
----> 1 dec.decompress

AttributeError: 'LZMACompatDecompress' object has no attribute 'decompress'

In [4]: dec.Segmentation fault

Actually i`ve achieved it by manually parsing header:

import pylzma
import struct

f = open(archive, 'r')
header = f.read(13)
size = struct.unpack('=BIQ', header)[-1]

dec = pylzma.decompressobj(maxlength=size)
dec.decompress(header[:5])

assert 13 == f.tell()
s = dec.decompress(f.read()) # this should be optimized for large files

By the way, i don`t understand compat part of source. Also its very unusual to get Segfault in python shell :)

py7zlib fails with `IndexError: list index out of range` when opening specific 7z archive

py7zlib caught out of range error when opening specific file.

how to reproduce

Run snippet following

#!/usr/bin/env python

import py7zlib
import requests

archive = 'testfile.7z'
url = 'https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_597/qt.qt5.597.gcc_64/5.9.7-0-201810181452qtxmlpatterns-Linux-RHEL_7_4-GCC-Linux-RHEL_7_4-X86_64.7z'
r = requests.get(url, stream=True)
with open(archive, 'wb') as fd:
    for chunk in r.iter_content(chunk_size=512):
        fd.write(chunk)
f = py7zlib.Archive7z(open(archive, 'rb'))

Traceback

 Traceback (most recent call last):
  File "./repro.py", line 13, in <module>
    f = py7zlib.Archive7z(open(archive, 'rb'))
  File "/home/miurahr/projects/qli-installer/venv/lib/python3.5/site-packages/py7zlib.py", line 884, n __init__
    folder = folders[fidx]
IndexError: list index out of range

Version

pylzma-0.5.0.post0`

related issues

#9

Environment

Linux Mint 18.3 (Sylvia), python 3.5.2

Most recent commit fails unittest on Windows

Using windows 7 x64 and Python 32bit 2.7:
and commit: cc2bfaf

During unittest test_7zfiles.py.Test7ipFiles.test_encrypted_names_password
line 164 "archive = Archive7z(fp, password='secret')" fails without raising an exception in:
py7zlib.ArchiveFile._read_7z_aes256_sha256
at line 698 "result = cipher.decrypt(input)"

Using debugger this line fails without raising an exception and execution halts.

Getting version information from git describe

I had an issue using Jenkis-CI with pylzma from PyPI
Jenkins creates a virtualenv inside the workspace of the build (which is a git repo actually), so git describe returns a nonsense value.
version.py claims that the version of pylzma is "jenkins-somestuff" instead of 0.4.4 and the pip install for the requirements fails

Invalid type while parsing encrypted 7z file

Hello! I'm trying to use py7zlib to read from an encrypted 7z file.

Here is my code:

import py7zlib

fp = open('12313213.7z', 'rb')
archive = py7zlib.Archive7z(fp)

Here is the sample file (the zip archive contains the target 7z file, becasue GitHub does not allow to attach 7z's, I'm not trying to open zip file with pylzma, of course):
12313213.zip

It produces the following error:

Traceback (most recent call last):
  File "/venv/main.py", line 4, in <module>
    archive = py7zlib.Archive7z(fp)
  File "\venv\lib\site-packages\py7zlib.py", line 811, in __init__
    self.header = Header(buffer)
  File "\venv\lib\site-packages\py7zlib.py", line 547, in __init__
    self.files = FilesInfo(file)
  File "\venv\lib\site-packages\py7zlib.py", line 527, in __init__
    raise FormatError('invalid type %r' % (typ))
py7zlib.FormatError: invalid type b'\x19'

I'm using Windows 10 x64 (Python is x32), Python 3.4.

py7zlib: _read64Bit() returns None when reading bytes start with 0xff

When running following test code, _read64Bit(file) returns None.

import io
import py7zlib

#  read  bytes start with b'\xff'
buf = io.BytesIO(b'\xff\xcd\xab\x90\x78\x56\x34\x12\xcf')
val = py7zlib.Base()._read64Bit(buf)
if val is None:
     raise

This is just a validation code for a border condition.

compilation error because of incorrect PYLZMA_VERSION stringification

pylzma-0.4.6

The macro -DPYLZMA_VERSION="0.4.6" is passed to compiler.
In pylzma-0.4.6\src\pylzma\pylzma.c line:284:

    PyModule_AddStringConstant(m, "__version__", PYLZMA_VERSION);

Preprocessor replace this string to:

    PyModule_AddStringConstant(m, "__version__", 0.4.6);

But we want string, like this:

    PyModule_AddStringConstant(m, "__version__", "0.4.6");

To do what we want:

  1. Add macro STRINGIFY
#define STRINGIFY_(x_) #x_
#define STRINGIFY(x_) STRINGIFY_(x_)
  1. Use macro STRINGIFY
    PyModule_AddStringConstant(m, "__version__", STRINGIFY(PYLZMA_VERSION));
  1. Edit setup.py line:146,
    replace:
if version:
    macros.append(('PYLZMA_VERSION', '"'+version+'"'))

to:

    macros.append(('PYLZMA_VERSION', version))

Build log with MSVC:

D:\TMP\pylzma-0.4.6>python setup.py build
running build
running build_py
running build_ext
adding support for multithreaded compression
building 'pylzma' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DWITH_COMPAT=1 -DPYLZMA_VERSION="0.4.6" -DCOMPRESS_MF_MT=1 -Isrc/sdk -IC:\Python27_x86_32\include -IC:\Python27_x86_32\PC /Tcsrc/pylzma/pylzma.c /Fobuild\temp.win32-2.7\Release\src/pylzma/pylzma.obj /MT
cl : Command line warning D9025 : overriding '/MD' with '/MT'
pylzma.c
src/pylzma/pylzma.c(284) : error C2440: 'function' : cannot convert from 'double' to 'const char *'
src/pylzma/pylzma.c(284) : warning C4024: 'PyModule_AddStringConstant' : different types for formal and actual parameter 3
src/pylzma/pylzma.c(284) : error C2143: syntax error : missing ')' before 'constant'
src/pylzma/pylzma.c(284) : error C2059: syntax error : ')'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\BIN\\cl.exe' failed with exit status 2

Build log with MinGW:

D:\TMP\pylzma-0.4.6>python setup.py build
running build
running build_py
running build_ext
adding support for multithreaded compression
building 'pylzma' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -DWITH_COMPAT=1 -DPYLZMA_VERSION="0.4.6" -DCOMPRESS_MF_MT=1 -Isrc/sdk -IC:\Python27_x86_32\include -IC:\Python27_x86_32\PC -c src/pylzma/pylzma.c -o build\temp.win32-2.7\Release\src\pylzma\pylzma.o
src/pylzma/pylzma.c: In function 'initpylzma':
:0:16: error: too many decimal points in number
src/pylzma/pylzma.c:284:50: note: in expansion of macro 'PYLZMA_VERSION'
     PyModule_AddStringConstant(m, "__version__", PYLZMA_VERSION);
                                                  ^
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

Unpacking AES-256 encrypted zip files in memory using pylzma

Hi,

I am using the ZipFile module from the Python zipfile package to read in and unpack zip archives into memory:

import zipfile
zfile = zipfile.ZipFile(filehandle, 'r', compression=zipfile.ZIP_LZMA)
zfile.setpassword(password)

However, this does not work with AES-256 encryption (a known issue). Is it possible to achieve this using pylzma?

Thanks,
Ron

kDummy not handled - cannot open file created with p7zip Version 9.38.1

Full info about version: p7zip Version 9.38.1 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs,ASM)

The archive created with this version of p7zip cannot be opened by this lib because it lacks handling of Dummy parameter. The error I've received is:

FormatError: invalid type b'\x19'

from:
in ()
----> 1 archive = py7zlib.Archive7z(fp)

/usr/lib/python3.5/site-packages/py7zlib.py in __init__(self, file, password)
    809             return
    810 
--> 811         self.header = Header(buffer)
    812         files = self.header.files
    813         folders = self.header.main_streams.unpackinfo.folders

/usr/lib/python3.5/site-packages/py7zlib.py in __init__(self, file)
    545 
    546         if id == PROPERTY_FILES_INFO:
--> 547             self.files = FilesInfo(file)
    548             id = file.read(1)
    549 

/usr/lib/python3.5/site-packages/py7zlib.py in __init__(self, file)
    525                         f['attributes'] = None
    526             else:
--> 527                 raise FormatError('invalid type %r' % (typ))
    528 

From spec please see:

0x17 = kEncodedHeader

0x18 = kStartPos
0x19 = kDummy

There are 2 more properties in spec that are not handled by this library. I cannot see what is kStartPos for by I may assume that kDummy should do just nothing.

Decompressing large .7z files (> 4GiB) causes Python to raise MemoryError exception

Decompressing large .7z files (> 4GiB) causes Python to raise MemoryError exception:

for name in self.archive.getnames():
    out_filename = os.path.join(path, name)
    out_dir = os.path.dirname(out_filename)
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)
        with open(out_filename, 'wb') as out_file:
            out_file.write(self.archive.getmember(name).read())

Slow performance

Hi- I've been using pylzma to handle large(ish) 7z files ranging from 50MB-1.0GB compressed. I am trying to access individual files from the archive, one at a time, and I noticed that performance can be highly variable, and is very slow in comparison to ZipFile.

Below I compared performance for two archives containing the same files (I created the ZIP by extracting the 7z file and recompressing it with zip):

http://nbviewer.jupyter.org/github/bkuczenski/lca-tools/blob/master/doc/7z%20profiling.ipynb

On the one hand, the ZIP file is almost 6x as large as the 7Z file; on the other hand, 7z access seems 10x-100x slower.

My question: is there a way for me to improve the performance of py7zlib? is there a better way to use the archive to reference single files? Or is there a technical limitation that prevents this?

n.b. the performance is no different if I keep the archive open between successive retrievals. It is consistent for the same file over multiple trials (some are fast, others are slow- in this case all the files are about the same size so that's not the issue).

Thanks for any feedback.

Data error during extraction

Error when running example:

Traceback (most recent call last):
  File "E:\Python\7ztest.py", line 38, in <module>
    sevenZfile.extractall('.')
  File "E:\Python\7ztest.py", line 33, in extractall
    outfile.write(self.archive.getmember(name).read())
  File "E:\Python\py7zlib.py", line 632, in read
    data = getattr(self, decoder)(coder, data, level, num_coders)
  File "E:\Python\py7zlib.py", line 717, in _read_lzma2
    return self._read_from_decompressor(coder, dec, input, level, num_coders, with_cache=True)
  File "E:\Python\py7zlib.py", line 688, in _read_from_decompressor
    data = decompressor.decompress(input)
ValueError: data error during decompression

Source

import py7zlib
import os

class SevenZFile(object):
    @classmethod
    def is_7zfile(cls, filepath):
        '''
        Class method: determine if file path points to a valid 7z archive.
        '''
        is7z = False
        fp = None
        try:
            fp = open(filepath, 'rb')
            archive = py7zlib.Archive7z(fp)
            n = len(archive.getnames())
            is7z = True
        finally:
            if fp:
                fp.close()
        return is7z

    def __init__(self, filepath):
        fp = open(filepath, 'rb')
        self.archive = py7zlib.Archive7z(fp)

    def extractall(self, path):
        for name in self.archive.getnames():
            outfilename = os.path.join(path, name)
            outdir = os.path.dirname(outfilename)
            if not os.path.exists(outdir):
                os.makedirs(outdir)
            outfile = open(outfilename, 'wb')
            outfile.write(self.archive.getmember(name).read())
            outfile.close()
			
if SevenZFile.is_7zfile('DP_LAN_Realtek-XP_18000.7z'):
    sevenZfile = SevenZFile('DP_LAN_Realtek-XP_18000.7z')
    sevenZfile.extractall('.')

build fails on windows 7 x64 using 32 bit python 2.7 and MSVS 9.0

using latest code from master, setup.py build fails as follows:

src/pylzma/pylzma.c(284) : error C2065: 'None' : undeclared identifier
src/pylzma/pylzma.c(284) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'
src/pylzma/pylzma.c(284) : warning C4024: 'PyModule_AddStringConstant' : different types for formal and actual parameter 3
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

Any thoughts? Thanks for your work on this.

Py7zLib Decompress Encrypted File Error

7Z Archive : test.7z
Compress Software : BandiZip 6.14,build 25403,2018-06-19,x64
Runtime : Python 3.6.6 on Win32
OS : Windows 10 x64 build 1803
Decompress the archive without password encrypt,works fine,all file successfully decompressed,
But when encrypt the archive with password "1234",py7zlib given the traceback:

Traceback (most recent call last):
File ".\mainPrg.py", line 8, in
archiveClass.decompressArchive(archiveClass.openArchive("test.7z","1234"))
File "C:\Users\Vinyl\Desktop\py7ztest\archive7zip.py", line 33, in decompressArchive
if (not cf.checkcrc()):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pylzma-0.0.0.dev0-py3.6-win32.egg\py7zlib.py", line 780, in checkcrc
data = self.read()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pylzma-0.0.0.dev0-py3.6-win32.egg\py7zlib.py", line 632, in read
data = getattr(self, decoder)(coder, data, level, num_coders)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pylzma-0.0.0.dev0-py3.6-win32.egg\py7zlib.py", line 772, in _read_7z_aes256_sha256
result = cipher.decrypt(input)
TypeError: data must be a multiple of 16 bytes, got 807

My Code :

archive7zip.py
`#coding:utf-8

import pylzma
import time
import os
from py7zlib import Archive7z,NoPasswordGivenError,WrongPasswordError,UTC

class Archive7Zip(object):
def init(self):
self.__openedFile = []

def openArchive(self,fileName,password = None):
	archive = open(fileName,"rb")
	self.__openedFile.append(archive)
	archive = Archive7z(archive,password)
	return archive

def decompressArchive(self,archive):
	fileNames = archive.getnames()
	for fileName in fileNames:
		paths = os.path.split(fileName)
	#	print (paths)
		for i in range(len(paths) - 1):
			if (len(paths) == 1):break
			try:
				os.makedirs(paths[i])
			except FileExistsError:
				break

		cf = archive.getmember(fileName)
		if (not cf.checkcrc()):
			print ("Check CRC Failed : %s" % filename)
			continue
		with open(fileName,"wb+") as f:
			f.write(cf.read())
			f.close()
		print ("Decompress \"%s\" Successfully." % fileName)

`

main.py
`# coding:utf-8

from archive7zip import Archive7Zip

archiveClass = Archive7Zip()

archiveClass.decompressArchive(archiveClass.openArchive("test.7z","1234"))
`

Can someone help me?I'm not good at English.

This is the archive file,decompress it for "test.7z",password = 1234
Archive.zip

Prepare a new release

Hi,

just wanted to ask whether it is possible that you could prepare another release? There were quite some bugs fixed since last release, particularly #37 and #33. At the moment I have to wrap pylzma myself with back ported patches, but I believe current master is stable enough for the release. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.