Registry / serialization / stream-unzip

stream-unzip

JSON →
library0.0.101pypypi✓ verified 23d ago

Stream-unzip is a Python library (version 0.0.101) designed to efficiently decompress ZIP archives without loading the entire file or any of its uncompressed contents into memory. It focuses on streaming capabilities, making it suitable for large files or network-bound operations. The library is actively maintained with regular releases and supports various ZIP formats including Deflate64, Zip64, and both AES and legacy ZipCrypto encryption.

pip install stream-unzip
INSTALL
IMPORT
SIG · STREAM-UNZIP
S
stream-unzip
serializationpythonv0.0.101
Install
2.2s avg
Import
255ms
Disk
28MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.101 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.258s · 28.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.252s · 30MB
28MB installed
● package 28MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stream_unzip
from stream_unzip import stream_unzip

This quickstart demonstrates how to stream-unzip a ZIP file downloaded via HTTPX. The `stream_unzip` function takes an iterable of bytes (representing the ZIP archive) and yields tuples for each file: `(file_name, file_size, unzipped_bytes_generator)`. The `unzipped_bytes_generator` for each file *must* be iterated to completion to avoid `UnfinishedIterationError`.

import httpx import os from stream_unzip import stream_unzip def get_zipped_chunks(url): # Ensure httpx is installed: pip install httpx # Example URL for a small test zip if not set: # url = url or 'https://www.learningcontainer.com/wp-content/uploads/2020/07/sample-zip-file.zip' with httpx.stream('GET', url, follow_redirects=True) as r: r.raise_for_status() yield from r.iter_bytes(chunk_size=65536) def main(): # Replace with a real ZIP file URL or use a local file stream zip_url = os.environ.get('STREAM_UNZIP_TEST_URL', 'https://www.learningcontainer.com/wp-content/uploads/2020/07/sample-zip-file.zip') print(f"Downloading and unzipping from: {zip_url}") for file_name, file_size, unzipped_chunks in stream_unzip(get_zipped_chunks(zip_url)): print(f"\nProcessing file: {file_name.decode('utf-8')} (Size: {file_size if file_size is not None else 'Unknown'} bytes)") total_unzipped_bytes = 0 # IMPORTANT: unzipped_chunks *must* be iterated to completion for chunk in unzipped_chunks: total_unzipped_bytes += len(chunk) # Process the chunk, e.g., write to disk or another stream # print(f" Read {len(chunk)} bytes from {file_name.decode('utf-8')}") print(f" Finished reading {total_unzipped_bytes} bytes for {file_name.decode('utf-8')}") if __name__ == '__main__': main()
stream-unzip --version
Debug
Known issues
breakingSupport for Python 3.6 was dropped in version 0.0.96. Additionally, support for earlier versions of Python 3.7 was dropped in version 0.0.100.
fix
Upgrade your Python environment to 3.7.7 or newer to use current versions of `stream-unzip`.
affects: >=0.0.96, >=0.0.100
gotchaThe `unzipped_chunks` generator yielded for each file *must* be fully consumed (iterated to completion). Failing to do so will result in an `UnfinishedIterationError`.
fix
Always iterate through all chunks yielded by the `unzipped_chunks` generator, even if you don't need the data (e.g., `for _ in unzipped_chunks: pass`).
affects: All
gotchaVersion 0.0.96 had a 'missing main import' bug which could lead to `ImportError`. This was fixed in version 0.0.97.
fix
Upgrade to version 0.0.97 or newer to avoid import issues.
affects: 0.0.96
gotchaThe library processes ZIP entries as they are read and does not rely on the central directory (which is at the end of a ZIP file). While this enables true streaming, it may lead to edge cases or failures with malformed or unusual ZIP archives that depend on the central directory for critical metadata.
fix
Be aware of this architectural choice when processing non-standard or potentially corrupted ZIP files. For such cases, a traditional `zipfile` module approach might be more robust if full file availability is not an issue.
affects: All
gotchaThe file name and file size values extracted from the ZIP archive should be treated as untrusted input, as they are provided by the ZIP file's creator and could be malicious.
fix
Sanitize or validate file names and sizes before using them, especially when writing to a file system or displaying to users.
affects: All
Upgrade
Version history
0.0.101latest on PyPI · released Mar 3, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
stream-unzip — pip install stream-unzip · libregistry