Skip to main content

7z.py

PyPI - Version PyPI - Python Version PyPI - License Tests

Python ctypes interface for 7z.dll (the 7-Zip archive library).Supports reading, extracting, and creating 7z archives with optional password protection and real-time progress callbacks - all via the native 7-Zip COM interface, no subprocess required.

Windows only - requires a 7z.dll for the matching architecture. Bundles 7z.dll for x64, x86, and ARM64.


Installation

uv add 7z.py

or

pip install 7z.py

Python 3.12+ and Windows are required.


Quick start

List entries

from py7z import ArchiveReader

with ArchiveReader("archive.7z") as reader:
    for entry in reader.list_entries():
        print(entry.path, entry.size)

Extract all

from pathlib import Path
from py7z import ArchiveReader

with ArchiveReader("archive.7z") as reader:
    reader.extract_all(output_dir=Path("out/"))

Create an archive

from pathlib import Path
from py7z import ArchiveWriter, ArchiveEntryInput

entries = [ArchiveEntryInput.from_path(p) for p in Path("src/").rglob("*")]

with ArchiveWriter("archive.7z") as writer:
    writer.write(entries)

Progress callbacks

from py7z import ArchiveWriter, ArchiveEntryInput, ProgressInfo

def on_progress(info: ProgressInfo) -> None:
    print(info.summary)

entries = [ArchiveEntryInput.from_path(p) for p in Path("src/").rglob("*")]

with ArchiveWriter("archive.7z") as writer:
    writer.write(entries, progress_cb=on_progress)

ProgressInfo.summary produces output like:

 42.3%  9.5 MB/s  elapsed 0:05  rem 0:02  [3/5 files]  'src/foo.py'

Password protection

# Create
with ArchiveWriter("secret.7z", password="hunter2") as writer:
    writer.write(entries)

# Extract
with ArchiveReader("secret.7z", password="hunter2") as reader:
    reader.extract_all(output_dir=Path("out/"))

Platform support

Wheel tag Architecture
win_amd64 x64 (64-bit)
win32 x86 (32-bit)
win_arm64 ARM64

License

MIT - see LICENSE. Bundles 7z.dll (LGPL-2.1-or-later).


About Modding Forge

7z.py was built for the Python tooling powering Modding Forge - a community dedicated to Skyrim modding. If you enjoy modding or want to connect with other modders, come say hi!

Metadata

Release files for 7z.py 1.0.4

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

Built distributions (wheels)

Table of built distributions (wheels) for 7z.py 1.0.4
File Interpreter ABI Platform
7z_py-1.0.4-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
7z_py-1.0.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
7z_py-1.0.4-py3-none-win32.whl Python 3 none Windows x86-32 Details

Total release size: 2.4 MB

Release files / 7z_py-1.0.4-py3-none-win_arm64.whl

Download URL 7z_py-1.0.4-py3-none-win_arm64.whl
Size 817.8 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
d56456676237754399de9200eb862b2ab0d7f8a62d234d321004c25a2a1460e2
BLAKE2b-256 checksum
How to use checksums
34f9b743b20cb67cb464a78aef84b81c521535ad5ed46029e38c8da781208d78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}

Release files / 7z_py-1.0.4-py3-none-win_amd64.whl

Download URL 7z_py-1.0.4-py3-none-win_amd64.whl
Size 886.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
dea0372b6e9adbce43dc88a025187ff2da633c7adc2361b1e3e7ec658190d0f8
BLAKE2b-256 checksum
How to use checksums
779485664c474b06e6321763cb4b7586092c2b74e4fac39a696ddbb1541a3c29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}

Release files / 7z_py-1.0.4-py3-none-win32.whl

Download URL 7z_py-1.0.4-py3-none-win32.whl
Size 722.0 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
0cb273545fff61d8446e8464dad343e5e2f89065f27c51234827b4cb2464a84d
BLAKE2b-256 checksum
How to use checksums
559500f09c79707e95995927dce55bbbb7e34ce73173ce4cb685d2f4c07d64b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}

Release history Release notifications | RSS feed

This release

1.0.4 This release

3 release files

1.0.3

3 release files

1.0.2

3 release files

1.0.1

3 release files

1.0.0

3 release files

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