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.0.tar.gz (31.2 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.0-cp37-abi3-win_amd64.whl (972.2 kB view details)

Uploaded CPython 3.7+Windows x86-64

crabpack-1.1.0-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.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: crabpack-1.1.0.tar.gz
  • Upload date:
  • Size: 31.2 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.0.tar.gz
Algorithm Hash digest
SHA256 9cbd620254b957847623928ada671078336f9c0281e2bea9e4f96a6a66332096
MD5 bf6e8c976755d22349556afe3b4069ad
BLAKE2b-256 52b928ece8d494607f734c8499b1bc641ad93d09ee1b414de6e27a7df9544304

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.0.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.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: crabpack-1.1.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 972.2 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.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6b32742f3930d786baa7c2f389d7fd60078e54a4899997e991f6f36aab9935e7
MD5 b1f6fc55bf592f1ee62d4bc47a2f62e2
BLAKE2b-256 20cdb6d9c00313a9cb764761cb6c7ce7f1c64d72fa7c6d205d376fbb1af5a7ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.0-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.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for crabpack-1.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0acae94f6ab40c0992a6005b313f2f7830aee853d5d06b328909f2403c6cd9dd
MD5 39e32f5ed5e5673fdd501af030ed2913
BLAKE2b-256 b52d095cf208f5f02003a94707ef6233c4f07e60bf03a4ff81616c12cda6c492

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.0-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.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for crabpack-1.1.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ef7cbb7ae3732934250871134d4e75f948dde517854ba7e53efbaa64ddfddfdb
MD5 8bd7ffa41adc1ee195caae85d682a37b
BLAKE2b-256 6e2ca0bf24068cd720f51872eeb63c3058a0ff7a75a9a5993e715fbb8706969e

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.0-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.0-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.0-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 550cd0de0ce62581b17802ed315420cf23c1bf1508c764b3ccaf9547d2fb0a50
MD5 512b452726897e4e83c2d452553f1bff
BLAKE2b-256 f1bff583b8bb9fa87f9860fc15a1e38f72de45615555caa9b2a0ab89aef755e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-1.1.0-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