venvmod.modulefile module

venvmod.modulefile.get_module_file_directory(venv_name: str) pathlib.Path[source]

Gets the modulefile directory

Parameters

venv_name (str or Path) – Path to virtual env

Returns

Path prepend by venv_name

Return type

Path

venvmod.modulefile.add_command(filename: pathlib.Path, line: str)[source]

Appends a command to a modulefile

Parameters
  • filename (Path) – File to modify

  • line (str) – Line to append

venvmod.modulefile.get_version() str[source]

Gets modulefile version

Returns

version as ‘x.y.z’, ‘0.0.0’ if not found

Return type

str

venvmod.modulefile.get_version_list(index: int = 0) List[int][source]

Gets version as list

Parameters

index (int, optional) – index in version, by default 0

Returns

version numbers or version number if index > 0

Return type

List[int] or int

class venvmod.modulefile.ModuleInstaller(version_or_path: str, install_prefix: str, cache_directory: str)[source]

Bases: object

Class to install Environment Module.

Methods

run([verbose, do_raise])

run installer

__init__(version_or_path: str, install_prefix: str, cache_directory: str) None[source]
run(verbose: bool = False, do_raise: bool = True) int[source]

run installer

Parameters
  • verbose (bool, optional) – True to enable verbosity, by default False

  • do_raise (bool, optional) – True to raise if fails, by default True

Returns

return code

Return type

int

venvmod.modulefile.upgrade_modulefile(virtual_env: pathlib.Path, module_prefix: pathlib.Path) int[source]

Upgrade modulefile in venv

Parameters
  • virtual_env (Path) – Path to virtual env

  • module_prefix (Path) – Modulefile install prefix

Returns

return code

Return type

int

venvmod.modulefile.create_modulefile(virtual_env: pathlib.Path, module_name: str = 'venvmod', module_category: Optional[str] = None, log_load: str = '') int[source]

Creates a modulefile.

Parameters
  • module_name (str) – Name of the module to create

  • module_directory (Path) – Module directory

  • module_category (str, optional) – Module category, by default None

  • log_load (str, optional) – Loag edited at load, by default “”

venvmod.modulefile.upgrade_venv(virtual_env: pathlib.Path)[source]

Ugrade virtual env with modulefile at activate and deactivate.

Parameters

env_prefix (Path) – Path to environment.

Raises
  • AssertionError – If the activate script is not found.

  • AssertionError – If the module is already loaded frome the script but from another modulefile directory.