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

Uploaded CPython 3.9+Windows x86-64

unretro-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (887.9 kB view details)

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

unretro-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (860.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

unretro-0.1.2-cp39-abi3-macosx_11_0_arm64.whl (802.7 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

unretro-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl (856.2 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: unretro-0.1.2.tar.gz
  • Upload date:
  • Size: 247.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.2.tar.gz
Algorithm Hash digest
SHA256 2c829d0667005de0ebb06fcac4c099de77868101fe724d8c3d7c9dd927925d29
MD5 69080c4335279b4ae9c0cb370bb994c5
BLAKE2b-256 2f327b122a93c283178c1a0e496de5ee486ec451953c53902099fed92917eb53

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: unretro-0.1.2-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.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a38d1828825fce001b20041b57dde0d50c372932e55652888ce9805b24216a3d
MD5 b29c9412258a18e827e1088b93fad411
BLAKE2b-256 b6085bee87957e07e730d405abc1c0caed2c28f89fbabe7f37a6abab948a76f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fab6919f76382ce8d76a99d3af9c9245ebd1908a19663d4003d75a61f48c3518
MD5 880d870950456582cd6878700ccce715
BLAKE2b-256 71d4de7343864fc84cf350ee212adb745cac6fd786c562dc1b6c6de6bb7b3918

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5dc186098201cb3fec05eabecd66a717a9a4685db4c200557e0bec7f48a9d0d7
MD5 0c1f5ff7a7a7fc313a9b88b747ef2728
BLAKE2b-256 649ee9a00137f993d8544df0eb9696be4c02c86b468f75a7116c29ad6c8a641e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.1.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 47122bce9cad3b638500a56dba2f9f18e1947248907973a6fde6a7794f8f5fca
MD5 a8c62ee039bc9ee2a6fc462d56495e9a
BLAKE2b-256 104a01f6422ad9e52bf8203453117668681d1bd9492abdfddedccbb3614a5acb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unretro-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f030cdc15b9451ebdd006ab50afd6f66b8950aa5378a8bde3608ad1fc7e04f0d
MD5 ef9d51e5c95e1d151c79dd4d025ff19e
BLAKE2b-256 c330ef84068d46af92db6d2ad50e5881edd829213575fbd0ed07f7095f2447a3

See more details on using hashes here.

Provenance

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