Skip to main content

Rust-native packaging tool for Python virtual environments

Project description

crabpack

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.
      --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

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-0.1.0.tar.gz (30.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-0.1.0-cp37-abi3-win_amd64.whl (973.5 kB view details)

Uploaded CPython 3.7+Windows x86-64

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

File metadata

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

File hashes

Hashes for crabpack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44825d881e11bc655b21c650d3842f6c47a3b56ef606400ff4c9168a5ad7a13b
MD5 fcc0691e593c57a79b7a1b7cc8bd37d1
BLAKE2b-256 6f59089377f710d0b7d02f4d610834deff6382d51a8c61d641fedb8703378473

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: crabpack-0.1.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 973.5 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-0.1.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 eb7e31e6d4e54dbcc2fe4df6f4b02eb63953edc31a8342a666c0dee4891091a4
MD5 201db366f9c1bed7e325baf468373a82
BLAKE2b-256 983ed71c3e9f9b12092489818768bca59aec7c1526929b74382b28835bb8afbf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for crabpack-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a382d98da614045ae016c9d23b48341f8d72acf74713230f1e7ac6322320f46b
MD5 ba923fbc0fe1022359da225a38e7e228
BLAKE2b-256 996747554056b448aa3124aef715b9ad6e91882aca8e84a2b4fdd1bfce29b2b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for crabpack-0.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-0.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-0.1.0-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 aac5047df48b21cba560fbb387d3401f0600d265c1835a2879e7ac82886ef743
MD5 691d2a9602d0161e4c2f7c304c56fc70
BLAKE2b-256 05871e89718cc0854782ecafb03ddc558f268cf8e9fe7c590a4b9fd45f433b71

See more details on using hashes here.

Provenance

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