Module markov.common.utils.package_utils

Functions

def create_conda_environment(path: str, python_version) ‑> Optional[str]

Creates a conda environment at the given path using the given python version. Note that we only guarantee the minor python version to be the same as the given python version as not all python versions are available as conda packages

Args

path
The path of the conda environment you want to create
python_version
The version of python you want to install (only minor python version is guaranteed

Returns

The prefix of the conda environment created (helps locate the conda environment in the system) Side effects: A conda environment at the specified path with the given python version

def create_virtualenv_environment(path: str) ‑> str

Creates a virtualenv environment at the given path using the active python version in

Args

path : str
The path of the virtualenv to be created. Note: If the directories in the path do not exist,

they will be created.

Returns

Path to the created virtualenv environment Side effects: A virtualenv environment is created (with pip installed)

Raises

ValueError if base_directory_path is not a valid path in the FileSystem.

def get_installed_modules() ‑> Dict

Gets all the installed modules in the current environment.

Returns

Dict[str, str]
Package_name: Package_version
def install_markovml_package_using_pip(path_to_pip_executable: str)

Installs the markovml package using pip.

Args

path_to_pip_executable : str
The path to the pip executable which will be used to install the given packages

Returns

None Side effects: Markovml package get installed using the given pip executable

Raises

ValueError if path_to_pip_executable does not exist
Note
We do not validate the "packages" dictionary.Other runtime errors would occur if there

are issues in the given packages dictionary (like incompatible version etc.)

def install_packages_using_pip(path_to_pip_executable: str, packages: Dict[str, str])

Installs the given packages using pip.

Args

path_to_pip_executable : str
The path to the pip executable which will be used to install the given packages
packages : Dict[str, str]
Dictionary of the packages to be installed where

Key = Package name Value = Package version

Returns

None Side effects: Given Packages get installed using the given pip executable

Raises

ValueError if path_to_pip_executable does not exist
Note
We do not validate the "packages" dictionary.Other runtime errors would occur if there

are issues in the given packages dictionary (like incompatible version etc.)

def install_requirements_file_using_pip(path_to_pip_executable: str, path_to_requirements_file: str, stdout=None, stderr=None, return_exit_status: bool = False) ‑> Optional[bool]

Installs the given requirements file using pip.

Args

path_to_pip_executable : str
The path to the pip executable which will be used to install the given packages
path_to_requirements_file : str
The path to the requirements file that needs to be installed
stdout
File pointer to the file where you want the stdout of the pip command to be redirected
stderr
File pointer to the file where you want the stderr of the pip command to be redirected
return_exit_status : bool
Flag to determine whether to return exit status of the command run or not

Returns

exit_status of the command run if return_exit_status is True else None Side effects: Given packages in the given requirements file get installed using the given pip executable

Raises

ValueError if path_to_pip_executable does not exist
ValueError is path_to_requirements_file does not exist
Note
We do not validate the "requirements" file. Other runtime errors would occur if there

are issues in the given packages in the given requirements file (like incompatible version etc.)