Zipstream

raw JSON →
1.1.4 verified Fri May 01 auth: no python maintenance

Zipfile generator that allows streaming zip file creation with iterators, suitable for large files. Current version 1.1.4, released Oct 2020. Maintenance mode.

pip install zipstream
error AttributeError: module 'zipstream' has no attribute 'ZipStream'
cause Wrong import. zipstream exports ZipStream, not zipstream.ZipStream.
fix
Use 'from zipstream import ZipStream'
error TypeError: argument should be integer or None, not 'NoneType'
cause Passing None as the file path to write().
fix
Provide a valid file path string to z.write(path).
error ValueError: ZIP64 extensions required but not enabled
cause File larger than 4 GiB without zip64 flag.
fix
Set allowZip64=True when creating ZipStream: z = ZipStream(allowZip64=True)
deprecated ZipStream is in maintenance mode with no active development. Consider using zipfile (standard library) for in-memory zips or streamingzip for large streaming.
fix Migrate to zipfile or streamingzip if possible.
gotcha ZipStream is not thread-safe. Do not share a ZipStream instance across threads.
fix Create separate ZipStream instances per thread.
breaking In v1.1.2, PointerIO.seek() was removed, making the stream non-seekable. Code that relied on .seek() will break.
fix Do not call .seek() on the output of ZipStream. Accumulate data if seeking is required.

Create a zip from a file and iterate chunks.

from zipstream import ZipStream

z = ZipStream()
z.write('/path/to/file.txt')

with open('output.zip', 'wb') as f:
    for chunk in z:
        f.write(chunk)