venv-wrapper is a convenient tool to help you manage your Python virtual environments. It used to be
a wrapper around python's built-in venv
module, but that is no longer the case, the required
features from venv
were re-implemented in Rust instead.
- Install rust (https://www.rust-lang.org/tools/install).
- Add the
cargo
bin path to yourPATH
environment variable.- Usually the bin path is
~/.cargo/bin
.
- Usually the bin path is
- Run
cargo install venv-wrapper
.
You can install venv-wrapper from the AUR.
$ paru -S venv-wrapper-bin
$ brew install marier-nico/packages/venv-wrapper
Coming soon!
- After installing, make sure you can use the
venv-wrapper
command (it should be in your shell's$PATH
). - Then, you need to setup your shell to use venv-wrapper. To do this, edit your shell
startup configuration file (
~/.bashrc
,~/.zshrc
,~/.config/fish/config.fish
) and add the following anywhere in there :
eval "$(venv-wrapper init bash)"
venv completions # Optional, if you want shell completions
eval "$(venv-wrapper init zsh)"
venv completions # Optional, if you want shell completions
venv-wrapper init fish | source
venv completions # Optional, if you want shell completions
It's possible to configure venv-wrapper with either a configuration file, environment variables, or CLI flags.
venv_root
: The directory in which to store all virtualenvs (defaults to~/.virtualenvs
).
The config file is a simple ini
file that contains no sections, like this :
venv_root = /home/me/.non-default-location
CAUTION: Paths in your configuration MUST be absolute, otherwise you might end up putting virtual environments where you don't intend to.
The location for the configuration file depends on your platform of choice. For specific implementation details, see the directories crate.
-
Linux
The XDG user directory specification is followed. Assuming defaults, the configuration should be located in
~/.config/venv-wrapper/config.ini
. -
macOS
The Standard Directories are used. By default, the configuration should be in
~/Library/Application support/venv-wrapper/config.ini
Note that paths do not need to be absolute here because your shell will perform path expansion. You do need the path to be absolute if your shell does not expand paths.
VENVWRAPPER_VENV_ROOT=~/.a-different-venvs-directory venv ls
The same note as with environment variables applies here : no need for an absolute path unless your shell does not expand paths.
venv -r ~/.a-different-venvs-directory venv ls
These shells are fully supported and should all work correctly :
- Bash
- ZSH
- Fish
However, all features except shell completions should work in most bash-like shells.
By default, shell completions are not active, but enabling them is really easy. All you have to do is run :
$ venv completions
Note: You must initialize venv-wrapper in your shell before activating completions.
Mostly, you should install pre-commit and run pre-commit install
to
make sure your commits are up to stuff! Also, your commits should adhere to
conventional commits. To do this, you can use a
tool like commitizen, which will help make sure
all commits look good.
The commit convention was added recently, so most commits are not yet compliant!
In its current state, this project does not quite match the features of virtualenvwrapper
. The
missing features are as follows :
- Copy virtualenvs
- Customizable hooks
- A plugin system to create shareable extensions
To release a new version, there a few simple steps to follow.
- Create or edit the
RELEASE_CHANGELOG.md
file (at the repo's root) to contain a changelog for the release.- This will be the GitHub release's body
- Update the version in
cargo.toml
, andsrc/cli/get_app.rs
. - Merge all code to be released into
main
. - Create a new tag pointing to the head of the
main
branch.git tag -s vX.Y.Z -m "Release vX.Y.Z"
- Push the new tag.
git push --tags
- After the release is created, update the homebrew formula here.