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 readable 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: bool
display(max_len: int = 0) None[source]
ensure_mirror_usable(direction: str = 'push') None[source]
property fetch_url: str

Get the valid, canonicalized fetch URL

property fetch_view: str | None

Get the fetch view

static from_local_path(path: str) Mirror[source]
static from_url(url: str) Mirror[source]

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

static from_yaml(stream: str | IO[str], name: str | None = None) Mirror[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: str
property push_url: str

Get the valid, canonicalized push URL

property push_view: str | None

Get the push view

property signed: bool
property source: bool
property supported_layout_versions: List[int]

List all of the supported layouts a mirror can fetch from

to_dict() str | dict[source]
to_yaml(stream: None = None) str[source]
to_yaml(stream: IO[str]) None
update(data: Dict[str, Any], 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: Mapping[str, Any] | None = None, scope: str | None = None, binary: bool | None = None, source: bool | None = None, autopush: bool | None = None)[source]

Bases: Mapping[str, Mirror]

A mapping of mirror names to mirrors.

display() None[source]
static from_dict(d: Mapping[str, Any]) MirrorCollection[source]
lookup(name_or_url: str) Mirror[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: bool = False) Dict[str, Any][source]
spack.mirrors.mirror.SUPPORTED_LAYOUT_VERSIONS

The layout version spack can current install

spack.mirrors.mirror.supported_url_schemes

What schemes do we support

spack.mirrors.utils module

class spack.mirrors.utils.MirrorStatsForAllSpecs[source]

Bases: object

merge(ext_mirror_stat: MirrorStatsForOneSpec)[source]
stats()[source]
class spack.mirrors.utils.MirrorStatsForOneSpec(spec)[source]

Bases: object

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

Add a named mirror in the given scope

spack.mirrors.utils.create_mirror_from_package_object(pkg_obj, mirror_cache: MirrorCache, mirror_stats: MirrorStatsForOneSpec) 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.get_mirror_cache(path, skip_unstable_versions=False)[source]

Returns a mirror cache, 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).

Returns:

mirror cache object for the given path.

Return type:

spack.caches.MirrorCache

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