Skip to main content

Rust-native packaging tool for Python virtual environments

Project description

crabpack

This package was written 100% by AI.

crabpack is a Rust-native, high-performance reimplementation of the venv-pack tool for packaging Python virtual environments. It provides a drop-in compatible command line interface as well as optional Python bindings powered by PyO3.

The crate produces portable .tar, .tar.gz, .tar.bz2, or .zip archives of existing Python virtual environments. During packing, crabpack rewrites shebangs for executables, optionally relinks Python interpreters, and injects a portable activate script (sourced from CPython).

Command line usage

Package an existing virtual environment into an archive file.

Usage: crabpack [OPTIONS]

Options:
  -p, --prefix <PATH>           Full path to environment prefix. Default is
                                current environment.
  -o, --output <PATH>           The path of the output file. Defaults to the
                                environment name with a `.tar.gz` suffix.
      --format <FORMAT>         The archival format to use. [default: infer]
                                [possible values: infer, zip, tar.gz, tgz,
                                tar.bz2, tbz2, tar]
      --python-prefix <PATH>    New prefix path for linking python in the
                                packaged environment.
      --compress-level <INT>    Compression level to use (0-9). Ignored for zip
                                archives. [default: 4]
      --compressor <COMPRESSOR>
                                Compressor to use for .tar.gz archives.
                                [default: auto] [possible values: auto, gzip,
                                pigz]
      --pigz-threads <INT>      Number of threads to use with pigz compression.
      --zip-symlinks            Store symbolic links in the zip archive instead
                                of the linked files.
      --no-zip-64               Disable ZIP64 extensions.
      --skip-editable           Continue packing even if editable packages are
                               detected.
      --exclude <PATTERN>       Exclude files matching this pattern (can be
                                repeated).
      --include <PATTERN>       Re-add excluded files matching this pattern.
  -f, --force                   Overwrite any existing archive at the output
                                path.
  -q, --quiet                   Do not report progress.
      --version                 Show version then exit.
      --help                    Print help information.

Example:

crabpack --prefix /opt/envs/my-env --output my-env.tar.gz --format tar.gz \
  --exclude "*.pyc" --force

Editable packages

crabpack aborts by default when it detects editable installs (packages living outside of the environment prefix and linked in via .pth files). Use the --skip-editable flag to continue packing despite their presence. When this option is enabled, crabpack reports the offending paths on stderr and omits their external locations from the generated archive.

Python package

crabpack can also be distributed as a Python package backed by the Rust implementation. The project uses maturin as its build backend and publishes a module compatible with venv_pack.pack.

To work with the Python bindings locally, create a virtual environment and install the extension in development mode:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
maturin develop --release -F python

After installation, the package can be imported from Python:

import crabpack

crabpack.pack(prefix="/opt/envs/my-env", output="my-env.tar.gz", format="tar.gz")

To build distributable wheels and an sdist for publishing, run:

maturin build --release -F python

Development

cargo fmt
cargo check
cargo test
pytest -q

The repository includes integration assets under assets/scripts that are embedded into produced archives. The script is derived from CPython's venv implementation and distributed under the PSF license (see assets/scripts/CPYTHON_LICENSE.txt).

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

crabpack-1.1.1.tar.gz (31.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

crabpack-1.1.1-cp37-abi3-win_amd64.whl (972.4 kB view details)

Uploaded CPython 3.7+Windows x86-64

crabpack-1.1.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

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

crabpack-1.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

crabpack-1.1.1-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.2 MB view details)

Uploaded CPython 3.7+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file crabpack-1.1.1.tar.gz.

File metadata

  • Download URL: crabpack-1.1.1.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for crabpack-1.1.1.tar.gz
Algorithm Hash digest
SHA256 bed717fdf7cb72722c9619fa8fe27fca05cf67f936fbee5ba0c79fc03ace6339
MD5 26c46912d5dd74ce624d3922b69737bd
BLAKE2b-256 58dbb9679a65741eca2c5e224bde9d427ed7dbd9626545596b3d3de023a5f938

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.1.tar.gz:

Publisher: release.yml on jantzent/crabpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crabpack-1.1.1-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: crabpack-1.1.1-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 972.4 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for crabpack-1.1.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 548c062175c1c5fa70f4c1b0360c9c06abcfbd45eb2203eb1d43f116d0c86bdb
MD5 73c6242570823b59e9108e56c801f125
BLAKE2b-256 36970a7e58b58a393b3fe178d7719a8e8e4a7f328cfa84b503e7f373ce1881b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.1-cp37-abi3-win_amd64.whl:

Publisher: release.yml on jantzent/crabpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crabpack-1.1.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for crabpack-1.1.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd4bfd777bf3a06296b6639ed19de81e2f17fe0deb46a2b586d46b485b540cbe
MD5 d3dc3ff81aa2d1b2f32e1effde30d79a
BLAKE2b-256 b85eb4642c688f72c00f57542c7ccef29580342bd5a53d75f6a95014d82e4c54

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on jantzent/crabpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crabpack-1.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for crabpack-1.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dc1ec246d7fef70960c52c15dfbd25de865f74a5fd15ca9ab50138eb7b96124e
MD5 605719a011728aae8387056f7724fb54
BLAKE2b-256 f0eccd727030ee3fa3ca9627e9761620a4974f7301730cc2749595a0c71e15ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on jantzent/crabpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crabpack-1.1.1-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for crabpack-1.1.1-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fb05b38f3f2fd99e287f74dc7977452165f4cea78b673575f2d8554cad985b9f
MD5 41eb3771e94960f6065eca1bfd9d9c91
BLAKE2b-256 44fd28019d48d2c42a08634cc158f7b3e32c6a3447604ae2ed1d924312e2c100

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.1-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on jantzent/crabpack

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