Spec.package_class -> spack.repo.PATH.get_pkg_class (#48985)
This commit is contained in:
parent
f043455ccc
commit
9747978c7f
@ -125,7 +125,7 @@ def develop(parser, args):
|
||||
version = spec.versions.concrete_range_as_version
|
||||
if not version:
|
||||
# look up the maximum version so infintiy versions are preferred for develop
|
||||
version = max(spec.package_class.versions.keys())
|
||||
version = max(spack.repo.PATH.get_pkg_class(spec.fullname).versions.keys())
|
||||
tty.msg(f"Defaulting to highest version: {spec.name}@{version}")
|
||||
spec.versions = spack.version.VersionList([version])
|
||||
|
||||
|
@ -545,7 +545,7 @@ def _not_license_excluded(self, x):
|
||||
package does not explicitly forbid redistributing source."""
|
||||
if self.private:
|
||||
return True
|
||||
elif x.package_class.redistribute_source(x):
|
||||
elif spack.repo.PATH.get_pkg_class(x.fullname).redistribute_source(x):
|
||||
return True
|
||||
else:
|
||||
tty.debug(
|
||||
|
@ -252,7 +252,9 @@ def has_test_and_tags(pkg_class):
|
||||
hashes = env.all_hashes() if env else None
|
||||
|
||||
specs = spack.store.STORE.db.query(hashes=hashes)
|
||||
specs = list(filter(lambda s: has_test_and_tags(s.package_class), specs))
|
||||
specs = list(
|
||||
filter(lambda s: has_test_and_tags(spack.repo.PATH.get_pkg_class(s.fullname)), specs)
|
||||
)
|
||||
|
||||
spack.cmd.display_specs(specs, long=True)
|
||||
|
||||
|
@ -566,7 +566,7 @@ def copy_test_files(pkg: Pb, test_spec: spack.spec.Spec):
|
||||
|
||||
# copy test data into test stage data dir
|
||||
try:
|
||||
pkg_cls = test_spec.package_class
|
||||
pkg_cls = spack.repo.PATH.get_pkg_class(test_spec.fullname)
|
||||
except spack.repo.UnknownPackageError:
|
||||
tty.debug(f"{test_spec.name}: skipping test data copy since no package class found")
|
||||
return
|
||||
@ -623,7 +623,7 @@ def test_functions(
|
||||
vpkgs = virtuals(pkg)
|
||||
for vname in vpkgs:
|
||||
try:
|
||||
classes.append((Spec(vname)).package_class)
|
||||
classes.append(spack.repo.PATH.get_pkg_class(vname))
|
||||
except spack.repo.UnknownPackageError:
|
||||
tty.debug(f"{vname}: virtual does not appear to have a package file")
|
||||
|
||||
@ -668,7 +668,7 @@ def process_test_parts(pkg: Pb, test_specs: List[spack.spec.Spec], verbose: bool
|
||||
|
||||
# grab test functions associated with the spec, which may be virtual
|
||||
try:
|
||||
tests = test_functions(spec.package_class)
|
||||
tests = test_functions(spack.repo.PATH.get_pkg_class(spec.fullname))
|
||||
except spack.repo.UnknownPackageError:
|
||||
# Some virtuals don't have a package so we don't want to report
|
||||
# them as not having tests when that isn't appropriate.
|
||||
|
@ -3472,7 +3472,7 @@ def external_spec_selected(self, node, idx):
|
||||
self._specs[node].extra_attributes = spec_info.get("extra_attributes", {})
|
||||
|
||||
# If this is an extension, update the dependencies to include the extendee
|
||||
package = self._specs[node].package_class(self._specs[node])
|
||||
package = spack.repo.PATH.get_pkg_class(self._specs[node].fullname)(self._specs[node])
|
||||
extendee_spec = package.extendee_spec
|
||||
|
||||
if extendee_spec:
|
||||
|
@ -1905,6 +1905,12 @@ def package_class(self):
|
||||
"""Internal package call gets only the class object for a package.
|
||||
Use this to just get package metadata.
|
||||
"""
|
||||
warnings.warn(
|
||||
"`Spec.package_class` is deprecated and will be removed in version 1.0.0. Use "
|
||||
"`spack.repo.PATH.get_pkg_class(spec.fullname) instead.",
|
||||
category=spack.error.SpackAPIWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return spack.repo.PATH.get_pkg_class(self.fullname)
|
||||
|
||||
@property
|
||||
@ -2864,7 +2870,7 @@ def inject_patches_variant(root):
|
||||
|
||||
# Add any patches from the package to the spec.
|
||||
patches = set()
|
||||
for cond, patch_list in s.package_class.patches.items():
|
||||
for cond, patch_list in spack.repo.PATH.get_pkg_class(s.fullname).patches.items():
|
||||
if s.satisfies(cond):
|
||||
for patch in patch_list:
|
||||
patches.add(patch)
|
||||
@ -2877,7 +2883,7 @@ def inject_patches_variant(root):
|
||||
if dspec.spec.concrete:
|
||||
continue
|
||||
|
||||
pkg_deps = dspec.parent.package_class.dependencies
|
||||
pkg_deps = spack.repo.PATH.get_pkg_class(dspec.parent.fullname).dependencies
|
||||
|
||||
patches = []
|
||||
for cond, deps_by_name in pkg_deps.items():
|
||||
@ -3111,7 +3117,7 @@ def ensure_valid_variants(spec):
|
||||
if spec.concrete:
|
||||
return
|
||||
|
||||
pkg_cls = spec.package_class
|
||||
pkg_cls = spack.repo.PATH.get_pkg_class(spec.fullname)
|
||||
pkg_variants = pkg_cls.variant_names()
|
||||
# reserved names are variants that may be set on any package
|
||||
# but are not necessarily recorded by the package's class
|
||||
@ -4705,7 +4711,7 @@ def concrete(self):
|
||||
bool: True or False
|
||||
"""
|
||||
return self.spec._concrete or all(
|
||||
v in self for v in self.spec.package_class.variant_names()
|
||||
v in self for v in spack.repo.PATH.get_pkg_class(self.spec.fullname).variant_names()
|
||||
)
|
||||
|
||||
def copy(self) -> "VariantMap":
|
||||
@ -4765,14 +4771,14 @@ def substitute_abstract_variants(spec: Spec):
|
||||
elif name in vt.reserved_names:
|
||||
continue
|
||||
|
||||
variant_defs = spec.package_class.variant_definitions(name)
|
||||
variant_defs = spack.repo.PATH.get_pkg_class(spec.fullname).variant_definitions(name)
|
||||
valid_defs = []
|
||||
for when, vdef in variant_defs:
|
||||
if when.intersects(spec):
|
||||
valid_defs.append(vdef)
|
||||
|
||||
if not valid_defs:
|
||||
if name not in spec.package_class.variant_names():
|
||||
if name not in spack.repo.PATH.get_pkg_class(spec.fullname).variant_names():
|
||||
unknown.append(name)
|
||||
else:
|
||||
whens = [str(when) for when, _ in variant_defs]
|
||||
|
@ -206,7 +206,7 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage):
|
||||
)
|
||||
def test_redistribute_directive(test_repo, spec_str, distribute_src, distribute_bin):
|
||||
spec = spack.spec.Spec(spec_str)
|
||||
assert spec.package_class.redistribute_source(spec) == distribute_src
|
||||
assert spack.repo.PATH.get_pkg_class(spec.fullname).redistribute_source(spec) == distribute_src
|
||||
concretized_spec = spack.concretize.concretize_one(spec)
|
||||
assert concretized_spec.package.redistribute_binary == distribute_bin
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
import spack.compiler
|
||||
import spack.platforms
|
||||
import spack.repo
|
||||
import spack.util.libc
|
||||
from spack.operating_systems.mac_os import macos_sdk_path, macos_version
|
||||
from spack.package import *
|
||||
@ -1217,7 +1218,7 @@ def _post_buildcache_install_hook(self):
|
||||
)
|
||||
if header_dir and all(
|
||||
os.path.exists(os.path.join(header_dir, h))
|
||||
for h in libc.package_class.representative_headers
|
||||
for h in spack.repo.PATH.get_pkg_class(libc.fullname).representative_headers
|
||||
):
|
||||
relocation_args.append(f"-idirafter {header_dir}")
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user