zipstream-ng

A modern Python library for generating and streaming ZIP files without buffering them in memory.

Library
PyPI
v1.9.2
47stars
LGPL-3.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
27/100Needs Attention
Development Activity20
Maintenance0
Community20
Maturity56
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture82
Code Quality82
Innovation78
Learning Curve84

zipstream-ng is a modern, dependency-free Python library for building ZIP archives that are streamed out as they are created, rather than assembled entirely in memory or on disk first. You add files, folders, or arbitrary byte streams to a ZipStream and iterate over it to get the archive bytes, making it ideal for serving large downloads from a web application where you want the response to start immediately and memory usage to stay flat.

It is a spiritual successor to the older python-zipstream project, rewritten with a cleaner API, Python 3 focus, and thread-safety. Beyond basic streaming it supports compression, ZIP64 for large archives, computing the final size ahead of time when possible, and adding content lazily from generators, so it fits everything from ad-hoc scripts to production download endpoints.

What You Get

  • A streamable ZipStream you iterate to emit archive bytes
  • Support for adding files, folders, and arbitrary byte iterables
  • Optional compression and ZIP64 support for very large archives
  • The ability to compute the final archive size in advance in many cases
  • Lazy content addition from generators for on-the-fly data
  • A bundled zipserver command for quickly serving a directory as a stream

Common Use Cases

  • Serving large multi-file downloads from a web app without buffering
  • Zipping and streaming user-selected files on demand
  • Packaging generated content (reports, exports) into a download response
  • Creating archives from data that is produced incrementally

Under The Hood

Architecture - The library centers on a ZipStream object (under src/zipstream) that you populate with files, paths, or byte iterables and then iterate to emit the archive. Rather than building a full archive first, it writes local file headers and compressed data on the fly and appends the central directory at the end, using the ZIP format’s streaming-friendly layout. A small zipstream.server module provides the optional zipserver console entry point that streams a directory as a download.

Tech Stack - Pure Python targeting 3.5+ with zero runtime dependencies, relying only on the standard library’s zlib and struct handling for compression and record packing. Packaging uses the modern hatchling build backend via pyproject.toml, and the source is laid out under a src/ layout with tests kept alongside.

Code Quality - The repository includes a substantial tests/test_zipstream.py suite run under pytest with coverage in CI (GitHub Actions), and the pyproject.toml declares a broad matrix of supported Python versions. The absence of external dependencies keeps the surface small and the behavior easy to reason about.

API Design - The API is deliberately approachable: construct a ZipStream, add content with a few methods, and iterate. Thoughtful extras - predicting the final size for a Content-Length header, thread-safety, and lazy generators - address the real needs of streaming downloads without complicating the common case. The README documents web-framework integration patterns, giving it a gentle learning curve.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search