Package: venv-management
A Python package for programmatic creation and management of Python virtual environments.This document gives an overview. For more detail see thedocumentation.PrerequisitesA virtualenvwrapper installation must have been installed and be available in a shell and configured
at shell start-up in the appropriatercfile (e.g..bashrc, but the documentation for more
details and options). The following virtualenvwrapper implementations have been tested:virtualenvwrappervirtualenv-shpyenv-virtualenvPossibly in future we will also support:pewInstallationInstall from PyPI usingpip:$ pip install venv-managementSynopsisUse the Python functions exported by thevenv_managementpackage to create, enumerate,
interrogate, and destroy virtual environments:>>> make_virtual_env("myenv")
>>> python_version(env_path)
'3.10.0'
>>> list_virtual_envs()
['myenv']
>>> env_path = resolve_virtual_env("myenv")
>>> env_path
/home/user/.virtualenvs/myenv
>>> remove_virtual_env("myenv")
>>>Refer to the documentation to see all available functions.Shell selectionThisvenv-managementpackage delegates most operations to one of thevirtualenvwrapperor
equivalent tools, which are implemented using shell scripts and shell functions. In order to invoke
these scripts and functions successfully the shell environment mush have been correctly configured.
By defaultvenv-managementattempts to use the current user’s preferred shell by examining the$SHELLenvironment variable. This can be overridden by setting the$VENV_MANAGEMENT_SHELLvariable with a shell executable name or the path to a shell executable, for example:export VENV_MANAGEMENT_SHELL=zshIf neither$SHELLnor$VENV_MANAGEMENT_SHELLare set, an attempt to usebashwill be
made.Shell configurationThe selected shell must be configured to make thevirtualenvwrappercommands available. By
default,venv-managementwill source thercfile corresponding to the selected shell, for
example.bashrcforbash,.zshrcforzsh, and so on, on the basis thatvirtualenvwrapperinitialization is often performed from these files. If thercfile for
the selected shell can only be usefully sourced in an interactive shell, setVENV_MANAGEMENT_INTERACTIVE_SHELLtoyes:export VENV_MANAGEMENT_INTERACTIVE_SHELL=yesShould you wish to specify a different file for shell configuration, provide its path in theVENV_MANAGEMENT_SETUP_FILEPATHenvironment variable. For example, since.bashrcmay return
immediately in non-interactive shells, and only login shells source.profileon start-up,
you may want to set up virtualenvwrapper or an equivalent in in a separate file, in this example
called.venvwraprc:# .venvwraprc
source /usr/local/bin/virtualenvwrapper.shand then source this file in turn from, say,.bashrc.If theVENV_MANAGEMENT_USE_SETUPvariable is set toyes, the script whose filepath is
specified in theVENV_MANAGEMENT_SETUP_FILEPATHvariable will be as necessary before executing
the commands run by this package:export VENV_MANAGEMENT_USE_SETUP=yes
export VENV_MANAGEMENT_SETUP_FILEPATH=$HOME/.venvwraprcYou can also source this custom config file in a shell-specificrcfile using thesourceor.command,
so thatvirtualenvwrappercould be used in interactive shells.Driver preferenceIf you have multiple virtualenv wrapper implementations installed, you can specify the order in
which they will be tried with theVENV_MANAGEMENT_PREFERRED_DRIVERSenvironment variable. The
first working implementation will be used:export VENV_MANAGEMENT_PREFERRED_DRIVERS="virtualenvwrapper,virtualenv-sh"Release processUpgrade the version:$ bumpversion <major | minor | patch>Push the tagged commit into the repository together with the tag. You can find the latest tag using thegit tagcommand or find and fill in the most recent tag withgit describe:$ git push --atomic origin master $(git describe --abbrev=0 --tags)Create the source and the binary distribution (outputs in thedistdirectory):$ python setup.py sdist bdist_wheelRemove old versions in thedistdirectory and use the following command to upload its contents to PyPI:$ twine upload dist/* --config-file=<path/to/file/with/credentials.pypirc>Copyright 2021 Sixty North ASPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.