Skip to main content

tpack

tpack is a lightweight text-based archiver that packs a directory into a single text file and restores it in another environment.
Unlike binary formats such as ZIP or TAR, tpack produces a fully readable UTF‑8 text archive that preserves file boundaries using configurable headers.

  • Cross‑platform (Windows / macOS / Linux)
    • Output is always UTF‑8 with LF (\n) newlines
    • Configurable exclude rules, header format, and whitespace handling
    • Designed as a simple and portable CLI tool installable via pip

✨ Features

  • Pack: Convert a directory into a single text archive
    • Unpack: Restore files from a text archive
    • Configurable behavior via YAML:
      • Glob-based exclude patterns
      • Optional blank-line removal
      • Custom header prefix and border characters
      • Custom encoding (default: UTF‑8)
    • Binary files are automatically skipped
    • Deterministic output format suitable for version control or diff tools

📦 Installation

pip install tpack

🚀 Usage

Pack a directory

tpack <source_dir> -o output.txt

Example:

tpack src -o archive.txt

Output File Safety

When packing a directory, tpack automatically excludes the output file if it is located inside the source directory. This prevents the archive from accidentally including or overwriting itself.

Example:

tpack src -o src/archive.txt

In this case, archive.txt is inside src/, so tpack will automatically exclude it from the pack operation. This behavior applies whether the paths are specified as absolute or relative; tpack normalizes paths internally to ensure correct detection.

If the output file is outside the source directory, no exclusion is applied.


Unpack an archive

tpack -u archive.txt -d restored_dir

Example:

tpack -u archive.txt -d restored

⚙ Configuration (config.yaml)

tpack supports a YAML configuration file to customize its behavior.

exclude:
  - node_modules
  - "*.log"
  - "*.jar"

remove_blank_lines: true
encoding: "utf-8"

header:
  prefix: "=="
  border_char: "="

Apply configuration

tpack src -o archive.txt -c config.yaml
tpack -u archive.txt -d restored -c config.yaml

📁 Output Format Example

==------==
== a.txt ==
==------==
hello
world

The header format is controlled by prefix and border_char.


🧪 Testing

tpack includes pytest-based tests.

pytest -q

📂 Project Structure

tpack/
  tpack/
    __init__.py
    cli.py
    packer.py
    unpacker.py
    config.py
  pyproject.toml
  README.md
  tests/
    test_tpack.py

📜 License

MIT License


🤝 Contributing

Issues and pull requests are welcome.

Metadata

Release files for tpack 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tpack 0.1.0
File Size Uploaded
tpack-0.1.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tpack 0.1.0
File Interpreter ABI Platform
tpack-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / tpack-0.1.0.tar.gz

Download URL tpack-0.1.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fe0c529cc984ae2c7efd921bfc104eddc83b94e0c5342520440e54f78acd8bb0
BLAKE2b-256 checksum
How to use checksums
5f82e80f9886ab279a35c01e92793c011487285712ce991e54055ac7cf28e953
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release files / tpack-0.1.0-py3-none-any.whl

Download URL tpack-0.1.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13447e32958325276ec817f3e75651f6a0bcbf7bfa12fc7ca88729b14bebca18
BLAKE2b-256 checksum
How to use checksums
3fd2f53751db72a039300d8ee7f838d9e825bb8f30c99b5e57b3037fe3ec9a40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page