module installhelper.install_venv_helper

Inheritance diagram of pymyinstall.installhelper.install_venv_helper

Short summary

module pymyinstall.installhelper.install_venv_helper

Helpers for virtualenv

source on GitHub

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_cmd_path

run a script knowing python path, it does not raise an exception.

run_venv_script

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

venv_install

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

Documentation

Helpers for virtualenv

source on GitHub

exception pymyinstall.installhelper.install_venv_helper.VirtualEnvError

Bases: RuntimeError

exception raised by the function implemented in this file

source on GitHub

pymyinstall.installhelper.install_venv_helper.build_venv_cmd(params, posparams)

builds the command line for virtual env

Parameters:
  • params – dictionary of parameters

  • posparams – positional arguments

Returns:

string

source on GitHub

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)

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

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)

source on GitHub

pymyinstall.installhelper.install_venv_helper.run_cmd_path(python_path, script, fLOG=<built-in function print>, file=False, is_cmd=False, **kwargs)

run a script knowing python path, it does not raise an exception.

Parameters:
  • python_path – python path

  • script – script as a string (not a file) or command line if is_cmd is True

  • 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

  • kwargs – extra parameters

Returns:

output, error

source on GitHub

pymyinstall.installhelper.install_venv_helper.run_venv_script(venv, script, fLOG=<built-in function print>, file=False, is_cmd=False)

run a script on a virtual 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

source on GitHub

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

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

source on GitHub