formelsammlung.venv_utils module

formelsammlung.venv_utils.get_venv_path(raise_error=False)[source]

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

Parameters

raise_error (bool) – raise FileNotFoundError if no venv is detected. Default: False

Raises

FileNotFoundError – when no calling venv can be detected.

Return type

Optional[Path]

Returns

Return venv path or None if python is not called from a venv.

formelsammlung.venv_utils.get_venv_bin_dir(venv_path, raise_error=False)[source]

Return path to bin/Scripts dir of given venv.

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

  • raise_error (bool) – raise FileNotFoundError if no bin/Scripts dir is found. Default: False

Raises

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

Return type

Optional[Path]

Returns

Path to bin/Scripts dir or None

formelsammlung.venv_utils.get_venv_tmp_dir(venv_path, raise_error=False)[source]

Return path to tmp/temp dir of given venv.

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

  • raise_error (bool) – raise FileNotFoundError if no tmp/temp dir is found. Default: False

Raises

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

Return type

Optional[Path]

Returns

Path to tmp/temp dir or None

formelsammlung.venv_utils.get_venv_site_packages_dir(venv_path, raise_error=False)[source]

Return path to site-packages dir of given venv.

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

  • raise_error (bool) – raise FileNotFoundError if no site-packages dir is found. Default: False

Raises

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

Return type

Optional[Path]

Returns

Path to site-packages dir or None

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