formelsammlung.venv_utils module

formelsammlung.venv_utils.get_venv_path()[source]

Get path to the venv from where the python executable runs.

Raises

FileNotFoundError – when no calling venv can be detected.

Return type

Path

Returns

Return venv path

formelsammlung.venv_utils.get_venv_bin_dir(venv_path)[source]

Return path to bin/Scripts dir of given venv.

Parameters

venv_path (Union[str, Path]) – Path to venv

Raises

FileNotFoundError – when no bin/Scripts dir can be found for given venv.

Return type

Path

Returns

Path to bin/Scripts dir

formelsammlung.venv_utils.get_venv_tmp_dir(venv_path, search_tmp_dirs=None, create_if_missing=False, create_dir_name=None)[source]

Return path to tmp/temp dir of given venv.

Parameters
  • venv_path (Union[str, Path]) – Path to venv

  • search_tmp_dirs (Optional[Tuple[str]]) – List of temp dir names to look for; defaults to (“tmp”, “temp”, “.tmp”, “.temp”)

  • create_if_missing (bool) – Create a temp dir in the given venv if non exists; defaults to False

  • create_dir_name (Optional[str]) – Name of the venv to create; defaults to tmp

Raises

FileNotFoundError – when no tmp/temp dir can be found for given venv.

Return type

Path

Returns

Path to tmp/temp dir

formelsammlung.venv_utils.get_venv_site_packages_dir(venv_path)[source]

Return path to site-packages dir of given venv.

Parameters

venv_path (Union[str, Path]) – Path to venv

Raises

FileNotFoundError – when no site-packages dir can be found for given venv.

Return type

Path

Returns

Path to site-packages dir

formelsammlung.venv_utils.where_installed(program)[source]

Find installation locations for given program.

Return exit code and locations based on found installation places. Search in current venv and globally.

Exit codes:

  • 0 = nowhere

  • 1 = venv

  • 2 = global

  • 3 = both

Parameters

program (str) – Program to search

Return type

Tuple[int, Optional[str], Optional[str]]

Returns

Exit code, venv executable path, glob executable path