Command line program uvw
to work with multiple uv based virtual
environments. Note that the program name uvw
differs from the project name
uv-workon
as uvw
was taken on pypi.
uv
has taken the python world by storm, and for good reason. It manages
projects, dependencies, virtual environment creation, and much more, all while
being blazingly fast. One of the central ideas of uv is that the old method of
activating virtual environments should be replace with uv run ...
and letting
uv figure out the rest. We fully agree with this workflow, but it does run
counter to how many have used python virtual environments day to day data work.
For example, many have historically used tools like conda
or
virtualenvwrapper
to manage centrally located python
environments, that can be reused for multiple tasks. While we discorage using
"mega" environments (i.e., sticking every dependency you'll ever need in a
single python environments), there is utility in using a virtual environment for
multiple tasks. There is active discussion regarding if
and how uv should manage centralized virtual environments.
We takes the perspective that python virtual environments should be managed with
uv inside a project. uvw
allows for the usage of such virtual environments
outside the project. The basic workflow is as follows:
- Create a project
my-project
usinguv init ...
- Create a virtual environment
my-project/.venv
usinguv sync ...
- Link to central location using
uvw link my-project
Now, from anywhere, you can use the virtual environment my-project
:
- Activate with
uvw activate -n my-project
- Run python using the
my-project
virtual environment withuvw run -n my-project ...
- Change to the
my-project
project directory withuvw cd -n my-project
- Link virtual environment to central location with
uv link
. These links are located atWORKON_HOME
environment variable, defaulting to~/.virtualenvs
. - Activate virtual environment with
uvw activate ...
- Run under virtual environment with
uvw run ...
- Change to project directory with
uvw cd ...
- List available virtual environments with
uvw list
- Cleanup missing symlinks with
uvw clean
Currently uvw
is setup to work with bash
and zsh
shells only.
This package is actively used by the author. Please feel free to create a pull request for wanted features and suggestions!
It is recommended to install with uv
:
uv tool install uv-workon
Run the following to add autocompletion for uvw
:
uvw --install-completion
To use uvw activate
and uvw cd
, you must enable the shell configuration with
`eval "$(uvw shell-config)", or add it to you config script with:
# for zsh
echo 'eval "$(uvw shell-config)"' >> ~/.zshrc
# for bash
echo 'eval "$(uvw shell-config)"' >> ~/.bashrc
See the documentation for further details.
This is free software. See LICENSE.
Any other stuff to mention....
The author can be reached at [email protected].
This package was created using Cookiecutter with the usnistgov/cookiecutter-nist-python template.