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 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.

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. uvw 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 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 with uvw run -n my-project ...
  • Change to the my-project project directory with uvw cd -n my-project

Features

  • Link virtual environment to central location with uvw link. These links are located at WORKON_HOME environment variable, defaulting to ~/.virtualenvs.
  • Activate virtual environment with uvw activate ... (requires shell integration)
  • Run under virtual environment with uvw run ...
  • Change to project directory with uvw cd ... (requires shell integration)
  • List available virtual environments with uvw list
  • Cleanup missing symlinks with uvw clean
  • Manage ipykernel with uvw kernels ...
    • Install kernels for linked virtual environments which have ipykernel installed with uvw kernels install ...
    • Remove kernels (including remove all missing/broken kernels) with uvw kernels remove ...
    • list installed kernels with uvw 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 uvw:

uvw --install-completion

Shell integration

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

Currently uvw shell integration is setup to work with bash and zsh shells only.

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

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.5.1.tar.gz (150.5 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.5.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uv_workon-0.5.1.tar.gz
Algorithm Hash digest
SHA256 22e93901bdb5f1e4a794b2b32261b66db37b68af2eaaf0cf14ec557a2524b808
MD5 c08dabb8b8f81b211c925fc9e0b2855f
BLAKE2b-256 7cf19f08ed617caa1ced2eeab6f6355022681a3a71108a1ee09abbd9d11059ea

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for uv_workon-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d6443528c2b533fb3e81f83ef586b8fcb5c1829838783f223fdcb12229cdf42
MD5 34a4679907186da2ad17d619cc5781dd
BLAKE2b-256 1ed6679a1649bc86bec43b4aea42d3321d8cef53c7ca2a8fbd5cce1188c135e2

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