stouputils.installer.linux module#

Installer module for Linux/macOS specific functions.

Provides Linux/macOS specific implementations for checking admin privileges, determining appropriate installation paths (global/local), and suggesting how to add directories to the system’s PATH environment variable.

add_to_path_linux(install_path: str) bool[source]#

Suggest how to add install_path to PATH on Linux.

Checks the current shell and provides instructions for adding the path to the appropriate configuration file (e.g., .bashrc, .zshrc, config.fish).

Parameters:

install_path (str) – The path to add to the PATH environment variable.

Returns:

True if instructions were provided, False otherwise (e.g., unknown shell).

Return type:

bool

check_admin_linux() bool[source]#

Check if the script is running with root privileges on Linux/macOS.

Returns:

True if the effective user ID is 0 (root), False otherwise.

Return type:

bool

get_install_path_linux(program_name: str, ask_global: int = 0, add_path: bool = True, append_to_path: str = '', default_global: str = '/usr/local/bin') str[source]#

Get the installation path for the program on Linux/macOS.

Parameters:
  • program_name (str) – The name of the program to install.

  • ask_global (int) – 0 = ask for anything, 1 = install globally, 2 = install locally

  • add_path (bool) – Whether to add the program to the PATH environment variable. (Only if installed globally)

  • append_to_path (str) – String to append to the installation path when adding to PATH. (ex: “bin” if executables are in the bin folder)

  • default_global (str) – The default global installation path. (Default is “/usr/local/bin” which is the most common location for executables on Linux/macOS, could be “/opt” or any other directory)

Returns:

The chosen installation path, or an empty string if installation is cancelled.

Return type:

str