===============
Venv Management
===============
A Python package for programmatic creation and management of Python virtual environments.
.. image:: https://github.com/rob-smallshire/renard/workflows/CI/badge.svg?branch=master
:target: https://github.com/sixty-north/venv-management/actions?workflow=CI
:alt: CI Status
.. image:: https://readthedocs.org/projects/venv-management/badge/?version=latest
:target: https://venv-management.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
This document gives an overview. For more detail see the `documentation <https://venv-management.readthedocs.io/en/latest/?badge=latest>`_.
Prerequisites
=============
A virtualenvwrapper installation must have been installed and be available in a shell and configured
at shell start-up in the appropriate ``rc`` file (*e.g.* ``.bashrc``, but the documentation for more
details and options). The following virtualenvwrapper implementations have been tested:
* `virtualenvwrapper <https://pypi.org/project/virtualenvwrapper/>`_
* `virtualenv-sh <https://pypi.org/project/virtualenv-sh/>`_
* `pyenv-virtualenv <https://github.com/pyenv/pyenv-virtualenv>`_
Possibly in future we will also support:
* `pew <https://pypi.org/project/pew/>`_
.. inclusion-begin-installation-marker-do-not-remove
Installation
------------
Install from PyPI using ``pip``::
$ pip install venv-management
.. inclusion-end-installation-marker-do-not-remove
Synopsis
--------
Use the Python functions exported by the ``venv_management`` package 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.
.. inclusion-begin-configuration-marker-do-not-remove
Shell selection
---------------
This ``venv-management`` package delegates most operations to one of the ``virtualenvwrapper`` or
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 default ``venv-management`` attempts to use the current user's preferred shell by examining the
``$SHELL`` environment variable. This can be overridden by setting the ``$VENV_MANAGEMENT_SHELL``
variable with a shell executable name or the path to a shell executable, for example::
export VENV_MANAGEMENT_SHELL=zsh
If neither ``$SHELL`` nor ``$VENV_MANAGEMENT_SHELL`` are set, an attempt to use ``bash`` will be
made.
Shell configuration
-------------------
The selected shell must be configured to make the ``virtualenvwrapper`` commands available. By
default, ``venv-management`` will source the ``rc`` file corresponding to the selected shell, for
example ``.bashrc`` for ``bash``, ``.zshrc`` for ``zsh``, and so on, on the basis that
``virtualenvwrapper`` initialization is often performed from these files. If the ``rc`` file for
the selected shell can only be usefully sourced in an interactive shell, set
``VENV_MANAGEMENT_INTERACTIVE_SHELL`` to ``yes``::
export VENV_MANAGEMENT_INTERACTIVE_SHELL=yes
Should you wish to specify a different file for shell configuration, provide its path in the
``VENV_MANAGEMENT_SETUP_FILEPATH`` environment variable. For example, since ``.bashrc`` may return
immediately in non-interactive shells, and only login shells source ``.profile`` on 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.sh
and then source this file in turn from, say, ``.bashrc``.
If the ``VENV_MANAGEMENT_USE_SETUP`` variable is set to ``yes``, the script whose filepath is
specified in the ``VENV_MANAGEMENT_SETUP_FILEPATH`` variable will be as necessary before executing
the commands run by this package::
export VENV_MANAGEMENT_USE_SETUP=yes
export VENV_MANAGEMENT_SETUP_FILEPATH=$HOME/.venvwraprc
You can also source this custom config file in a shell-specific ``rc`` file using the ``source`` or ``.`` command,
so that ``virtualenvwrapper`` could be used in interactive shells.
Driver preference
-----------------
If you have multiple virtualenv wrapper implementations installed, you can specify the order in
which they will be tried with the ``VENV_MANAGEMENT_PREFERRED_DRIVERS`` environment variable. The
first working implementation will be used::
export VENV_MANAGEMENT_PREFERRED_DRIVERS="virtualenvwrapper,virtualenv-sh"
.. inclusion-end-configuration-marker-do-not-remove
Release process
===============
Upgrade the version::
$ bumpversion <major | minor | patch>
Push the tagged commit into the repository together with the tag. You can find the latest tag using the
``git tag`` command or find and fill in the most recent tag with ``git describe``::
$ git push --atomic origin master $(git describe --abbrev=0 --tags)
Create the source and the binary distribution (outputs in the ``dist`` directory)::
$ python setup.py sdist bdist_wheel
Remove old versions in the ``dist`` directory 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 AS
Permission 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/sixty-north/venv-management",
"name": "venv-management",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "virtual-environment",
"author": "Sixty North AS",
"author_email": "systems+venv_management@sixty-north.com",
"download_url": "https://files.pythonhosted.org/packages/07/1c/be9a45b4cd5628871797971fc6aa89bb0e86deb8bb065cfbc1980d37d69e/venv-management-2.2.1.tar.gz",
"platform": null,
"description": "===============\nVenv Management\n===============\n\nA Python package for programmatic creation and management of Python virtual environments.\n\n\n.. image:: https://github.com/rob-smallshire/renard/workflows/CI/badge.svg?branch=master\n :target: https://github.com/sixty-north/venv-management/actions?workflow=CI\n :alt: CI Status\n\n.. image:: https://readthedocs.org/projects/venv-management/badge/?version=latest\n :target: https://venv-management.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\nThis document gives an overview. For more detail see the `documentation <https://venv-management.readthedocs.io/en/latest/?badge=latest>`_.\n\n\nPrerequisites\n=============\n\nA virtualenvwrapper installation must have been installed and be available in a shell and configured\nat shell start-up in the appropriate ``rc`` file (*e.g.* ``.bashrc``, but the documentation for more\ndetails and options). The following virtualenvwrapper implementations have been tested:\n\n * `virtualenvwrapper <https://pypi.org/project/virtualenvwrapper/>`_\n * `virtualenv-sh <https://pypi.org/project/virtualenv-sh/>`_\n * `pyenv-virtualenv <https://github.com/pyenv/pyenv-virtualenv>`_\n\nPossibly in future we will also support:\n\n * `pew <https://pypi.org/project/pew/>`_\n\n.. inclusion-begin-installation-marker-do-not-remove\n\nInstallation\n------------\n\nInstall from PyPI using ``pip``::\n\n $ pip install venv-management\n\n.. inclusion-end-installation-marker-do-not-remove\n\n\nSynopsis\n--------\n\nUse the Python functions exported by the ``venv_management`` package to create, enumerate,\ninterrogate, and destroy virtual environments::\n\n >>> make_virtual_env(\"myenv\")\n >>> python_version(env_path)\n '3.10.0'\n >>> list_virtual_envs()\n ['myenv']\n >>> env_path = resolve_virtual_env(\"myenv\")\n >>> env_path\n /home/user/.virtualenvs/myenv\n >>> remove_virtual_env(\"myenv\")\n >>>\n\nRefer to the documentation to see all available functions.\n\n.. inclusion-begin-configuration-marker-do-not-remove\n\nShell selection\n---------------\n\nThis ``venv-management`` package delegates most operations to one of the ``virtualenvwrapper`` or\nequivalent tools, which are implemented using shell scripts and shell functions. In order to invoke\nthese scripts and functions successfully the shell environment mush have been correctly configured.\nBy default ``venv-management`` attempts to use the current user's preferred shell by examining the\n``$SHELL`` environment variable. This can be overridden by setting the ``$VENV_MANAGEMENT_SHELL``\nvariable with a shell executable name or the path to a shell executable, for example::\n\n export VENV_MANAGEMENT_SHELL=zsh\n\nIf neither ``$SHELL`` nor ``$VENV_MANAGEMENT_SHELL`` are set, an attempt to use ``bash`` will be\nmade.\n\n\nShell configuration\n-------------------\n\nThe selected shell must be configured to make the ``virtualenvwrapper`` commands available. By\ndefault, ``venv-management`` will source the ``rc`` file corresponding to the selected shell, for\nexample ``.bashrc`` for ``bash``, ``.zshrc`` for ``zsh``, and so on, on the basis that\n``virtualenvwrapper`` initialization is often performed from these files. If the ``rc`` file for\nthe selected shell can only be usefully sourced in an interactive shell, set\n``VENV_MANAGEMENT_INTERACTIVE_SHELL`` to ``yes``::\n\n\n export VENV_MANAGEMENT_INTERACTIVE_SHELL=yes\n\nShould you wish to specify a different file for shell configuration, provide its path in the\n``VENV_MANAGEMENT_SETUP_FILEPATH`` environment variable. For example, since ``.bashrc`` may return\nimmediately in non-interactive shells, and only login shells source ``.profile`` on start-up,\nyou may want to set up virtualenvwrapper or an equivalent in in a separate file, in this example\ncalled ``.venvwraprc``::\n\n # .venvwraprc\n source /usr/local/bin/virtualenvwrapper.sh\n\nand then source this file in turn from, say, ``.bashrc``.\n\nIf the ``VENV_MANAGEMENT_USE_SETUP`` variable is set to ``yes``, the script whose filepath is\nspecified in the ``VENV_MANAGEMENT_SETUP_FILEPATH`` variable will be as necessary before executing\nthe commands run by this package::\n\n export VENV_MANAGEMENT_USE_SETUP=yes\n export VENV_MANAGEMENT_SETUP_FILEPATH=$HOME/.venvwraprc\n\nYou can also source this custom config file in a shell-specific ``rc`` file using the ``source`` or ``.`` command,\nso that ``virtualenvwrapper`` could be used in interactive shells.\n\nDriver preference\n-----------------\n\nIf you have multiple virtualenv wrapper implementations installed, you can specify the order in\nwhich they will be tried with the ``VENV_MANAGEMENT_PREFERRED_DRIVERS`` environment variable. The\nfirst working implementation will be used::\n\n export VENV_MANAGEMENT_PREFERRED_DRIVERS=\"virtualenvwrapper,virtualenv-sh\"\n\n.. inclusion-end-configuration-marker-do-not-remove\n\n\nRelease process\n===============\n\n\nUpgrade the version::\n\n $ bumpversion <major | minor | patch>\n\nPush the tagged commit into the repository together with the tag. You can find the latest tag using the\n``git tag`` command or find and fill in the most recent tag with ``git describe``::\n\n $ git push --atomic origin master $(git describe --abbrev=0 --tags)\n\nCreate the source and the binary distribution (outputs in the ``dist`` directory)::\n\n $ python setup.py sdist bdist_wheel\n\nRemove old versions in the ``dist`` directory and use the following command to upload its contents to PyPI::\n\n $ twine upload dist/* --config-file=<path/to/file/with/credentials.pypirc>\n\n\nCopyright 2021 Sixty North AS\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A Python package for programmatic creation of Python virtual environments",
"version": "2.2.1",
"project_urls": {
"Homepage": "https://github.com/sixty-north/venv-management"
},
"split_keywords": [
"virtual-environment"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2f7f91a16e09e3473c55b9e611fa9f3522aa83faae1d4b0d61a9dd9550d0e3e1",
"md5": "6bb3c6f9ad320707f53f5cb9910a319c",
"sha256": "12efdb82f86edfdd4a95261cdb5dcca5c1aa81135a23613d8a3aa1846e7c45dc"
},
"downloads": -1,
"filename": "venv_management-2.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6bb3c6f9ad320707f53f5cb9910a319c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 23867,
"upload_time": "2023-10-23T09:03:48",
"upload_time_iso_8601": "2023-10-23T09:03:48.706760Z",
"url": "https://files.pythonhosted.org/packages/2f/7f/91a16e09e3473c55b9e611fa9f3522aa83faae1d4b0d61a9dd9550d0e3e1/venv_management-2.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "071cbe9a45b4cd5628871797971fc6aa89bb0e86deb8bb065cfbc1980d37d69e",
"md5": "441c9127c23d8166b0af6d2899945839",
"sha256": "88317042ae00d097543eff9608a22ace51c4af7ecc83b0608238bf5b0038a918"
},
"downloads": -1,
"filename": "venv-management-2.2.1.tar.gz",
"has_sig": false,
"md5_digest": "441c9127c23d8166b0af6d2899945839",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19331,
"upload_time": "2023-10-23T09:03:49",
"upload_time_iso_8601": "2023-10-23T09:03:49.847949Z",
"url": "https://files.pythonhosted.org/packages/07/1c/be9a45b4cd5628871797971fc6aa89bb0e86deb8bb065cfbc1980d37d69e/venv-management-2.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-23 09:03:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sixty-north",
"github_project": "venv-management",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "venv-management"
}