mirrors: add missing init file (#47977)
This commit is contained in:
parent
f54c101b44
commit
422f829e4e
@ -222,9 +222,6 @@ def setup(sphinx):
|
|||||||
("py:class", "spack.traverse.EdgeAndDepth"),
|
("py:class", "spack.traverse.EdgeAndDepth"),
|
||||||
("py:class", "archspec.cpu.microarchitecture.Microarchitecture"),
|
("py:class", "archspec.cpu.microarchitecture.Microarchitecture"),
|
||||||
("py:class", "spack.compiler.CompilerCache"),
|
("py:class", "spack.compiler.CompilerCache"),
|
||||||
("py:class", "spack.mirrors.mirror.Mirror"),
|
|
||||||
("py:class", "spack.mirrors.layout.MirrorLayout"),
|
|
||||||
("py:class", "spack.mirrors.utils.MirrorStats"),
|
|
||||||
# TypeVar that is not handled correctly
|
# TypeVar that is not handled correctly
|
||||||
("py:class", "llnl.util.lang.T"),
|
("py:class", "llnl.util.lang.T"),
|
||||||
]
|
]
|
||||||
|
4
lib/spack/spack/mirrors/__init__.py
Normal file
4
lib/spack/spack/mirrors/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
|
||||||
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
@ -4,7 +4,6 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
@ -214,7 +213,9 @@ def error(self):
|
|||||||
self.errors.add(self.current_spec)
|
self.errors.add(self.current_spec)
|
||||||
|
|
||||||
|
|
||||||
def create_mirror_from_package_object(pkg_obj, mirror_cache, mirror_stats):
|
def create_mirror_from_package_object(
|
||||||
|
pkg_obj, mirror_cache: "spack.caches.MirrorCache", mirror_stats: MirrorStats
|
||||||
|
) -> bool:
|
||||||
"""Add a single package object to a mirror.
|
"""Add a single package object to a mirror.
|
||||||
|
|
||||||
The package object is only required to have an associated spec
|
The package object is only required to have an associated spec
|
||||||
@ -222,32 +223,27 @@ def create_mirror_from_package_object(pkg_obj, mirror_cache, mirror_stats):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
pkg_obj (spack.package_base.PackageBase): package object with to be added.
|
pkg_obj (spack.package_base.PackageBase): package object with to be added.
|
||||||
mirror_cache (spack.caches.MirrorCache): mirror where to add the spec.
|
mirror_cache: mirror where to add the spec.
|
||||||
mirror_stats (spack.mirror.MirrorStats): statistics on the current mirror
|
mirror_stats: statistics on the current mirror
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
True if the spec was added successfully, False otherwise
|
True if the spec was added successfully, False otherwise
|
||||||
"""
|
"""
|
||||||
tty.msg("Adding package {} to mirror".format(pkg_obj.spec.format("{name}{@version}")))
|
tty.msg("Adding package {} to mirror".format(pkg_obj.spec.format("{name}{@version}")))
|
||||||
num_retries = 3
|
max_retries = 3
|
||||||
while num_retries > 0:
|
for num_retries in range(max_retries):
|
||||||
try:
|
try:
|
||||||
# Includes patches and resources
|
# Includes patches and resources
|
||||||
with pkg_obj.stage as pkg_stage:
|
with pkg_obj.stage as pkg_stage:
|
||||||
pkg_stage.cache_mirror(mirror_cache, mirror_stats)
|
pkg_stage.cache_mirror(mirror_cache, mirror_stats)
|
||||||
exception = None
|
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_tuple = sys.exc_info()
|
if num_retries + 1 == max_retries:
|
||||||
exception = e
|
|
||||||
num_retries -= 1
|
|
||||||
if exception:
|
|
||||||
if spack.config.get("config:debug"):
|
if spack.config.get("config:debug"):
|
||||||
traceback.print_exception(file=sys.stderr, *exc_tuple)
|
traceback.print_exc()
|
||||||
else:
|
else:
|
||||||
tty.warn(
|
tty.warn(
|
||||||
"Error while fetching %s" % pkg_obj.spec.cformat("{name}{@version}"),
|
"Error while fetching %s" % pkg_obj.spec.format("{name}{@version}"), str(e)
|
||||||
getattr(exception, "message", exception),
|
|
||||||
)
|
)
|
||||||
mirror_stats.error()
|
mirror_stats.error()
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user