Skip to main content

Python bindings for retro container formats (ZIP, LHA, HFS, StuffIt, etc.)

Project description

unretro (Python bindings)

Python bindings for the unretro Rust library.

The package provides forward-only traversal over retro container formats with a Pythonic API (Loader, open, walk, listdir) backed by the Rust implementation.

Related docs:

Installation

pip install unretro

Supported Interfaces

The package exports:

  • Loader
  • Entry
  • ContainerFormat
  • Metadata
  • ArchiveIterator
  • WalkResult
  • WalkIterator
  • open(path, *, max_depth=32)
  • walk(path, *, max_depth=32, topdown=True)
  • listdir(path)
  • detect_format(path)
  • __version__

Quick Examples

Iterate files in a container

import unretro

for entry in unretro.Loader(path="archive.lha"):
    print(f"{entry.path}: {entry.size} bytes")
    data = entry.read()

Read from bytes

import unretro

loader = unretro.Loader(data=b"...", name="archive.zip")
for entry in loader:
    print(entry.name)

Use file-like Entry

import json
import unretro

for entry in unretro.Loader(path="config.zip"):
    if entry.extension == "json":
        obj = json.load(entry)
        print(obj)

Filter traversal

import unretro

loader = unretro.Loader(path="disk.img")
loader = loader.filter_extension(["mod", "xm"])
loader = loader.filter_path("disk.img/music")

for entry in loader:
    print(entry.path)

open, walk, and listdir

import unretro

with unretro.open("archive.zip/readme.txt") as f:
    print(f.read())

for dirpath, dirnames, filenames in unretro.walk("archive.zip"):
    print(dirpath, dirnames, filenames)

print(unretro.listdir("archive.zip"))

Loader Construction Rules

Loader(...) accepts exactly one source:

  • Loader(path="..."), or
  • Loader(data=b"...", name="archive.zip")

Invalid combinations raise ValueError:

  • neither path nor data
  • both path and data
  • data without name

Behavior Notes

  • Traversal is forward-only and optimized for streaming.
  • open(path) returns the first matching leaf entry in traversal scope.
  • Entry supports file-like methods: read, seek, tell, readable, seekable.
  • walk and listdir propagate root failures as errors.
  • Recoverable nested traversal issues are emitted as Python warnings.

ContainerFormat and Metadata

  • detect_format(path) returns ContainerFormat or None.
  • ContainerFormat.name provides a human-readable name.
  • ContainerFormat.is_multi_file indicates whether format contains multiple files.
  • Entry.metadata exposes optional structured metadata when available.

Local Development

From this directory (crates/unretro-python):

python3 -m venv .venv
source .venv/bin/activate
pip install maturin pytest pytest-timeout
maturin develop --release
pytest tests/ -v

Project metadata and test defaults are defined in pyproject.toml.

Troubleshooting

  • If maturin develop fails, confirm Rust toolchain and Python headers are available.
  • If imports fail after rebuilding, re-activate the virtual environment and reinstall with maturin develop.
  • If traversal returns unexpected scope, verify whether path is treated as a virtual path into nested containers.

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

unretro-0.1.0.tar.gz (245.1 kB view details)

Uploaded Source

Built Distributions

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

unretro-0.1.0-cp39-abi3-win_amd64.whl (843.5 kB view details)

Uploaded CPython 3.9+Windows x86-64

unretro-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (887.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

unretro-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (861.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

unretro-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (802.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

unretro-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (858.8 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file unretro-0.1.0.tar.gz.

File metadata

  • Download URL: unretro-0.1.0.tar.gz
  • Upload date:
  • Size: 245.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unretro-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba38a29acb9ceccbac297cc17c5619fad9b393f67bc2b70b978680d4dba9963c
MD5 ec3b8051e30704c694811050e8cccf52
BLAKE2b-256 7b7e72bec84054ddb8224020df63de90294a76107a0e36dbd4c9d7dfddbd90cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.0.tar.gz:

Publisher: release.yml on rickardp/unretro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unretro-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: unretro-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 843.5 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unretro-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 29e27113d8c64e50bbd9975fa369a6eaa6ce76cf398f5479bf9ed906d4c180fd
MD5 44c55a374d3ad8c07788e0c07c5df3a2
BLAKE2b-256 e8c337d4433ca879836bc6266f65d4d56625b4ea227c9f0d3ef87cc326866d75

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on rickardp/unretro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unretro-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for unretro-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9049cf2bce41e794689b9f9d696bdd92dcbb6e0bed8b7d4a372171bb1db11b6a
MD5 8a135d20a76c567fd684c8468ea93449
BLAKE2b-256 7eb6a4c5f5b541a0ddd814d988e50bc3877e0de3fcc71572939e056be231dcc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rickardp/unretro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unretro-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for unretro-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bc0c750dad2efdf4bdde8c148be872fcea76f2df29b45d1c53728a59ac1eca39
MD5 e17715fd3848afad51fa7b3544f031d8
BLAKE2b-256 b1102bec73efde0c3c0971a460c91ebb2eab4bd2f9b8588d6c646415d4909f4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on rickardp/unretro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unretro-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for unretro-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db2cd356403825b6c8dca2a655827607caf1f4ccfad30d2da5a57670a610e043
MD5 61aab4dcae736956a1a1405c27f39ab5
BLAKE2b-256 108a4b0ab4f56cc235e81bd30bf665b1305851da9ad401384ac5d13c28a06312

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on rickardp/unretro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unretro-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for unretro-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d57dff8e9f8d5dcec341407f9dc34aeda8493e0d3999c443c023ceab9e97c7de
MD5 2067b30497d62eaa04126d51e804f04a
BLAKE2b-256 43b71976b4a5e532544989fd469176d17637633156b6a50d37e3ff469076abc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on rickardp/unretro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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