invirtualenv.virtualenv module

Functions for creating and managing python virtual environments

invirtualenv.virtualenv.build_virtualenv(name, directory, python_interpreter=None, user=None, verbose=False)

Build a virtualenv in a directory

Parameters:
  • name (str) – Name of the virtualenv to create
  • directory (str) – Directory to create the virtualenv in
  • python_interpreter (str, optional) – Python interpreter to provide in the virtualenv, defaults to the interpreter that is running the virtualenv command
  • verbose (bool) – If True, provides status output while running.
Returns:

Full path to the root of the virtualenv directory

Return type:

str

Raises:

BuildException – The Virtualenv build failed

invirtualenv.virtualenv.default_virtualenv_directory()

Get the default virtualenv directory for the current system/platform

Returns:The path to the default virtualenv directory
Return type:str
invirtualenv.virtualenv.install_requirements(requirements, virtualenv, user=None, upgrade=False, verbose=False, pip_version=None, use_index=True, use_local_wheels=False)

Open one or more requirements files and run pip -r to install them

Parameters:
  • requirements (str) – Filename containing requirements
  • virtualenv (str) – Full path to the virtualenv to install into
  • user (str, optional) – The user:group to run the install as
  • upgrade (bool) – If True, tell pip to upgrade when running the install. Default=False
  • verbose (bool) – If True, provides status output while running.
  • pip_version (str, optional) – Install the requirements with the specified version of pip
  • use_index (bool, optional) – Allow pip to use an external index Default=True
  • use_local_wheels (bool, optional) – Install wheels from local directory Default=False
invirtualenv.virtualenv.remove_virtualenv(name, directory=None)

Remove a virtualenv from a directory :param name: :param directory: :return:

invirtualenv.virtualenv.upgrade_package_tools(virtualenv_directory, verbose=False)

Upgrade the packages used to install/build packages in the virtualenv :param virtualenv_directory: The directory that contains the virtualenv :type virtualenv_directory: str

invirtualenv.virtualenv.virtualenv_bin_file_hashes(virtualenv_dir)

Calculate a hash of all files in the virtualenv bin directory :param virtualenv_dir: The root directory of the virtualenv to operate on :type virtualenv_dir: str

Returns:Key = Filename, value = hash
Return type:dict
invirtualenv.virtualenv.virtualenv_command(install_virtualenv=False)

Return the virtualenv command

Parameters:install_virtualenv (bool) – If True, Install virtualenv if necessary. default=False
Returns:Path to the virtualenv command
Return type:str