Skip to main content

Python ctypes interface for 7z.dll (7-Zip archive library)

Project description

7z.py

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 NanaZip's 7z.dll for x64, x86, and ARM64.


Installation

pip install 7z.py

Python 3.14+ and Windows are required.


Quick start

List entries

from mf_7z 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 mf_7z import ArchiveReader

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

Create an archive

from pathlib import Path
from mf_7z 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 mf_7z 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 from NanaZip (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!

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

7z_py-1.0.0-py3-none-win_arm64.whl (842.9 kB view details)

Uploaded Python 3Windows ARM64

7z_py-1.0.0-py3-none-win_amd64.whl (919.3 kB view details)

Uploaded Python 3Windows x86-64

7z_py-1.0.0-py3-none-win32.whl (736.9 kB view details)

Uploaded Python 3Windows x86

File details

Details for the file 7z_py-1.0.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: 7z_py-1.0.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 842.9 kB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 7z_py-1.0.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 7077b0f419ec07a0c9772796db3d41523f451a13123fc2129d4286b31750e0fd
MD5 3b0b85f0ac1490e66ed25fc0a2f1fb8e
BLAKE2b-256 545c1e2fc66de96d812903d286d8686507d14c500ccb02fa099293d0e783e402

See more details on using hashes here.

File details

Details for the file 7z_py-1.0.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: 7z_py-1.0.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 919.3 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 7z_py-1.0.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 197b08776f8ec2313980419c7f64457494dbb7b90f15eab3b463831f06bc84b0
MD5 b8d6de84cec72e54f157d0f457202b85
BLAKE2b-256 54e64e4f526087fd20c5f65b4f726a1a1271919dcb1c2b669585b6dd9eadcae9

See more details on using hashes here.

File details

Details for the file 7z_py-1.0.0-py3-none-win32.whl.

File metadata

  • Download URL: 7z_py-1.0.0-py3-none-win32.whl
  • Upload date:
  • Size: 736.9 kB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 7z_py-1.0.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 1f09c3ebf2d107554489f71f3eeea4d9cff3bf919e66a0e2d709eddd36960eb0
MD5 ded078c8f813cb1dac3e5cb530fb5e81
BLAKE2b-256 56292e822ea7b810305410926162b7731b649e6f4f6dfc83dcde90c658e292b9

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