Skip to main content

zip-deterministic: byte-identical archives, build after build

PyPI version Python versions Downloads CI License docs zero dependencies

byte-identical archives, build after build

Standard library only. No runtime dependencies. Python 3.9+.

how zip-deterministic fits in

Install

pip install zip-deterministic

Use

from zip_deterministic import zip_bytes, tar_bytes, write_zip, write_tar

data = zip_bytes(
    {"README.md": b"# hello\n", "src/app.py": b"print('hi')\n"},
    compression=__import__("zipfile").ZIP_DEFLATED,
    level=6,
)

tar = tar_bytes({"README.md": b"# hello\n"})  # .tar.gz, gzip header cleared
plain = tar_bytes({"README.md": b"# hello\n"}, gz=False)  # bare .tar

write_zip("release.zip", {"a.txt": b"a"})  # returns the size in bytes
write_tar("release.tar.gz", {"a.txt": b"a"})

Executables keep their bit when you ask for it:

zip_bytes({"bin/run.sh": b"#!/bin/sh\n"}, mode=0o755)

Members are checked before anything is written. Absolute paths, .. traversal, duplicate names and non-bytes content raise instead of producing an archive that extracts outside the target directory.

What it does not do

  • It does not walk a directory for you: pass the members, so the caller decides what goes in and in what encoding.
  • Symbols, hard links and directories are not modelled; only regular file members.
  • Deflate output still depends on the zlib version. Same interpreter and zlib, same bytes; across zlib versions the compressed stream may differ, which is why the reproducible-builds project recommends ZIP_STORED when that matters.

Development

python -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest

License

MIT.

Metadata

Release files for zip-deterministic 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for zip-deterministic 0.1.3
File Interpreter ABI Platform Actions
zip_deterministic-0.1.3-py3-none-any.whl Python 3 none any Details for zip_deterministic-0.1.3-py3-none-any.whl

Release files / zip_deterministic-0.1.3-py3-none-any.whl

Download URL zip_deterministic-0.1.3-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c79af08e3cb7a2b8e7e55ebebd415ec9f0b7022e2dc0ba3897076f86ac01b63
BLAKE2b-256 checksum
How to use checksums
54183dd41527037790fec6b6b6eda3081c86d7ab4d1b9c903f89a2d3a6deb13e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.14

Security for zip-deterministic 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page