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 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 uv link. These links are located at WORKON_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.

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

Add autocompletion

Run the following to add autocompletion for uvw:

uvw --install-completion

Shell interaction

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

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

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.2.0.tar.gz (183.3 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.2.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uv_workon-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0af5adb55d940e741706c859243f92d4f6a594cb7d477892141fc3d5962f3c6d
MD5 369b70d407523ec8e4ffdb76aafc8ccc
BLAKE2b-256 26d146666315b84969aa77ba1231d401968973478af8deacb88e7eae819fd6bb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for uv_workon-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 034a606fcb454c89e8b335f85a9fcdf7ee5132c8603da472748111e6da6de764
MD5 e1880284c51aa8e5c68e9ac1281674c9
BLAKE2b-256 eb8888a216ee8eaa755f881736065882f69738de6ee892441a86f8f0a4f0b28c

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