swh.loader.package.opam.loader module#
- class swh.loader.package.opam.loader.OpamPackageInfo(url: str, filename: str | None, version: str, author: Person, committer: Person, *, directory_extrinsic_metadata: List[RawExtrinsicMetadataCore] = [], checksums: Dict[str, str] = {})[source]#
Bases:
BasePackageInfo
Method generated by attrs for class OpamPackageInfo.
- swh.loader.package.opam.loader.opam() str [source]#
Get the path to the opam executable.
- Raises:
EnvironmentError if no opam executable is found –
- class swh.loader.package.opam.loader.OpamLoader(storage: StorageInterface, url: str, opam_root: str, opam_instance: str, opam_url: str, opam_package: str, **kwargs: Any)[source]#
Bases:
PackageLoader
[OpamPackageInfo
]Load all versions of a given package in a given opam repository.
The state of the opam repository is stored in a directory called an opam root. This folder is a requisite for the opam binary to actually list information on package. It will be automatically initialized or updated if it does not exist or if an opam repository must be added to the default switch.
The remaining ingestion uses the opam binary to give the versions of the given package. Then, for each version, the loader uses the opam binary to list the tarball url to fetch and ingest.
- Loader’s constructor. This raises exception if the minimal required
configuration is missing (cf. fn:check method).
- Parameters:
storage – Storage instance
url – Origin url to load data from
- get_metadata_authority()[source]#
For package loaders that get extrinsic metadata, returns the authority the metadata are coming from.
- get_versions() List[str] [source]#
First initialize the opam root directory if needed then start listing the package versions.
- Raises:
ValueError in case the lister is not able to determine the list of –
versions or if the opam root directory is invalid. –
- get_package_info(version: str) Iterator[Tuple[str, OpamPackageInfo]] [source]#
- Given a release version of a package, retrieve the associated
package information for such version.
- Parameters:
version – Package version
- Returns:
(branch name, package metadata)
- build_release(p_info: OpamPackageInfo, uncompressed_path: str, directory: bytes) Release | None [source]#
Build the release from the archive metadata (extrinsic artifact metadata) and the intrinsic metadata.
- Parameters:
p_info – Package information
uncompressed_path – Artifact uncompressed path on disk