Skip to main content

Tools to activate and run virtual environments from central location

Project description

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!

Quick start

It is recommended to install with uv:

uv tool install uv-workon

To include the ability to manage ipykernel, include the jupyter extra:

uv tool install "uv-workon[jupyter]"

Add autocompletion

Run the following to add autocompletion for uv-workon:

uv-workon --install-completion

Shell integration

To use uv-workon activate and uv-workon cd, you must enable the shell configuration with `eval "$(uv-workon shell-config)", or add it to you config script with:

# for zsh
echo 'eval "$(uv-workon shell-config)"' >> ~/.zshrc
# for bash
echo 'eval "$(uv-workon shell-config)"' >> ~/.bashrc
# for fish
echo 'uv-workon shell-config | source' >> ~/.config/fish/completions/uv-workon.fish

Open a issue if you need support for another shell.

Documentation

See the documentation for further details.

License

This is free software. See LICENSE.

Related work

Any other stuff to mention....

Contact

The author can be reached at wpk@nist.gov.

Credits

This package was created using Cookiecutter with the usnistgov/cookiecutter-nist-python template.

Changelog

Changelog for uv-workon

Unreleased

See the fragment files in changelog.d

0.7.0 — 2025-06-02

Changed

  • Main executable is now named uv-workon, and removed uvw executable. This is to avoid conflict with uv which added a uvw alias for windows machines.

0.6.0 — 2025-05-30

Added

  • Now supports fish shell integration.

v0.5.1 — 2025-03-27

Changed

  • Cleanup output for kernels install for environments without ipykernels. Now only outputs No ipykernels if --verbose option passed

v0.5.0 — 2025-03-27

Added

  • Added subcommand uvw venv-link to link from workon-home to local .venv.

v0.4.0 — 2025-03-25

Changed

  • Now supports --yes/--no options. Default is to query the user to yes/no questions. Passing --yes will always answer yes. Passing --no will always answer no.

v0.3.1 — 2025-03-25

Fixed

  • Removed warning from uvw kernels list and type completion.

v0.3.0 — 2025-03-19

Added

  • Added kernels subcommands with:
    • install - install ipykernels
    • remove - remove jupyer kernels
    • list - list jupyter kernels This adds functionality to easy transition from nb_conda_kernels to using uv to manage virtual environment.
  • Added tests to have full coverage. This software was developed by employees of the National Institute of Standards and Technology (NIST), an agency of the Federal Government. Pursuant to title 17 United States Code Section 105, works of NIST employees are not subject to copyright protection in the United States and are considered to be in the public domain. Permission to freely use, copy, modify, and distribute this software and its documentation without fee is hereby granted, provided that this notice and disclaimer of warranty appears in all copies.

THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.

Distributions of NIST software should also include copyright and licensing statements of any third-party software that are legally bundled with the code in compliance with the conditions of those licenses.

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

uv_workon-0.7.0.tar.gz (158.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uv_workon-0.7.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file uv_workon-0.7.0.tar.gz.

File metadata

  • Download URL: uv_workon-0.7.0.tar.gz
  • Upload date:
  • Size: 158.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for uv_workon-0.7.0.tar.gz
Algorithm Hash digest
SHA256 c7c14a90103dd2d26678eae186932ae39ebd379f288ffab81970335ffc2e1784
MD5 1b07ceedc3ebf683e658dcfbfa0ca3e2
BLAKE2b-256 6ad9ccec1409ab1878114afae971d38e0c7bd45611399121807468ac5ada632f

See more details on using hashes here.

File details

Details for the file uv_workon-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: uv_workon-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for uv_workon-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90d5cacc39f69701dd3bde3917765d23a51ab2782ee36fc65e31ac86881a600b
MD5 2a04cfb0d1d5b83799fe48a9400386eb
BLAKE2b-256 e176d609b2fe6e62bb76362480dffc2ec537780ed58473a670fcda5197ebea61

See more details on using hashes here.

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