Archivey
Archivey reads, streams, and safely extracts ZIP / TAR / RAR / 7z / ISO / directory / single-file-compressed archives behind one uniform interface.
import archivey
with archivey.open_archive("photos.zip") as reader:
for member in reader:
print(member.name, member.size)
Thirty seconds
import sys
import archivey
# Extract safely. Path traversal, symlink escapes and bombs are blocked by
# default; you opt out, not in. -> Safe extraction
report = archivey.extract("untrusted.zip", "out/")
# Read one member, verified. A corrupt or truncated member raises from read(),
# never quietly returns short. -> Reading members
with archivey.open_archive("photos.zip") as reader:
data = reader.read("subdir/a.txt")
# Stream one member without materialising it. -> Reading members
with archivey.open_archive("big.tar.gz") as reader:
for member, stream in reader.stream_members():
if member.is_file:
for chunk in iter(lambda: stream.read(1 << 20), b""):
...
# Read from a pipe: forward-only, single pass. TAR and the single-file compressors only
# — ZIP, ISO, 7z and RAR need a seekable source. -> Access costs
with archivey.open_archive(sys.stdin.buffer, streaming=True) as reader:
for member, stream in reader.stream_members():
...
Safe extraction · Reading members · Access costs · Install
Highlights
- One interface for every format — ZIP, TAR (
.tar.gz/.bz2/.xz/.zst/…), RAR, 7z, ISO, plain directories, and single-file streams (gzip, bzip2, xz, zstd, lz4, lzip, zlib, brotli, Unix compress) all read the same way. - Automatic format detection from content, not just the file extension.
- Zero-dependency core — ZIP/TAR/directory and the stdlib codecs work with no extra installs; optional formats and accelerators are opt-in extras.
- Native 7z and RAR metadata readers — no
py7zr/rarfileon the read path (RAR member data still uses the systemunrarorrar). - Safe by default — extraction blocks path traversal, symlink escapes, and archive bombs unless you opt out. See Safe extraction.
- Streaming-friendly — read TAR and the single-file compressors straight from a pipe in a single forward pass (formats that keep their index at the end need a seekable source), with explicit, predictable access costs for solid archives and seeking.
- Consistent handling of symlinks, timestamps, permissions, passwords, and a single exception hierarchy.
User guide
- Install and extras — what to install for the formats you need
- Opening and listing — sources, detection, passwords, what's inside
- Reading members — getting bytes out, and what each outcome means
- Gotchas — traps worth knowing after the basics (read this next)
- Safe extraction — what “safe by default” means in practice
- Access costs and pitfalls — hidden decompression costs and how to avoid them
- Formats and extras — per-format quirks, required libraries, limitations
- Errors and diagnostics — what is raised, what is recorded
- Command line — the
archiveycommand - Migrating — coming from
zipfile,tarfile,shutil,patool - Platforms and threading — supported Pythons/OSes and what free-threading claims
- Philosophy — why Archivey exists and the defaults that follow
- API reference — generated from source
- Acknowledgements — libraries, oracles, and design references
For contributors
This site is the user guide, and nothing else. Contributor material lives in the repository:
CONTRIBUTING.md— coding and testing standardsopenspec/specs/— the authoritative behaviour contractsdev-docs/— decision log, threat model, codec analysis, known issues, roadmap, and finished investigationsVISION.md— what the project is for and how trade-offs get settled