Installers

import knots_hub.installer

various software that can be installed on the user system

class knots_hub.installer.BaseVendorInstaller(version: int, install_dir: Path, dirs_to_make: list[Path] | None = None)

An abstract class defining how to install an external program.

An installation directory is always provided but might not be used by the developer to store the actual program. However the directory is still used to specify that the program was installed.

The version is an arbitrary text that is used in a binary fashion, meaning or the version installed on disk is similar to the instance, or both are different then the instance is always prioritized. In theory an user can’t have a more recent version on disk than the one listed in the config.

__init__(version: int, install_dir: Path, dirs_to_make: list[Path] | None = None)
property dirs_to_make: list[Path]

List of filesystem path to directory that must be created on installation.

abstract install()

Arbitrary process to install a program.

Developer is responsible for calling set_install_completed() at the end or to check if an existing install exist.

property install_dir: Path

Filesystem path to a directory that may not exist and used to install the vendor program to.

property is_installed: bool

Returns: True if there is already an active install else False.

make_install_directories()

Create all the directories used for installation, given by the user.

Usually manually called in the install method subclass override.

abstract classmethod name() str

Unique installer name across all installer subclasses.

set_install_completed()

To call at the end of the install() method.

property time_installed: float | None

Returns: time in seconds since the Epoch at which the program was last installed, or None if never installed.

abstract uninstall()

Arbitrary process to uninstall a program.

Developer is responsible for removing the “install file”.

property version: int

Current version of the installer configuration.

property version_installed: int | None

Returns: a number that is incremented everytime an installer config change and allow to check if an existing installation need updating.

class knots_hub.installer.HubInstallersList(content: List[Tuple[str, Path]])

A mapping of “hub version”: “hub filesystem path” listing all the “installer” available.

Each path can either be a directory to copy or a zip file to extract.

The user is reponsible of ensuring the paths submitted are valid hub installation, i.e. packaged as self-isolated executable.

__init__(content: List[Tuple[str, Path]])
classmethod from_file(path: Path) HubInstallersList

Get an instance from a serialized json file.

Parameters:

path – filesystem path to an existing json file.

get_path(version: str) Path

Get the installer path matching the given version.

property last_path: Path

Returns: filesystem path to a directory or existing zip file that should exist.

property last_version: str
class knots_hub.installer.RezVendorInstaller(python_version: str, rez_version: str, version: int, install_dir: Path, dirs_to_make: list[Path] | None = None)
__init__(python_version: str, rez_version: str, version: int, install_dir: Path, dirs_to_make: list[Path] | None = None)
install()

Arbitrary process to install a program.

Developer is responsible for calling set_install_completed() at the end or to check if an existing install exist.

classmethod name() str

Unique installer name across all installer subclasses.

uninstall()

Arbitrary process to uninstall a program.

Developer is responsible for removing the “install file”.

knots_hub.installer.create_exe_shortcut(shortcut_dir: Path, exe_path: Path, dry_run: bool = False) Path

Create a file that link to the given executable.

Parameters:
  • shortcut_dir – filesystem path to an existing directory.

  • exe_path – executable file the shortcut links to.

  • dry_run – just return without actually creating files on disk

knots_hub.installer.install_hub(install_src_path: Path, filesystem: HubInstallFilesystem) Path
Parameters:
  • install_src_path – filesystem path to an existing directory or existing zip file.

  • filesystem – determine where to install

Returns:

filesystem path to the installed hub executable

knots_hub.installer.is_hub_up_to_date(installer_list: HubInstallersList | None) bool

Return True if the current hub version doesn’t need update.

knots_hub.installer.read_vendor_installers_from_file(file_path: Path) List[BaseVendorInstaller]

Get a list of installer from a serialized representation.

The representation is a simple dict:

{
    "installerName": {
        "version": 1,
        "firstInstallerKwarg": "3.10.11",
        "secondInstallerKwarg": "2.109.0",
        ...
    },
    ...
}
Parameters:

file_path – filesystem path to an existing json file.

Returns:

list of unique installer instances (no subclass duplicates).

knots_hub.installer.uninstall_hub(filesystem: HubInstallFilesystem)

Exit the hub and uninstall it from the filesystem.

Parameters:

filesystem – determine what filesystem data to uninstall

knots_hub.installer.update_hub(update_src_path: Path, filesystem: HubInstallFilesystem) Path
Parameters:
  • update_src_path – filesystem path to an existing directory or existing zip file.

  • filesystem – determine where to update

Returns:

filesystem path to the updated hub executable