mork package¶
-
class
mork.
VirtualEnv
(venv_dir)¶ Bases:
object
-
activated
(include_extras=True, extra_dists=[])¶ A context manager which activates the virtualenv.
Parameters: extra_dists (list) – Paths added to the context after the virtualenv is activated. - This context manager sets the following environment variables:
- PYTHONUSERBASE
- VIRTUAL_ENV
- PYTHONIOENCODING
- PYTHONDONTWRITEBYTECODE
In addition, it activates the virtualenv inline by calling activate_this.py.
-
base_paths
¶
-
classmethod
filter_sources
(requirement, sources)¶
-
classmethod
from_project_path
(path)¶ Utility for finding a virtualenv location based on a project path
-
get_distributions
()¶ Retrives the distributions installed on the library path of the virtualenv
Returns: A set of distributions found on the library path Return type: iterator
-
get_monkeypatched_pathset
()¶ Returns a monkeypatched UninstallPathset for using to uninstall packages from the virtualenv
Returns: A patched UninstallPathset which enables uninstallation of venv packages Return type: pip._internal.req.req_uninstall.UninstallPathset
-
get_setup_install_args
(pkgname, setup_py, develop=False)¶ Get setup.py install args for installing the supplied package in the virtualenv
Parameters: Returns: The installation arguments to pass to the interpreter when installing
Return type:
-
classmethod
get_sys_path
(python_path)¶ Get the
sys.path
data for a given python executable.Parameters: python_path (str) – Path to a specific python executable. Returns: The system path information for that python runtime. Return type: list
-
get_working_set
()¶ Retrieve the working set of installed packages for the virtualenv.
Returns: The working set for the virtualenv Return type: pkg_resources.WorkingSet
-
classmethod
get_workon_home
()¶
-
initial_working_set
¶
-
install
(req, editable=False, sources=[])¶ Install a package into the virtualenv
Parameters: Returns: A return code, 0 if successful
Return type:
-
is_installed
(pkgname)¶ Given a package name, returns whether it is installed in the virtual environment
Parameters: pkgname (str) – The name of a package Returns: Whether the supplied package is installed in the environment Return type: bool
-
libdir
¶
-
classmethod
normalize_path
(path)¶
-
paths
¶
-
python
¶ Path to the virtualenv python
-
python_version
¶
-
pyversion
¶
-
classmethod
resolve_dist
(dist, working_set)¶ Given a local distribution and a working set, returns all dependencies from the set.
Parameters: - dist (
pkg_resources.Distribution
) – A single distribution to find the dependencies of - working_set (
pkg_resources.WorkingSet
) – A working set to search for all packages
Returns: A set of distributions which the package depends on, including the package
Return type: set(
pkg_resources.Distribution
)- dist (
-
run
(cmd, cwd='.')¶ Run a command with
Popen
in the context of the virtualenvParameters: Returns: A finished command object
Return type:
-
run_py
(cmd, cwd='.')¶ Run a python command in the virtualenv context.
Parameters: Returns: A finished command object
Return type:
-
classmethod
safe_import
(name)¶ Helper utility for reimporting previously imported modules while inside the venv
-
script_basedir
¶ Path to the virtualenv scripts dir
-
scripts_dir
¶
-
setuptools_install
(chdir_to, pkg_name, setup_py_path=None, editable=False)¶ Install an sdist or an editable package into the virtualenv
Parameters:
-
sys_path
¶ The system path inside the virtualenv
Returns: The sys.path
from the virtualenvReturn type: list
-
sys_prefix
¶ The prefix run inside the context of the virtualenv
Returns: The python prefix inside the virtualenv Return type: sys.prefix
-
system_paths
¶
-
uninstall
(pkgname, *args, **kwargs)¶ A context manager which allows uninstallation of packages from the virtualenv
Parameters: pkgname (str) – The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=False) as uninstaller: cleaned = uninstaller.paths >>> if cleaned: print("uninstalled packages: %s" % cleaned)
-