stouputils.installer.main module#

Main module of the installer subpackage for stouputils.

Provides functions for installing programs from local zip files or URLs. It handles downloading, extracting, and setting up programs in a platform-agnostic way.

This module contains the core installation functions that are used by both the Windows and Linux/macOS specific modules.

extract_archive(
extraction_path: str,
temp_dir: str,
extract_func: Callable[[str], None],
get_file_list_func: Callable[[], list[str]],
) None[source]#

Helper function to extract archive files with consistent handling.

Parameters:
  • extraction_path (str) – Path where files should be extracted

  • temp_dir (str) – Temporary directory for intermediate extraction

  • extract_func (Callable[[str], None]) – Function to extract the archive

  • get_file_list_func (Callable[[], list[str]]) – Function to get the list of files in the archive

get_install_path(
program_name: str,
platform_str: str = 'Linux',
ask_global: int = 0,
add_path: bool = True,
append_to_path: str = '',
) str[source]#

Get the installation path for the program on the current platform.

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

  • platform_str (str) – The platform to get the installation path for.

  • ask_global (int) – Whether to ask the user for a path, 0 = ask, 1 = install globally, 2 = install locally.

  • add_path (bool) – Whether to add the program to the PATH environment variable.

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

Returns:

The installation path for the program.

Return type:

str

add_to_path(
install_path: str,
platform_str: str = 'Linux',
) bool[source]#

Add the program to the PATH environment variable.

Parameters:
  • install_path (str) – The path to the program to add to the PATH environment variable.

  • platform_str (str) – The platform you are running on (ex: “Windows”, “Linux”, “Darwin”, …), we use this to determine the installation path if not provided.

Returns:

True if add to PATH was successful, False otherwise.

Return type:

bool

install_program(
input_path: str,
install_path: str = '',
platform_str: str = 'Linux',
program_name: str = '',
add_path: bool = True,
append_to_path: str = '',
) bool[source]#

Install a program to a specific path from a local zip file or URL.

Parameters:
  • input_path (str) – Path to a zip file or a download URL.

  • install_path (str) – The directory to extract the program into, we ask user for a path if not provided.

  • platform_str (str) – The platform you are running on (ex: “Windows”, “Linux”, “Darwin”, …), we use this to determine the installation path if not provided.

  • add_path (bool) – Whether to add the program to the PATH environment variable.

  • program_name (str) – Override the program name, we get it from the input path if not provided.

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

Returns:

True if installation was successful, False otherwise.

Return type:

bool