tmt.libraries package
Submodules
tmt.libraries.beakerlib module
- class tmt.libraries.beakerlib.BeakerLib(parent: ~tmt.utils.Common, _logger: ~tmt.log.Logger, identifier: ~tmt.base.core.DependencyFmfId, format: str, repo: ~tmt._compat.pathlib.Path, name: str, dest: ~tmt._compat.pathlib.Path, path: ~tmt._compat.pathlib.Path | None, require: list[~tmt.base.core.DependencySimple | ~tmt.base.core.DependencyFmfId | ~tmt.base.core.DependencyFile] = <factory>, recommend: list[~tmt.base.core.DependencySimple | ~tmt.base.core.DependencyFmfId | ~tmt.base.core.DependencyFile] = <factory>, default_branch: str | None = None)
Bases:
LibraryA beakerlib library
Takes care of fetching beakerlib libraries from remote repositories based on provided library identifier described in detail here: https://tmt.readthedocs.io/en/latest/spec/tests.html#require
Libraries are fetched into the ‘libs’ directory under parent’s workdir or into ‘destination’ if provided in the identifier.
- default_branch: str | None = None
- dest: Path
Target folder into which the library repo is cloned
- fetch() None
Fetch the library from the source in the identifier.
- property fmf_node_path: Path
Path to fmf node
- classmethod from_identifier(*, identifier: DependencySimple | DependencyFmfId | DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) Library
Factory function to get correct library instance
- identifier: DependencyFmfId
The original dependency requested
- path: Path | None
- recommend: list[DependencySimple | DependencyFmfId | DependencyFile]
List of recommended packages
- require: list[DependencySimple | DependencyFmfId | DependencyFile]
List of required packages
- source_directory: Path
Source directory where used for files required by the library dependencies
- tree: Tree
Fmf tree holding library metadata
- class tmt.libraries.beakerlib.BeakerLibFromPath(parent: ~tmt.utils.Common, _logger: ~tmt.log.Logger, identifier: ~tmt.base.core.DependencyFmfId, format: ~typing.Literal['fmf'], repo: ~tmt._compat.pathlib.Path, name: str, dest: ~tmt._compat.pathlib.Path, path: ~tmt._compat.pathlib.Path, require: list[~tmt.base.core.DependencySimple | ~tmt.base.core.DependencyFmfId | ~tmt.base.core.DependencyFile] = <factory>, recommend: list[~tmt.base.core.DependencySimple | ~tmt.base.core.DependencyFmfId | ~tmt.base.core.DependencyFile] = <factory>, default_branch: str | None = None)
Bases:
BeakerLibA beakerlib library on the local filesystem.
- format: Literal['fmf']
Format of the library type requested
- classmethod from_identifier(*, identifier: DependencySimple | DependencyFmfId | DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) BeakerLib
Factory function to get correct library instance
- path: Path
Absolute path on the local filesystem pointing to the library
- class tmt.libraries.beakerlib.BeakerLibFromUrl(parent: ~tmt.utils.Common, _logger: ~tmt.log.Logger, identifier: ~tmt.base.core.DependencyFmfId, format: ~typing.Literal['rpm', 'fmf'], repo: ~tmt._compat.pathlib.Path, name: str, dest: ~tmt._compat.pathlib.Path, path: ~tmt._compat.pathlib.Path | None = None, require: list[~tmt.base.core.DependencySimple | ~tmt.base.core.DependencyFmfId | ~tmt.base.core.DependencyFile] = <factory>, recommend: list[~tmt.base.core.DependencySimple | ~tmt.base.core.DependencyFmfId | ~tmt.base.core.DependencyFile] = <factory>, default_branch: str | None = None, url: str = '', ref: str | None = None)
Bases:
BeakerLibAn external beakerlib library fetched from a git url.
- format: Literal['rpm', 'fmf']
Format of the library type requested
- classmethod from_identifier(*, identifier: DependencySimple | DependencyFmfId | DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) Library
Factory function to get correct library instance
- property hostname: str
Get hostname from url or default to local
- path: Path | None = None
Path under the git repository pointing to the fmf root
- ref: str | None = None
Git revision (branch, tag or commit)
- url: str = ''
Full git repository url
- class tmt.libraries.beakerlib.CommonWithLibraryCache(*, parent: CommonDerivedType | None = None, name: str | None = None, workdir: Literal[True] | Path | None = None, workdir_root: Path | None = None, relative_indent: int = 1, cli_invocation: CliInvocation | None = None, logger: Logger, **kwargs: Any)
Bases:
CommonInitialize name and relation with the parent object
Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.
- cli_invocation: 'tmt.cli.CliInvocation' | None = None
tmt.libraries.file module
- class tmt.libraries.file.File(parent: Common, _logger: Logger, identifier: DependencyFile, format: Literal['file'], repo: Path, name: str, pattern: list[str], source_location: Path, target_location: Path)
Bases:
LibraryRequired files
Takes care of copying required files for specific test or library, more details here: https://tmt.readthedocs.io/en/latest/spec/tests.html#require
- fetch() None
Fetch the library from the source in the identifier.
- format: Literal['file']
Format of the library type requested
- classmethod from_identifier(*, identifier: DependencySimple | DependencyFmfId | DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) Library
Factory function to get correct library instance
- identifier: DependencyFile
The original dependency requested
- pattern: list[str]
Filename paths and regexes which need to be copied
- source_location: Path
Root source location of the tests directory of the Discover phase (
test_dir)
- target_location: Path
Root target location where to copy the file into
Module contents
Handle libraries
- class tmt.libraries.Library(parent: Common, _logger: Logger, identifier: DependencySimple | DependencyFmfId | DependencyFile, format: str, repo: Path, name: str)
Bases:
ABCGeneral library class
Used as parent for specific libraries like beakerlib and file
- abstractmethod fetch() None
Fetch the library from the source in the identifier.
- property fmf_node_path: Path
Path to fmf node
- format: str
Format of the library type requested
- classmethod from_identifier(*, identifier: DependencySimple | DependencyFmfId | DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) Library
Factory function to get correct library instance
- property hostname: str
Get hostname from url or default to local
- identifier: DependencySimple | DependencyFmfId | DependencyFile
The original dependency requested
- name: str
Fully-qualified name of the library (excluding the
repopart).For example the name used in the
rlImportcommand. Must start with/.
- repo: Path
Name of the repository where the library came from
- exception tmt.libraries.LibraryError
Bases:
ExceptionUsed when library cannot be parsed from the identifier
- tmt.libraries.dependencies(*, original_require: list[DependencySimple | DependencyFmfId | DependencyFile], original_recommend: list[DependencySimple | DependencyFmfId | DependencyFile] | None = None, parent: Common | None = None, imported_lib_ids: list[DependencySimple | DependencyFmfId | DependencyFile] | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) tuple[list[DependencySimple | DependencyFmfId | DependencyFile], list[DependencySimple | DependencyFmfId | DependencyFile], list[Library]]
Check dependencies for possible beakerlib libraries
Fetch all identified libraries, check their required and recommended packages. Return tuple (requires, recommends, libraries) containing list of regular rpm package names aggregated from all fetched libraries, list of aggregated recommended packages and a list of gathered libraries (instances of the Library class).
Avoid infinite recursion by keeping track of imported library identifiers and not trying to fetch those again.