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.1.tar.gz (246.9 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.1-cp39-abi3-win_amd64.whl (843.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

unretro-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (887.8 kB view details)

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

unretro-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (860.0 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

unretro-0.1.1-cp39-abi3-macosx_11_0_arm64.whl (801.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

unretro-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl (858.9 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: unretro-0.1.1.tar.gz
  • Upload date:
  • Size: 246.9 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.1.tar.gz
Algorithm Hash digest
SHA256 f278bb74f2777736316e9806909af7a7f0a4c0a3b66e3d707e8509aafcf1eaf8
MD5 f5a037982c29e1e39834f0d3c521a2b0
BLAKE2b-256 5caaa46ebd1f477e2e5a4f0e582982e99f318ec6c446a9945ea8db419732b101

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.1.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.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: unretro-0.1.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 843.3 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.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 262bd613f8abb78f3fccea7b62b884b894ec975665a86ec35574b2c77981a020
MD5 e4d9d46c6fa8b8765537380aae1402ed
BLAKE2b-256 0c3f3d3cafe56b2c310dc11d96106d2e9d4b6c61d9fb27ceadd86c3711320f22

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.1-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.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for unretro-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f191892575d16007ad5ef0a91d8d12593389560413dff89789752c115f32c8a
MD5 333efa5ce2d2f03f1c38bcedca3893f0
BLAKE2b-256 f50d3a8fd91b53f99bab781ee7c323a43c2ad21e30f20093d4a1fd3a4b2c656a

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.1-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.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for unretro-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1d60cbb1b683e819cd19fb34146cfec13eadb0393823f7412f7b700b0d68c1a6
MD5 b577b3fa0fc56809b1adab111a1889cf
BLAKE2b-256 c8d84ce37bfa8e7089e3172072fa6c903fa87d2f891bab491d14bd73ae6b377e

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.1-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.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for unretro-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7879cbb0cdb6edeb88fcef7cb73ccdfa4dba7d14c547f949f0c954ce67c36c3b
MD5 930c0e0b5c96696091f2b5d49621b4a0
BLAKE2b-256 432daba315fd8fcb1ce3778ec58d0b782df401d167457c0d797e51aab70e5cf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.1-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.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for unretro-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f2ac442e1aaa5093099a28a83c241428707ac6e8acbde86bec89b5469a4f9d3b
MD5 be3f295f664d2dfe54c575d9ae2b9b68
BLAKE2b-256 0393da59b67f0575162e98731acf363f25e8e573f67a7106af2750561a437229

See more details on using hashes here.

Provenance

The following attestation bundles were made for unretro-0.1.1-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