Installer¶
knots_hub.installer¶
import knots_hub.installer
various software that can be installed on the user system
- class knots_hub.installer.BaseVendorInstaller(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>)¶
An abstract class defining how to install an external program.
An instance represent the configuration in which to install the 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.
- __init__(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>) None ¶
- dirs_to_make: list[Path] = <knots_hub.serializelib._Uninitialized object>¶
List of filesystem path to directory that must be created on installation.
- classmethod get_documentation() list[str] ¶
Get the documentation for the subclass as a list of lines.
- Returns:
list of lines as valid .rst syntax.
- get_hash() str ¶
Get a hash that allow to differenciate this instance against a previously installed one.
- 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.
- install_dir: Path = <knots_hub.serializelib._Uninitialized object>¶
Filesystem path to a directory that may not exist and used to install the vendor program to.
- property install_record_path: Path¶
Get the path to the file used to store metadata about the installation.
- 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.
- serialize() str ¶
Convert this instance to a serialized string representation.
- classmethod unserialize(serialized: str, context: UnserializeContext) BaseVendorInstaller ¶
Create a dataclass instance from a serialized string representation.
- Raises:
VendorNameError – if the serialized string is not corresponding to this subclass. This is a pretty common issue.
- abstract classmethod version() int ¶
The version of the installer API.
Any change in the code of the subclass imply to bump this version which should trigger an update on the user system.
- class knots_hub.installer.HubInstallRecord(installed_time: float | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>, installed_version: str | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>, installed_path: ~pathlib.Path | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>, vendors_record_paths: dict[str, ~pathlib.Path] | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>)¶
A datastructure to manipulate the metadata stored along the local hub install.
The datastructure can be serialized and unserialized from disk.
- __init__(installed_time: float | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>, installed_version: str | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>, installed_path: ~pathlib.Path | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>, vendors_record_paths: dict[str, ~pathlib.Path] | ~knots_hub.serializelib._Uninitialized = <knots_hub.serializelib._Uninitialized object>) None ¶
- installed_path: Path | _Uninitialized = <knots_hub.serializelib._Uninitialized object>¶
Filesystem path to the installation directory of the hub.
- installed_time: float | _Uninitialized = <knots_hub.serializelib._Uninitialized object>¶
Time since epoch at which the hub was last installed.
- installed_version: str | _Uninitialized = <knots_hub.serializelib._Uninitialized object>¶
Currently installed version of the hub.
- classmethod read_from_disk(path: Path) HubInstallRecord ¶
Create an instance from a serialized disk file.
- Parameters:
path – filesystem path to an existing file
- update_disk(path: Path)¶
Write this instance as a serialized disk file, updating if the file already exists.
Updating means only writing non-Uninitialized value of this instance.
- vendors_record_paths: dict[str, Path] | _Uninitialized = <knots_hub.serializelib._Uninitialized object>¶
A mapping of vendor names installed, and their vendor installation record path.
- write_to_disk(path: Path)¶
Write this instance as a serialized disk file.
- class knots_hub.installer.RezVendorInstaller(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>, python_version: str = <knots_hub.serializelib._Uninitialized object>, rez_version: str = <knots_hub.serializelib._Uninitialized object>)¶
Install rez at the given location. See https://rez.readthedocs.io/en/stable/
- __init__(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>, python_version: str = <knots_hub.serializelib._Uninitialized object>, rez_version: str = <knots_hub.serializelib._Uninitialized object>) None ¶
- classmethod get_documentation() list[str] ¶
Get the documentation for the subclass as a list of lines.
- Returns:
list of lines as valid .rst syntax.
- 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.
- python_version: str = <knots_hub.serializelib._Uninitialized object>¶
- rez_version: str = <knots_hub.serializelib._Uninitialized object>¶
- classmethod version() int ¶
The version of the installer API.
Any change in the code of the subclass imply to bump this version which should trigger an update on the user system.
- class knots_hub.installer.VendorInstallRecord(name: str = <knots_hub.serializelib._Uninitialized object>, installed_time: float = <knots_hub.serializelib._Uninitialized object>, install_hash: str = <knots_hub.serializelib._Uninitialized object>, installed_path: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, extra_paths: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>)¶
A datastructure to record how a vendor was installed on the local system.
The datastructure can be serialized and unserialized from disk.
- __init__(name: str = <knots_hub.serializelib._Uninitialized object>, installed_time: float = <knots_hub.serializelib._Uninitialized object>, install_hash: str = <knots_hub.serializelib._Uninitialized object>, installed_path: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, extra_paths: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>) None ¶
- extra_paths: list[Path] = <knots_hub.serializelib._Uninitialized object>¶
A list of extra paths created for the install of the vendor.
They need to be removed on uninstallation.
- install_hash: str = <knots_hub.serializelib._Uninitialized object>¶
A hash to validate if the current install is up to date.
- installed_path: Path = <knots_hub.serializelib._Uninitialized object>¶
Filesystem path to the installation directory of the vendor.
- installed_time: float = <knots_hub.serializelib._Uninitialized object>¶
Time since epoch at which the vendor was last installed.
- name: str = <knots_hub.serializelib._Uninitialized object>¶
Name of the vendor that is installed.
- classmethod read_from_disk(path: Path) VendorInstallRecord ¶
Create an instance from a serialized disk file.
- Parameters:
path – filesystem path to an existing file
- update_disk(path: Path)¶
Write this instance as a serialized disk file, updating if the file already exists.
Updating means only writing non-Uninitialized value of this instance.
- write_to_disk(path: Path)¶
Write this instance as a serialized disk file.
- knots_hub.installer.get_hub_local_executable(filesystem: HubLocalFilesystem) Path | None ¶
Find the filesystem path to the locally installed hub executable file.
- Parameters:
filesystem – collection of paths for storing runtime data
- Returns:
filesystem path to an existing file or None if not found.
- knots_hub.installer.install_hub(install_src_path: Path, install_dst_path: Path, installed_version: str, hubrecord_path: Path) Path ¶
- Parameters:
install_src_path – filesystem path to a directory which correspond to the new hub to install.
install_dst_path – filesystem path to the directory location to install the hub to.
installed_version – the hub version that is being installed
hubrecord_path – filesystem path the HubInstallRecord file
- Returns:
filesystem path to the installed hub executable
- knots_hub.installer.install_vendor(vendor: BaseVendorInstaller, record_path: Path) bool ¶
Install OR update the vendor as configured by the user.
- Parameters:
vendor – the vendor installer instance to install/update.
record_path – filesystem path to a file that may exist and should record the last and future vendor installation configuration.
- knots_hub.installer.is_hub_up_to_date(installer: HubInstallerConfig | None, filesystem: HubLocalFilesystem) bool ¶
Return True if the current hub version doesn’t need update.
- Parameters:
installer – optional expected configuration of the hub installation
filesystem – collection of paths for storing runtime data
- knots_hub.installer.read_vendor_installer_from_file(file_path: Path) list[BaseVendorInstaller] ¶
Get the vendor installers serialized in the given file.
- Parameters:
file_path – filesystem path to an existing json file.
- Returns:
list of corresponding instances.
- knots_hub.installer.uninstall_vendor(record_file: VendorInstallRecord)¶
Uninstall the previously installed vendor as recorded by the given file.
knots_hub.installer.vendors¶
import knots_hub.installer.installer.vendors
various external software that can be installed on the user system
- class knots_hub.installer.vendors.BaseVendorInstaller(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>)¶
An abstract class defining how to install an external program.
An instance represent the configuration in which to install the 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.
- __init__(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>) None ¶
- dirs_to_make: list[Path] = <knots_hub.serializelib._Uninitialized object>¶
List of filesystem path to directory that must be created on installation.
- classmethod get_documentation() list[str] ¶
Get the documentation for the subclass as a list of lines.
- Returns:
list of lines as valid .rst syntax.
- get_hash() str ¶
Get a hash that allow to differenciate this instance against a previously installed one.
- 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.
- install_dir: Path = <knots_hub.serializelib._Uninitialized object>¶
Filesystem path to a directory that may not exist and used to install the vendor program to.
- property install_record_path: Path¶
Get the path to the file used to store metadata about the installation.
- 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.
- serialize() str ¶
Convert this instance to a serialized string representation.
- classmethod unserialize(serialized: str, context: UnserializeContext) BaseVendorInstaller ¶
Create a dataclass instance from a serialized string representation.
- Raises:
VendorNameError – if the serialized string is not corresponding to this subclass. This is a pretty common issue.
- abstract classmethod version() int ¶
The version of the installer API.
Any change in the code of the subclass imply to bump this version which should trigger an update on the user system.
- class knots_hub.installer.vendors.RezVendorInstaller(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>, python_version: str = <knots_hub.serializelib._Uninitialized object>, rez_version: str = <knots_hub.serializelib._Uninitialized object>)¶
Install rez at the given location. See https://rez.readthedocs.io/en/stable/
- __init__(install_dir: ~pathlib.Path = <knots_hub.serializelib._Uninitialized object>, dirs_to_make: list[~pathlib.Path] = <knots_hub.serializelib._Uninitialized object>, python_version: str = <knots_hub.serializelib._Uninitialized object>, rez_version: str = <knots_hub.serializelib._Uninitialized object>) None ¶
- classmethod get_documentation() list[str] ¶
Get the documentation for the subclass as a list of lines.
- Returns:
list of lines as valid .rst syntax.
- 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.
- python_version: str = <knots_hub.serializelib._Uninitialized object>¶
- rez_version: str = <knots_hub.serializelib._Uninitialized object>¶
- classmethod version() int ¶
The version of the installer API.
Any change in the code of the subclass imply to bump this version which should trigger an update on the user system.
- exception knots_hub.installer.vendors.VendorNameError¶
The serialized representation is not for the expected vendor class.
- knots_hub.installer.vendors.install_vendor(vendor: BaseVendorInstaller, record_path: Path) bool ¶
Install OR update the vendor as configured by the user.
- Parameters:
vendor – the vendor installer instance to install/update.
record_path – filesystem path to a file that may exist and should record the last and future vendor installation configuration.
- knots_hub.installer.vendors.read_vendor_installer_from_file(file_path: Path) list[BaseVendorInstaller] ¶
Get the vendor installers serialized in the given file.
- Parameters:
file_path – filesystem path to an existing json file.
- Returns:
list of corresponding instances.
- knots_hub.installer.vendors.uninstall_vendor(record_file: VendorInstallRecord)¶
Uninstall the previously installed vendor as recorded by the given file.