uv-workon

Repo Docs PyPI license PyPI version Code style: ruff uv

uv-workon#

Command line program uv-workon to work with multiple uv based virtual environments. Note that the program name uv-workon differs from the project name uv-workon as uv-workon was taken on pypi.

Overview#

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 for 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. uv-workon allows for the usage of such virtual environments outside the project. The basic workflow is as follows:

  1. Create a project my-project using uv init ...

  2. Create a virtual environment my-project/.venv using uv sync ...

  3. Link to central location using uv-workon link my-project

Now, from anywhere, you can use the virtual environment my-project:

  • Activate with uv-workon activate -n my-project

  • Run python using the my-project virtual environment with uv-workon run -n my-project ...

  • Change to the my-project project directory with uv-workon cd -n my-project

Features#

  • Link virtual environment to central location with uv-workon link. These links are located at WORKON_HOME environment variable, defaulting to ~/.virtualenvs.

  • Activate virtual environment with uv-workon activate ... (requires shell integration)

  • Run under virtual environment with uv-workon run ...

  • Change to project directory with uv-workon cd ... (requires shell integration)

  • List available virtual environments with uv-workon list

  • Cleanup missing symlinks with uv-workon clean

  • Manage ipykernel with uv-workon kernels ...

    • Install kernels for linked virtual environments which have ipykernel installed with uv-workon kernels install ...

    • Remove kernels (including remove all missing/broken kernels) with uv-workon kernels remove ...

    • list installed kernels with uv-workon kernels list ...

Status#

This package is actively used by the author. Please feel free to create a pull request for wanted features and suggestions!