Skip to content

patrick91/fastar

 
 

Repository files navigation

Fastar

Versions PyPI Downloads License CodSpeed

The fastar library wraps the Rust tar and flate2 crates, providing a high-performance way for with compressed and uncompressed tar archives in Python.

Installation

pip install fastar

Usage

This section shows basic examples of how to create and extract tar archives using Fastar. For more usage examples, please refer directly to the test cases in the tests directory.

Working with uncompressed tar archives

import fastar
from pathlib import Path


input_file = Path("file.txt")
input_file.write_text("Hello, Fastar!")


with fastar.open("archive.tar", "w") as archive:
    archive.append(input_file)


with fastar.open("archive.tar", "r") as archive:
    archive.unpack("output/")


unpacked_file = Path("output/file.txt")
print(unpacked_file.read_text())  # Hello, Fastar!

Working with gzip-compressed tar archives

import fastar
from pathlib import Path


input_file = Path("file.txt")
input_file.write_text("Hello, Fastar!")


with fastar.open("archive.tar.gz", "w:gz") as archive:
    archive.append(input_file)


with fastar.open("archive.tar.gz", "r:gz") as archive:
    archive.unpack("output/")


unpacked_file = Path("output/file.txt")
print(unpacked_file.read_text())  # Hello, Fastar!

Development

  1. Install dependencies into a virtual env: uv sync
  2. Make changes to the code and tests
  3. Build the package: uv run maturin develop
  4. Run the tests: uv run pytest

About

High-level bindings for the Rust tar crate.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 87.9%
  • Rust 12.1%