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.2.0.tar.gz (251.4 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.2.0-cp39-abi3-win_amd64.whl (846.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

unretro-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (893.5 kB view details)

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

unretro-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (866.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

unretro-0.2.0-cp39-abi3-macosx_11_0_arm64.whl (808.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

unretro-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (861.8 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for unretro-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0306603d493651125b8e46d5f125127353eae0de33c93fa20f3671879c8ea5bc
MD5 6a232b16c4f2df31d0ff7e88e40d19e9
BLAKE2b-256 7eaf558749785539b62050f7552cdff97358cf4ad8a1cd40111b265a464d5fc0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: unretro-0.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 846.8 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.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9757b00c254762f5e69544c7979d2e97c00dd0135d9fca7af54dde79a26e81c4
MD5 fa05abed959ae3a1824882b9b913b94f
BLAKE2b-256 195ba6fddf65d9db187deb89557b2165ec41efea86efb78116409d2e3e1fc6b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 53a0c079088afdb9b57817dfad586dca97dc69650a4bd91547d1b50fe4ad3c1a
MD5 d00fbf6e9458e39199baaaf07bfd1254
BLAKE2b-256 d8a99d548844ad6cf348b1e42ca7c460f1d09aec2a0733bfef5e772941d1dc30

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 644e553bf6697a83d4e1bbb0accf4a3eda4e56963acf5c305a0f9c72b42f9a44
MD5 19b9f075021d64912b511a580eab3f93
BLAKE2b-256 7ae399ee28ddaa97f60fd851e8661ba4643b9addd1b3497736af294ce90c8f9d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d08ebd83c23bc1c236772784068c53b4ddfc3b431fd5f5b293ed613661d9fd1
MD5 ee75048a0c98dbbddd33b6fd5bdc0d5b
BLAKE2b-256 a89aea4a32ab66d75935bb5a1ed35e1f328dce99265ad3c7621b13635a7ffecd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f93a3f2e5b1a6e2573062b872163fd488832822d1e6dcd94a4aa9d2a7095deed
MD5 14c1832b78bd0b9506b68847d454f6a8
BLAKE2b-256 fe0e0e2c66d5e006343bf3694b46e5c18dcef98014139bfb721ad76d238806e2

See more details on using hashes here.

Provenance

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