Skip to main content

Venv-Pack

This is based on venv-pack but with lots of improvements added by mrmathematica. It has Windows support. Bin/Scripts generated by venv will work out-of-box.

Venv-pack is a command-line tool for packaging virtual environments for distribution. This is useful for deploying code in a consistent environment.

Supports virtual environments created using python3/venv. Venv is part of the python standard library.

Install from source

venv-pack is available on github and can always be installed from source.

pip install git+https://github.com/mrmathematica/venv-pack.git

Install from pypi

venv-pack is available on pypi as venv-pack2.

pip install venv-pack2

Command-line Usage

One common use case is packing an environment on one machine to distribute to other machines as part of a deployment process.

On the source machine

Create venv, and then upgrade pip + setuptools first:

python -m venv venv
venv\Scripts\activate
python -m pip install -U pip setuptools

Python generates Windows .exe file such as pip.exe on the fly, so on Windows there is restriction that you want to fix a version of pip and setuptools at the beginning and stick with it. If needed, re-create new venv from a lock file. See pip-tools.

Install all your python packages, for example

pip install -r requirements.txt

Pack the current environment into my_env.zip

venv-pack -o env.zip

Pack an environment located at an explicit path into my_env.zip

venv-pack -p explicit\path\to\env -o env.zip 

On the target machine

Unpack environment into directory my_env

md my_env
python -m zipfile -e venv.zip my_env\ 

All features of venv should keep working from my_env folder.

Caveats

This tool is new, and has a few caveats.

  1. Python is not packaged with the environment, but rather symlinked in the environment. On Windows python venv does so in a pyvenv.cfg file. This is useful for deployment situations where Python is already installed on the machine, but the required library dependencies may not be.
  2. The os type where the environment was built must match the os type of the target. This means that environments built on windows can’t be relocated to linux.

Metadata

Release files for venv-pack2 0.9.2

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

Built distribution (wheel)

Table of built distributions (wheels) for venv-pack2 0.9.2
File Interpreter ABI Platform
venv_pack2-0.9.2-py3-none-any.whl Python 3 none any Details

Release files / venv_pack2-0.9.2-py3-none-any.whl

Download URL venv_pack2-0.9.2-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db034518b2c16224b77ca0b8171701ee98174a51b588558d6741c65c90b454de
BLAKE2b-256 checksum
How to use checksums
865bf64218e240ed50d50888f5bb1186b579b05ee0e8beb734ce1749807b81f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.9.2 This release

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

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