Skip to main content

A Pythonic wrapper around the 7-Zip console tool (7zz/7za/7z).

Project description

PyPI version Python versions License CI

p7z

Drive 7-Zip from Python with an API that feels native. 7-Zip does the work; p7z owns the developer experience — the common thing is one obvious line, and the hard thing is one more.

p7z in action

Install

pip install p7z

Wheels bundle the 7-Zip binary for Linux (x86_64, aarch64, musl), macOS (universal2), and Windows (x86_64, arm64) — no separate install required. The pure-source sdist falls back to a 7zz/7za/7z binary on PATH.

The common thing — one line

import p7z

p7z.compress("backup.7z", ["src/", "tests/"])
p7z.extract("backup.7z", "out/")
p7z.ls("backup.7z")          # → list[Entry], typed; no string-parsing

The hard things — still one line each

# Read one member out of an encrypted archive, straight to bytes — no temp file.
data = p7z.read_bytes("vault.7z", "secrets.env", password="hunter2")

# Real-time progress on any operation.
p7z.compress("big.7z", ["data/"], on_progress=lambda p: print(f"{p.percent}%"))

# Compress in-memory bytes — no disk round-trip.
p7z.compress_bytes("mem.7z", "note.txt", b"generated in RAM")

# The exact same API, async — run several at once.
import asyncio
await asyncio.gather(
    p7z.acompress("a.7z", ["a/"]),
    p7z.acompress("b.7z", ["b/"]),
)

Why p7z

  • It is the real 7-Zip binary under the hood — full format support and native performance (minus a small subprocess-spawn cost), with no compression algorithm reimplemented in Python.
  • Zero runtime dependencies — stdlib only; the binary ships inside the wheels.
  • DX is the product — typed results, real-time progress, in-memory and streamed I/O, encryption done right, and a typed exception hierarchy.

Features

  • Full operation surface — compress, extract, list, test, update, delete; sync and async (acompress, aextract, …) with identical signatures.
  • Streaming I/O — read entries as bytes, stream to a file object, compress from bytes in memory without touching the filesystem.
  • Real-time progress — pass on_progress= to any operation; fires on every 7-Zip progress event with a typed Progress object.
  • Encryptionpassword= on all read and write ops; header encryption; typed WrongPasswordError / PasswordRequiredError; split stdin/argv transport (reads are never exposed on the process list).
  • Compression tuningmethod=, dict_size=, solid=, threads=, volume_size=.
  • Archive object — fluent handle for repeated operations on one archive.
  • Typed errors — 7-Zip exit codes map to a named exception hierarchy; warnings surface without raising.
  • Zero runtime dependencies — stdlib only; all heavy lifting is delegated to the binary.
  • Python 3.11+ — no back-compat shims; multiplatform (Linux / macOS / Windows).

A runnable tour of all of the above lives in examples/demo.py.

Documentation

Full guides (installation, operations, streaming, progress, async, error handling, architecture) at https://zelo.github.io/p7z/.

License

p7z is MIT-licensed. It bundles the 7-Zip binary, which is licensed under the LGPL (see the vendored License.txt shipped inside the wheel for the full 7-Zip license text, including the unRAR and BSD clauses).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p7z-1.0.0.tar.gz (130.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

p7z-1.0.0-py3-none-win_arm64.whl (1.1 MB view details)

Uploaded Python 3Windows ARM64

p7z-1.0.0-py3-none-win_amd64.whl (1.2 MB view details)

Uploaded Python 3Windows x86-64

p7z-1.0.0-py3-none-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

p7z-1.0.0-py3-none-musllinux_1_2_aarch64.whl (1.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

p7z-1.0.0-py3-none-manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded Python 3

p7z-1.0.0-py3-none-manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded Python 3

p7z-1.0.0-py3-none-macosx_11_0_universal2.whl (2.6 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file p7z-1.0.0.tar.gz.

File metadata

  • Download URL: p7z-1.0.0.tar.gz
  • Upload date:
  • Size: 130.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c8bdf3ad525f248f9508d56bb181a10d0a07ca86c6cdc0fd942f7dbb721f650f
MD5 337e711e52eed4a7dab26c0e8629f726
BLAKE2b-256 a9131e5d6c10af20d9b6197ef3f47406c4f919cc722f2ad30445dd292a6463a7

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 6e070a24cc96e5a214685ca0c1641869c31dc81fd56e37ed7be4b889dfd5e687
MD5 83e2dd10a5d4865956890a5715051e5d
BLAKE2b-256 cbe9c021028a3f58d56222271c285f06ea81e926d4bed817dc6b099c64237e9c

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6c87050b95204a033e3840181924831c2f915d9a07b148d79f95358c9b0f8487
MD5 50b80ed5b66c4fcbf3857cd5afcdfab4
BLAKE2b-256 742226e96568940c5dcd188597d1320598acaa334254aab5c9318b2a08d31042

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 592ba507c5d9ec920a04290e46627455193a50576e8ff202c12363ca0a3e46b4
MD5 b8442ad5743f288fd6c9eb515d08f305
BLAKE2b-256 e0ebd18ad4163e2727883cac14a52e7106f6b1906ce1a345c4e8abe04c5c0ba0

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-musllinux_1_2_aarch64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3, musllinux: musl 1.2+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f9b093db1e7a5b466f7248982cd514cd8d20ff25dc57cf5b62e90110a16af962
MD5 022675811120fe93805bde39ddee20f8
BLAKE2b-256 b58aa360bb6c3315f618c2d44c5d26fe345c7b2f58a686893e7a54666a49dc7c

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dfaa98721fc3494225f8b63ccf79fb20ef6dea6f7e8629ef11ca8cf96ad87406
MD5 c94df62bd9cf0bf659b61698eb104431
BLAKE2b-256 33c518c1ead26335a84f4055ce743fe7670deb75746fc22b786d7d645134256f

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-manylinux2014_aarch64.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-manylinux2014_aarch64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5d3730c44188426afea747e8dd9fb3c158367210c823a52737d518c98d81f95d
MD5 77691623e6ead3c3dc32e16e78928b97
BLAKE2b-256 bc62408625c6c1ffbadd6ce357386ea8d16b54ca8ddee785cf5b11ba063c6e7e

See more details on using hashes here.

File details

Details for the file p7z-1.0.0-py3-none-macosx_11_0_universal2.whl.

File metadata

  • Download URL: p7z-1.0.0-py3-none-macosx_11_0_universal2.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3, macOS 11.0+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for p7z-1.0.0-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 ca6f6b0670b7bfca1d2e17e4670ff12464279b683a6bfd5953aaea999dc56cc3
MD5 f57d8cb2fb00022da5a760ce1e6817a6
BLAKE2b-256 00822cfcc312e27ac5bf603845e651f2f1d9dca13b5b0fa4305d27ae9918dd89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page