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.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.4.0.tar.gz (148.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.4.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uv_workon-0.4.0.tar.gz
Algorithm Hash digest
SHA256 aa2512397bea00d26aea7c1a7c678f2dfdf17bf7402d119fa9eaf8ec18b35fec
MD5 70b89249ab4e26759bbc3da787b947b7
BLAKE2b-256 8fb8406e28be243cfce0781efad3c35a2ac966db7568e24d278e2f986f17bb53

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for uv_workon-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96913ca35cf34873976a175d580132e91ac416cb1235dd7f9a94bfaacf81237a
MD5 0d820c5b89e9f34f6d5a3e74f54c12c5
BLAKE2b-256 7393d830dab4fba09211f253143f93732cbc2ea00b5abd02e31205b2df71f286

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