spack.mirrors package

Submodules

spack.mirrors.layout module

class spack.mirrors.layout.DefaultLayout(alias_path: str, digest_path: str | None = None)[source]

Bases: MirrorLayout

make_alias(root: str) None[source]

Symlink a human readible path in our mirror to the actual storage location.

class spack.mirrors.layout.MirrorLayout(path: str)[source]

Bases: object

A MirrorLayout object describes the relative path of a mirror entry.

make_alias(root: str) None[source]

Make the entry root / self.path available under a human readable alias

class spack.mirrors.layout.OCILayout(digest: Digest)[source]

Bases: MirrorLayout

Follow the OCI Image Layout Specification to archive blobs where paths are of the form blobs/<algorithm>/<digest>

spack.mirrors.layout.default_mirror_layout(fetcher: FetchStrategy, per_package_ref: str, spec: Spec | None = None) MirrorLayout[source]

Returns a MirrorReference object which keeps track of the relative storage path of the resource associated with the specified fetcher.

spack.mirrors.mirror module

class spack.mirrors.mirror.Mirror(data: str | dict, name: str | None = None)[source]

Bases: object

Represents a named location for storing source tarballs and binary packages.

Mirrors have a fetch_url that indicate where and how artifacts are fetched from them, and a push_url that indicate where and how artifacts are pushed to them. These two URLs are usually the same.

property autopush: bool
property binary
display(max_len=0)[source]
ensure_mirror_usable(direction: str = 'push')[source]
property fetch_url

Get the valid, canonicalized fetch URL

static from_json(stream, name=None)[source]
static from_local_path(path: str)[source]
static from_url(url: str)[source]

Create an anonymous mirror by URL. This method validates the URL.

static from_yaml(stream, name=None)[source]
get_access_pair(direction: str) Tuple[str, str] | None[source]
get_access_token(direction: str) str | None[source]
get_credentials(direction: str) Dict[str, Any][source]

Get the mirror credentials from the mirror config

Parameters:

direction – fetch or push mirror config

Returns:

Dictionary from credential type string to value

Credential Type Map:

access_token -> str access_pair -> tuple(str,str) profile -> str

get_endpoint_url(direction: str) str | None[source]
get_profile(direction: str) str | None[source]
get_url(direction: str) str[source]
property name
property push_url

Get the valid, canonicalized fetch URL

property signed: bool
property source
to_dict()[source]
to_json(stream=None)[source]
to_yaml(stream=None)[source]
update(data: dict, direction: str | None = None) bool[source]

Modify the mirror with the given data. This takes care of expanding trivial mirror definitions by URL to something more rich with a dict if necessary

Parameters:
  • data (dict) – The data to update the mirror with.

  • direction (str) – The direction to update the mirror in (fetch or push or None for top-level update)

Returns:

True if the mirror was updated, False otherwise.

Return type:

bool

class spack.mirrors.mirror.MirrorCollection(mirrors=None, scope=None, binary: bool | None = None, source: bool | None = None, autopush: bool | None = None)[source]

Bases: Mapping

A mapping of mirror names to mirrors.

display()[source]
static from_dict(d)[source]
static from_json(stream, name=None)[source]
static from_yaml(stream, name=None)[source]
lookup(name_or_url)[source]

Looks up and returns a Mirror.

If this MirrorCollection contains a named Mirror under the name [name_or_url], then that mirror is returned. Otherwise, [name_or_url] is assumed to be a mirror URL, and an anonymous mirror with the given URL is returned.

to_dict(recursive=False)[source]
to_json(stream=None)[source]
to_yaml(stream=None)[source]
spack.mirrors.mirror.supported_url_schemes = ('file', 'http', 'https', 'sftp', 'ftp', 's3', 'gs', 'oci')

What schemes do we support

spack.mirrors.utils module

class spack.mirrors.utils.MirrorStats[source]

Bases: object

added(resource)[source]
already_existed(resource)[source]
error()[source]
next_spec(spec)[source]
stats()[source]
spack.mirrors.utils.add(mirror: Mirror, scope=None)[source]

Add a named mirror in the given scope

spack.mirrors.utils.create(path, specs, skip_unstable_versions=False)[source]

Create a directory to be used as a spack mirror, and fill it with package archives.

Parameters:
  • path – Path to create a mirror directory hierarchy in.

  • specs – Any package versions matching these specs will be added to the mirror.

  • skip_unstable_versions – if true, this skips adding resources when they do not have a stable archive checksum (as determined by fetch_strategy.stable_target)

Return Value:

Returns a tuple of lists: (present, mirrored, error)

  • present: Package specs that were already present.

  • mirrored: Package specs that were successfully mirrored.

  • error: Package specs that failed to mirror due to some error.

spack.mirrors.utils.create_mirror_from_package_object(pkg_obj, mirror_cache: MirrorCache, mirror_stats: MirrorStats) bool[source]

Add a single package object to a mirror.

The package object is only required to have an associated spec with a concrete version.

Parameters:
  • pkg_obj (spack.package_base.PackageBase) – package object with to be added.

  • mirror_cache – mirror where to add the spec.

  • mirror_stats – statistics on the current mirror

Returns:

True if the spec was added successfully, False otherwise

spack.mirrors.utils.get_all_versions(specs)[source]

Given a set of initial specs, return a new set of specs that includes each version of each package in the original set.

Note that if any spec in the original set specifies properties other than version, this information will be omitted in the new set; for example; the new set of specs will not include variant settings.

spack.mirrors.utils.get_matching_versions(specs, num_versions=1)[source]

Get a spec for EACH known version matching any spec in the list. For concrete specs, this retrieves the concrete version and, if more than one version per spec is requested, retrieves the latest versions of the package.

spack.mirrors.utils.mirror_cache_and_stats(path, skip_unstable_versions=False)[source]

Return both a mirror cache and a mirror stats, starting from the path where a mirror ought to be created.

Parameters:
  • path (str) – path to create a mirror directory hierarchy in.

  • skip_unstable_versions – if true, this skips adding resources when they do not have a stable archive checksum (as determined by fetch_strategy.stable_target)

spack.mirrors.utils.remove(name, scope)[source]

Remove the named mirror in the given scope

spack.mirrors.utils.require_mirror_name(mirror_name)[source]

Find a mirror by name and raise if it does not exist