module installhelper.install_venv_helper

Inheritance diagram of pymyinstall.installhelper.install_venv_helper

Short summary

module pymyinstall.installhelper.install_venv_helper

Helpers for virtualenv

Classes

class truncated documentation
VirtualEnvError exception raised by the function implemented in this file

Functions

function truncated documentation
build_venv_cmd builds the command line for virtual env
create_virtual_env
run_venv_script run a script on a vritual environment (the script should be simple
venv_install install a package or a list of packages in a virtual environment

Documentation

Helpers for virtualenv

exception pymyinstall.installhelper.install_venv_helper.VirtualEnvError[source]

Bases: Exception

exception raised by the function implemented in this file

pymyinstall.installhelper.install_venv_helper.build_venv_cmd(params, posparams)[source]

builds the command line for virtual env

Parameters:
  • params – dictionary of parameters
  • posparams – positional arguments
Returns:

string

pymyinstall.installhelper.install_venv_helper.create_virtual_env(where, symlinks=False, system_site_packages=False, clear=True, packages=None, fLOG=<built-in function print>, temp_folder=None)[source]

create a virtual environment

Parameters:
  • where – location of this virtual environment
  • symlinks – attempt to symlink rather than copy
  • system_site_packages – Give the virtual environment access to the system site-packages dir
  • clear – Delete the environment directory if it already exists. If not specified and the directory exists, an error is raised.
  • packages – list of packages to install (it will install module `pymyinstall <>`_).
  • fLOG – logging function
  • temp_folder – temporary folder (to download module if needed), by default <where>/download
Returns:

stand output

Example: Create a virtual environment

The following example creates a virtual environment. Packages can be added by specifying the parameter package.

from pyquickhelper.pycode import create_virtual_env
fold = "my_env"
if not os.path.exists(fold):
    os.mkdir(fold)
create_virtual_env(fold)
pymyinstall.installhelper.install_venv_helper.run_venv_script(venv, script, fLOG=<built-in function print>, file=False, is_cmd=False)[source]

run a script on a vritual environment (the script should be simple

Parameters:
  • venv – virtual environment
  • script – script as a string (not a file)
  • fLOG – logging function
  • file – is script a file or a string to execute
  • is_cmd – if True, script is a command line to run (as a list) for python executable
Returns:

output

pymyinstall.installhelper.install_venv_helper.venv_install(venv, packages, fLOG=<built-in function print>, temp_folder=None)[source]

install a package or a list of packages in a virtual environment

Parameters:
  • venv – location of the virtual environment
  • packages – a package (str) or a list of packages(list[str])
  • fLOG – logging function
  • temp_folder – temporary folder (to download module if needed), by default <where>/download
Returns:

standard output