Deprecate Spec.concretize/Spec.concretized in favor of spack.concretize.concretize_one (#47971)

The methods spack.spec.Spec.concretize and spack.spec.Spec.concretized
are deprecated in favor of spack.concretize.concretize_one.

This will resolve a circular dependency between the spack.spec and
spack.concretize in the next Spack release.
This commit is contained in:
Greg Becker 2025-01-15 01:13:19 -08:00 committed by GitHub
parent f3522cba74
commit e7c591a8b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
90 changed files with 1038 additions and 1034 deletions

View File

@ -543,10 +543,10 @@ With either interpreter you can run a single command:
.. code-block:: console .. code-block:: console
$ spack python -c 'from spack.spec import Spec; Spec("python").concretized()' $ spack python -c 'from spack.concretize import concretize_one; concretize_one("python")'
... ...
$ spack python -i ipython -c 'from spack.spec import Spec; Spec("python").concretized()' $ spack python -i ipython -c 'from spack.concretize import concretize_one; concretize_one("python")'
Out[1]: ... Out[1]: ...
or a file: or a file:

View File

@ -34,6 +34,7 @@
from llnl.util.lang import GroupedExceptionHandler from llnl.util.lang import GroupedExceptionHandler
import spack.binary_distribution import spack.binary_distribution
import spack.concretize
import spack.config import spack.config
import spack.detection import spack.detection
import spack.mirrors.mirror import spack.mirrors.mirror
@ -270,10 +271,10 @@ def try_import(self, module: str, abstract_spec_str: str) -> bool:
bootstrapper = ClingoBootstrapConcretizer(configuration=spack.config.CONFIG) bootstrapper = ClingoBootstrapConcretizer(configuration=spack.config.CONFIG)
concrete_spec = bootstrapper.concretize() concrete_spec = bootstrapper.concretize()
else: else:
concrete_spec = spack.spec.Spec( abstract_spec = spack.spec.Spec(
abstract_spec_str + " ^" + spec_for_current_python() abstract_spec_str + " ^" + spec_for_current_python()
) )
concrete_spec.concretize() concrete_spec = spack.concretize.concretize_one(abstract_spec)
msg = "[BOOTSTRAP MODULE {0}] Try installing '{1}' from sources" msg = "[BOOTSTRAP MODULE {0}] Try installing '{1}' from sources"
tty.debug(msg.format(module, abstract_spec_str)) tty.debug(msg.format(module, abstract_spec_str))
@ -299,7 +300,7 @@ def try_search_path(self, executables: Tuple[str], abstract_spec_str: str) -> bo
# might reduce compilation time by a fair amount # might reduce compilation time by a fair amount
_add_externals_if_missing() _add_externals_if_missing()
concrete_spec = spack.spec.Spec(abstract_spec_str).concretized() concrete_spec = spack.concretize.concretize_one(abstract_spec_str)
msg = "[BOOTSTRAP] Try installing '{0}' from sources" msg = "[BOOTSTRAP] Try installing '{0}' from sources"
tty.debug(msg.format(abstract_spec_str)) tty.debug(msg.format(abstract_spec_str))
with spack.config.override(self.mirror_scope): with spack.config.override(self.mirror_scope):

View File

@ -202,7 +202,7 @@ def _concretize_spec_pairs(
# Special case for concretizing a single spec # Special case for concretizing a single spec
if len(to_concretize) == 1: if len(to_concretize) == 1:
abstract, concrete = to_concretize[0] abstract, concrete = to_concretize[0]
return [concrete or abstract.concretized(tests=tests)] return [concrete or spack.concretize.concretize_one(abstract, tests=tests)]
# Special case if every spec is either concrete or has an abstract hash # Special case if every spec is either concrete or has an abstract hash
if all( if all(
@ -254,9 +254,9 @@ def matching_spec_from_env(spec):
""" """
env = ev.active_environment() env = ev.active_environment()
if env: if env:
return env.matching_spec(spec) or spec.concretized() return env.matching_spec(spec) or spack.concretize.concretize_one(spec)
else: else:
return spec.concretized() return spack.concretize.concretize_one(spec)
def matching_specs_from_env(specs): def matching_specs_from_env(specs):

View File

@ -14,9 +14,9 @@
import spack.bootstrap import spack.bootstrap
import spack.bootstrap.config import spack.bootstrap.config
import spack.bootstrap.core import spack.bootstrap.core
import spack.concretize
import spack.config import spack.config
import spack.mirrors.utils import spack.mirrors.utils
import spack.spec
import spack.stage import spack.stage
import spack.util.path import spack.util.path
import spack.util.spack_yaml import spack.util.spack_yaml
@ -397,7 +397,7 @@ def _mirror(args):
llnl.util.tty.msg(msg.format(spec_str, mirror_dir)) llnl.util.tty.msg(msg.format(spec_str, mirror_dir))
# Suppress tty from the call below for terser messages # Suppress tty from the call below for terser messages
llnl.util.tty.set_msg_enabled(False) llnl.util.tty.set_msg_enabled(False)
spec = spack.spec.Spec(spec_str).concretized() spec = spack.concretize.concretize_one(spec_str)
for node in spec.traverse(): for node in spec.traverse():
spack.mirrors.utils.create(mirror_dir, [node]) spack.mirrors.utils.create(mirror_dir, [node])
llnl.util.tty.set_msg_enabled(True) llnl.util.tty.set_msg_enabled(True)

View File

@ -16,6 +16,7 @@
import spack.binary_distribution as bindist import spack.binary_distribution as bindist
import spack.cmd import spack.cmd
import spack.concretize
import spack.config import spack.config
import spack.deptypes as dt import spack.deptypes as dt
import spack.environment as ev import spack.environment as ev
@ -554,8 +555,7 @@ def check_fn(args: argparse.Namespace):
tty.msg("No specs provided, exiting.") tty.msg("No specs provided, exiting.")
return return
for spec in specs: specs = [spack.concretize.concretize_one(s) for s in specs]
spec.concretize()
# Next see if there are any configured binary mirrors # Next see if there are any configured binary mirrors
configured_mirrors = spack.config.get("mirrors", scope=args.scope) configured_mirrors = spack.config.get("mirrors", scope=args.scope)
@ -623,7 +623,7 @@ def save_specfile_fn(args):
root = specs[0] root = specs[0]
if not root.concrete: if not root.concrete:
root.concretize() root = spack.concretize.concretize_one(root)
save_dependency_specfiles( save_dependency_specfiles(
root, args.specfile_dir, dependencies=spack.cmd.parse_specs(args.specs) root, args.specfile_dir, dependencies=spack.cmd.parse_specs(args.specs)

View File

@ -18,6 +18,7 @@
from llnl.util.symlink import symlink from llnl.util.symlink import symlink
import spack.cmd import spack.cmd
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.installer import spack.installer
import spack.store import spack.store
@ -103,7 +104,7 @@ def deprecate(parser, args):
) )
if args.install: if args.install:
deprecator = specs[1].concretized() deprecator = spack.concretize.concretize_one(specs[1])
else: else:
deprecator = spack.cmd.disambiguate_spec(specs[1], env, local=True) deprecator = spack.cmd.disambiguate_spec(specs[1], env, local=True)

View File

@ -10,6 +10,7 @@
import spack.build_environment import spack.build_environment
import spack.cmd import spack.cmd
import spack.cmd.common.arguments import spack.cmd.common.arguments
import spack.concretize
import spack.config import spack.config
import spack.repo import spack.repo
from spack.cmd.common import arguments from spack.cmd.common import arguments
@ -114,7 +115,7 @@ def dev_build(self, args):
# Forces the build to run out of the source directory. # Forces the build to run out of the source directory.
spec.constrain("dev_path=%s" % source_path) spec.constrain("dev_path=%s" % source_path)
spec.concretize() spec = spack.concretize.concretize_one(spec)
if spec.installed: if spec.installed:
tty.error("Already installed in %s" % spec.prefix) tty.error("Already installed in %s" % spec.prefix)

View File

@ -13,6 +13,7 @@
from llnl.util import lang, tty from llnl.util import lang, tty
import spack.cmd import spack.cmd
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.paths import spack.paths
@ -450,7 +451,7 @@ def concrete_specs_from_file(args):
else: else:
s = spack.spec.Spec.from_json(f) s = spack.spec.Spec.from_json(f)
concretized = s.concretized() concretized = spack.concretize.concretize_one(s)
if concretized.dag_hash() != s.dag_hash(): if concretized.dag_hash() != s.dag_hash():
msg = 'skipped invalid file "{0}". ' msg = 'skipped invalid file "{0}". '
msg += "The file does not contain a concrete spec." msg += "The file does not contain a concrete spec."

View File

@ -7,9 +7,9 @@
from llnl.path import convert_to_posix_path from llnl.path import convert_to_posix_path
import spack.concretize
import spack.paths import spack.paths
import spack.util.executable import spack.util.executable
from spack.spec import Spec
description = "generate Windows installer" description = "generate Windows installer"
section = "admin" section = "admin"
@ -65,8 +65,7 @@ def make_installer(parser, args):
""" """
if sys.platform == "win32": if sys.platform == "win32":
output_dir = args.output_dir output_dir = args.output_dir
cmake_spec = Spec("cmake") cmake_spec = spack.concretize.concretize_one("cmake")
cmake_spec.concretize()
cmake_path = os.path.join(cmake_spec.prefix, "bin", "cmake.exe") cmake_path = os.path.join(cmake_spec.prefix, "bin", "cmake.exe")
cpack_path = os.path.join(cmake_spec.prefix, "bin", "cpack.exe") cpack_path = os.path.join(cmake_spec.prefix, "bin", "cpack.exe")
spack_source = args.spack_source spack_source = args.spack_source

View File

@ -492,7 +492,7 @@ def extend_with_additional_versions(specs, num_versions):
mirror_specs = spack.mirrors.utils.get_all_versions(specs) mirror_specs = spack.mirrors.utils.get_all_versions(specs)
else: else:
mirror_specs = spack.mirrors.utils.get_matching_versions(specs, num_versions=num_versions) mirror_specs = spack.mirrors.utils.get_matching_versions(specs, num_versions=num_versions)
mirror_specs = [x.concretized() for x in mirror_specs] mirror_specs = [spack.concretize.concretize_one(x) for x in mirror_specs]
return mirror_specs return mirror_specs

View File

@ -37,13 +37,12 @@ def enable_compiler_existence_check():
SpecPairInput = Tuple[Spec, Optional[Spec]] SpecPairInput = Tuple[Spec, Optional[Spec]]
SpecPair = Tuple[Spec, Spec] SpecPair = Tuple[Spec, Spec]
SpecLike = Union[Spec, str]
TestsType = Union[bool, Iterable[str]] TestsType = Union[bool, Iterable[str]]
def concretize_specs_together( def _concretize_specs_together(
abstract_specs: Sequence[SpecLike], tests: TestsType = False abstract_specs: Sequence[Spec], tests: TestsType = False
) -> Sequence[Spec]: ) -> List[Spec]:
"""Given a number of specs as input, tries to concretize them together. """Given a number of specs as input, tries to concretize them together.
Args: Args:
@ -51,11 +50,10 @@ def concretize_specs_together(
tests: list of package names for which to consider tests dependencies. If True, all nodes tests: list of package names for which to consider tests dependencies. If True, all nodes
will have test dependencies. If False, test dependencies will be disregarded. will have test dependencies. If False, test dependencies will be disregarded.
""" """
import spack.solver.asp from spack.solver.asp import Solver
allow_deprecated = spack.config.get("config:deprecated", False) allow_deprecated = spack.config.get("config:deprecated", False)
solver = spack.solver.asp.Solver() result = Solver().solve(abstract_specs, tests=tests, allow_deprecated=allow_deprecated)
result = solver.solve(abstract_specs, tests=tests, allow_deprecated=allow_deprecated)
return [s.copy() for s in result.specs] return [s.copy() for s in result.specs]
@ -72,7 +70,7 @@ def concretize_together(
""" """
to_concretize = [concrete if concrete else abstract for abstract, concrete in spec_list] to_concretize = [concrete if concrete else abstract for abstract, concrete in spec_list]
abstract_specs = [abstract for abstract, _ in spec_list] abstract_specs = [abstract for abstract, _ in spec_list]
concrete_specs = concretize_specs_together(to_concretize, tests=tests) concrete_specs = _concretize_specs_together(to_concretize, tests=tests)
return list(zip(abstract_specs, concrete_specs)) return list(zip(abstract_specs, concrete_specs))
@ -90,7 +88,7 @@ def concretize_together_when_possible(
tests: list of package names for which to consider tests dependencies. If True, all nodes tests: list of package names for which to consider tests dependencies. If True, all nodes
will have test dependencies. If False, test dependencies will be disregarded. will have test dependencies. If False, test dependencies will be disregarded.
""" """
import spack.solver.asp from spack.solver.asp import Solver
to_concretize = [concrete if concrete else abstract for abstract, concrete in spec_list] to_concretize = [concrete if concrete else abstract for abstract, concrete in spec_list]
old_concrete_to_abstract = { old_concrete_to_abstract = {
@ -98,9 +96,8 @@ def concretize_together_when_possible(
} }
result_by_user_spec = {} result_by_user_spec = {}
solver = spack.solver.asp.Solver()
allow_deprecated = spack.config.get("config:deprecated", False) allow_deprecated = spack.config.get("config:deprecated", False)
for result in solver.solve_in_rounds( for result in Solver().solve_in_rounds(
to_concretize, tests=tests, allow_deprecated=allow_deprecated to_concretize, tests=tests, allow_deprecated=allow_deprecated
): ):
result_by_user_spec.update(result.specs_by_input) result_by_user_spec.update(result.specs_by_input)
@ -124,7 +121,7 @@ def concretize_separately(
tests: list of package names for which to consider tests dependencies. If True, all nodes tests: list of package names for which to consider tests dependencies. If True, all nodes
will have test dependencies. If False, test dependencies will be disregarded. will have test dependencies. If False, test dependencies will be disregarded.
""" """
import spack.bootstrap from spack.bootstrap import ensure_bootstrap_configuration, ensure_clingo_importable_or_raise
to_concretize = [abstract for abstract, concrete in spec_list if not concrete] to_concretize = [abstract for abstract, concrete in spec_list if not concrete]
args = [ args = [
@ -134,8 +131,8 @@ def concretize_separately(
] ]
ret = [(i, abstract) for i, abstract in enumerate(to_concretize) if abstract.concrete] ret = [(i, abstract) for i, abstract in enumerate(to_concretize) if abstract.concrete]
# Ensure we don't try to bootstrap clingo in parallel # Ensure we don't try to bootstrap clingo in parallel
with spack.bootstrap.ensure_bootstrap_configuration(): with ensure_bootstrap_configuration():
spack.bootstrap.ensure_clingo_importable_or_raise() ensure_clingo_importable_or_raise()
# Ensure all the indexes have been built or updated, since # Ensure all the indexes have been built or updated, since
# otherwise the processes in the pool may timeout on waiting # otherwise the processes in the pool may timeout on waiting
@ -190,10 +187,52 @@ def _concretize_task(packed_arguments: Tuple[int, str, TestsType]) -> Tuple[int,
index, spec_str, tests = packed_arguments index, spec_str, tests = packed_arguments
with tty.SuppressOutput(msg_enabled=False): with tty.SuppressOutput(msg_enabled=False):
start = time.time() start = time.time()
spec = Spec(spec_str).concretized(tests=tests) spec = concretize_one(Spec(spec_str), tests=tests)
return index, spec, time.time() - start return index, spec, time.time() - start
def concretize_one(spec: Union[str, Spec], tests: TestsType = False) -> Spec:
"""Return a concretized copy of the given spec.
Args:
tests: if False disregard 'test' dependencies, if a list of names activate them for
the packages in the list, if True activate 'test' dependencies for all packages.
"""
from spack.solver.asp import Solver, SpecBuilder
if isinstance(spec, str):
spec = Spec(spec)
spec = spec.lookup_hash()
if spec.concrete:
return spec.copy()
for node in spec.traverse():
if not node.name:
raise spack.error.SpecError(
f"Spec {node} has no name; cannot concretize an anonymous spec"
)
allow_deprecated = spack.config.get("config:deprecated", False)
result = Solver().solve([spec], tests=tests, allow_deprecated=allow_deprecated)
# take the best answer
opt, i, answer = min(result.answers)
name = spec.name
# TODO: Consolidate this code with similar code in solve.py
if spec.virtual:
providers = [s.name for s in answer.values() if s.package.provides(name)]
name = providers[0]
node = SpecBuilder.make_node(pkg=name)
assert (
node in answer
), f"cannot find {name} in the list of specs {','.join([n.pkg for n in answer.keys()])}"
concretized = answer[node]
return concretized
class UnavailableCompilerVersionError(spack.error.SpackError): class UnavailableCompilerVersionError(spack.error.SpackError):
"""Raised when there is no available compiler that satisfies a """Raised when there is no available compiler that satisfies a
compiler spec.""" compiler spec."""

View File

@ -67,7 +67,7 @@
GitOrStandardVersion = Union[spack.version.GitVersion, spack.version.StandardVersion] GitOrStandardVersion = Union[spack.version.GitVersion, spack.version.StandardVersion]
TransformFunction = Callable[["spack.spec.Spec", List[AspFunction]], List[AspFunction]] TransformFunction = Callable[[spack.spec.Spec, List[AspFunction]], List[AspFunction]]
#: Enable the addition of a runtime node #: Enable the addition of a runtime node
WITH_RUNTIME = sys.platform != "win32" WITH_RUNTIME = sys.platform != "win32"
@ -127,8 +127,8 @@ def __str__(self):
@contextmanager @contextmanager
def named_spec( def named_spec(
spec: Optional["spack.spec.Spec"], name: Optional[str] spec: Optional[spack.spec.Spec], name: Optional[str]
) -> Iterator[Optional["spack.spec.Spec"]]: ) -> Iterator[Optional[spack.spec.Spec]]:
"""Context manager to temporarily set the name of a spec""" """Context manager to temporarily set the name of a spec"""
if spec is None or name is None: if spec is None or name is None:
yield spec yield spec
@ -747,11 +747,11 @@ def on_model(model):
class KnownCompiler(NamedTuple): class KnownCompiler(NamedTuple):
"""Data class to collect information on compilers""" """Data class to collect information on compilers"""
spec: "spack.spec.Spec" spec: spack.spec.Spec
os: str os: str
target: str target: str
available: bool available: bool
compiler_obj: Optional["spack.compiler.Compiler"] compiler_obj: Optional[spack.compiler.Compiler]
def _key(self): def _key(self):
return self.spec, self.os, self.target return self.spec, self.os, self.target
@ -1386,7 +1386,7 @@ def effect_rules(self):
def define_variant( def define_variant(
self, self,
pkg: "Type[spack.package_base.PackageBase]", pkg: Type[spack.package_base.PackageBase],
name: str, name: str,
when: spack.spec.Spec, when: spack.spec.Spec,
variant_def: vt.Variant, variant_def: vt.Variant,
@ -1490,7 +1490,7 @@ def define_auto_variant(self, name: str, multi: bool):
) )
) )
def variant_rules(self, pkg: "Type[spack.package_base.PackageBase]"): def variant_rules(self, pkg: Type[spack.package_base.PackageBase]):
for name in pkg.variant_names(): for name in pkg.variant_names():
self.gen.h3(f"Variant {name} in package {pkg.name}") self.gen.h3(f"Variant {name} in package {pkg.name}")
for when, variant_def in pkg.variant_definitions(name): for when, variant_def in pkg.variant_definitions(name):
@ -1681,8 +1681,8 @@ def dependency_holds(input_spec, requirements):
def _gen_match_variant_splice_constraints( def _gen_match_variant_splice_constraints(
self, self,
pkg, pkg,
cond_spec: "spack.spec.Spec", cond_spec: spack.spec.Spec,
splice_spec: "spack.spec.Spec", splice_spec: spack.spec.Spec,
hash_asp_var: "AspVar", hash_asp_var: "AspVar",
splice_node, splice_node,
match_variants: List[str], match_variants: List[str],
@ -2977,7 +2977,7 @@ def _specs_from_requires(self, pkg_name, section):
for s in spec_group[key]: for s in spec_group[key]:
yield _spec_with_default_name(s, pkg_name) yield _spec_with_default_name(s, pkg_name)
def pkg_class(self, pkg_name: str) -> typing.Type["spack.package_base.PackageBase"]: def pkg_class(self, pkg_name: str) -> typing.Type[spack.package_base.PackageBase]:
request = pkg_name request = pkg_name
if pkg_name in self.explicitly_required_namespaces: if pkg_name in self.explicitly_required_namespaces:
namespace = self.explicitly_required_namespaces[pkg_name] namespace = self.explicitly_required_namespaces[pkg_name]
@ -3096,7 +3096,7 @@ def __init__(self, configuration) -> None:
self.compilers.add(candidate) self.compilers.add(candidate)
def with_input_specs(self, input_specs: List["spack.spec.Spec"]) -> "CompilerParser": def with_input_specs(self, input_specs: List[spack.spec.Spec]) -> "CompilerParser":
"""Accounts for input specs when building the list of possible compilers. """Accounts for input specs when building the list of possible compilers.
Args: Args:
@ -3136,7 +3136,7 @@ def with_input_specs(self, input_specs: List["spack.spec.Spec"]) -> "CompilerPar
return self return self
def add_compiler_from_concrete_spec(self, spec: "spack.spec.Spec") -> None: def add_compiler_from_concrete_spec(self, spec: spack.spec.Spec) -> None:
"""Account for compilers that are coming from concrete specs, through reuse. """Account for compilers that are coming from concrete specs, through reuse.
Args: Args:

View File

@ -86,7 +86,6 @@
import spack import spack
import spack.compiler import spack.compiler
import spack.compilers import spack.compilers
import spack.config
import spack.deptypes as dt import spack.deptypes as dt
import spack.error import spack.error
import spack.hash_types as ht import spack.hash_types as ht
@ -94,7 +93,6 @@
import spack.platforms import spack.platforms
import spack.provider_index import spack.provider_index
import spack.repo import spack.repo
import spack.solver
import spack.spec_parser import spack.spec_parser
import spack.store import spack.store
import spack.traverse import spack.traverse
@ -2949,44 +2947,16 @@ def ensure_no_deprecated(root):
raise SpecDeprecatedError(msg) raise SpecDeprecatedError(msg)
def concretize(self, tests: Union[bool, Iterable[str]] = False) -> None: def concretize(self, tests: Union[bool, Iterable[str]] = False) -> None:
"""Concretize the current spec. from spack.concretize import concretize_one
Args: warnings.warn(
tests: if False disregard 'test' dependencies, if a list of names activate them for "`Spec.concretize` is deprecated and will be removed in version 1.0.0. Use "
the packages in the list, if True activate 'test' dependencies for all packages. "`spack.concretize.concretize_one` instead.",
""" category=spack.error.SpackAPIWarning,
import spack.solver.asp stacklevel=2,
)
self.replace_hash() self._dup(concretize_one(self, tests))
for node in self.traverse():
if not node.name:
raise spack.error.SpecError(
f"Spec {node} has no name; cannot concretize an anonymous spec"
)
if self._concrete:
return
allow_deprecated = spack.config.get("config:deprecated", False)
solver = spack.solver.asp.Solver()
result = solver.solve([self], tests=tests, allow_deprecated=allow_deprecated)
# take the best answer
opt, i, answer = min(result.answers)
name = self.name
# TODO: Consolidate this code with similar code in solve.py
if self.virtual:
providers = [spec.name for spec in answer.values() if spec.package.provides(name)]
name = providers[0]
node = spack.solver.asp.SpecBuilder.make_node(pkg=name)
assert (
node in answer
), f"cannot find {name} in the list of specs {','.join([n.pkg for n in answer.keys()])}"
concretized = answer[node]
self._dup(concretized)
def _mark_root_concrete(self, value=True): def _mark_root_concrete(self, value=True):
"""Mark just this spec (not dependencies) concrete.""" """Mark just this spec (not dependencies) concrete."""
@ -3076,19 +3046,16 @@ def _finalize_concretization(self):
spec._cached_hash(ht.dag_hash) spec._cached_hash(ht.dag_hash)
def concretized(self, tests: Union[bool, Iterable[str]] = False) -> "Spec": def concretized(self, tests: Union[bool, Iterable[str]] = False) -> "Spec":
"""This is a non-destructive version of concretize(). from spack.concretize import concretize_one
First clones, then returns a concrete version of this package warnings.warn(
without modifying this package. "`Spec.concretized` is deprecated and will be removed in version 1.0.0. Use "
"`spack.concretize.concretize_one` instead.",
category=spack.error.SpackAPIWarning,
stacklevel=2,
)
Args: return concretize_one(self, tests)
tests (bool or list): if False disregard 'test' dependencies,
if a list of names activate them for the packages in the list,
if True activate 'test' dependencies for all packages.
"""
clone = self.copy()
clone.concretize(tests=tests)
return clone
def index(self, deptype="all"): def index(self, deptype="all"):
"""Return a dictionary that points to all the dependencies in this """Return a dictionary that points to all the dependencies in this

View File

@ -7,6 +7,7 @@
import pytest import pytest
import spack.concretize
import spack.config import spack.config
import spack.deptypes as dt import spack.deptypes as dt
import spack.solver.asp import spack.solver.asp
@ -21,7 +22,7 @@ def __init__(self, specs: List[str]) -> None:
self.concr_specs = [] self.concr_specs = []
def __enter__(self): def __enter__(self):
self.concr_specs = [Spec(s).concretized() for s in self.req_specs] self.concr_specs = [spack.concretize.concretize_one(s) for s in self.req_specs]
for s in self.concr_specs: for s in self.concr_specs:
PackageInstaller([s.package], fake=True, explicit=True).install() PackageInstaller([s.package], fake=True, explicit=True).install()
@ -62,13 +63,13 @@ def _has_build_dependency(spec: Spec, name: str):
def test_simple_reuse(splicing_setup): def test_simple_reuse(splicing_setup):
with CacheManager(["splice-z@1.0.0+compat"]): with CacheManager(["splice-z@1.0.0+compat"]):
spack.config.set("packages", _make_specs_non_buildable(["splice-z"])) spack.config.set("packages", _make_specs_non_buildable(["splice-z"]))
assert Spec("splice-z").concretized().satisfies(Spec("splice-z")) assert spack.concretize.concretize_one("splice-z").satisfies(Spec("splice-z"))
def test_simple_dep_reuse(splicing_setup): def test_simple_dep_reuse(splicing_setup):
with CacheManager(["splice-z@1.0.0+compat"]): with CacheManager(["splice-z@1.0.0+compat"]):
spack.config.set("packages", _make_specs_non_buildable(["splice-z"])) spack.config.set("packages", _make_specs_non_buildable(["splice-z"]))
assert Spec("splice-h@1").concretized().satisfies(Spec("splice-h@1")) assert spack.concretize.concretize_one("splice-h@1").satisfies(Spec("splice-h@1"))
def test_splice_installed_hash(splicing_setup): def test_splice_installed_hash(splicing_setup):
@ -81,9 +82,9 @@ def test_splice_installed_hash(splicing_setup):
spack.config.set("packages", packages_config) spack.config.set("packages", packages_config)
goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.0") goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.0")
with pytest.raises(Exception): with pytest.raises(Exception):
goal_spec.concretized() spack.concretize.concretize_one(goal_spec)
_enable_splicing() _enable_splicing()
assert goal_spec.concretized().satisfies(goal_spec) assert spack.concretize.concretize_one(goal_spec).satisfies(goal_spec)
def test_splice_build_splice_node(splicing_setup): def test_splice_build_splice_node(splicing_setup):
@ -91,9 +92,9 @@ def test_splice_build_splice_node(splicing_setup):
spack.config.set("packages", _make_specs_non_buildable(["splice-t"])) spack.config.set("packages", _make_specs_non_buildable(["splice-t"]))
goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.0+compat") goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.0+compat")
with pytest.raises(Exception): with pytest.raises(Exception):
goal_spec.concretized() spack.concretize.concretize_one(goal_spec)
_enable_splicing() _enable_splicing()
assert goal_spec.concretized().satisfies(goal_spec) assert spack.concretize.concretize_one(goal_spec).satisfies(goal_spec)
def test_double_splice(splicing_setup): def test_double_splice(splicing_setup):
@ -107,9 +108,9 @@ def test_double_splice(splicing_setup):
spack.config.set("packages", freeze_builds_config) spack.config.set("packages", freeze_builds_config)
goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.2+compat") goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.2+compat")
with pytest.raises(Exception): with pytest.raises(Exception):
goal_spec.concretized() spack.concretize.concretize_one(goal_spec)
_enable_splicing() _enable_splicing()
assert goal_spec.concretized().satisfies(goal_spec) assert spack.concretize.concretize_one(goal_spec).satisfies(goal_spec)
# The next two tests are mirrors of one another # The next two tests are mirrors of one another
@ -126,10 +127,10 @@ def test_virtual_multi_splices_in(splicing_setup):
spack.config.set("packages", _make_specs_non_buildable(["depends-on-virtual-with-abi"])) spack.config.set("packages", _make_specs_non_buildable(["depends-on-virtual-with-abi"]))
for gs in goal_specs: for gs in goal_specs:
with pytest.raises(Exception): with pytest.raises(Exception):
Spec(gs).concretized() spack.concretize.concretize_one(gs)
_enable_splicing() _enable_splicing()
for gs in goal_specs: for gs in goal_specs:
assert Spec(gs).concretized().satisfies(gs) assert spack.concretize.concretize_one(gs).satisfies(gs)
def test_virtual_multi_can_be_spliced(splicing_setup): def test_virtual_multi_can_be_spliced(splicing_setup):
@ -143,12 +144,12 @@ def test_virtual_multi_can_be_spliced(splicing_setup):
] ]
with CacheManager(cache): with CacheManager(cache):
spack.config.set("packages", _make_specs_non_buildable(["depends-on-virtual-with-abi"])) spack.config.set("packages", _make_specs_non_buildable(["depends-on-virtual-with-abi"]))
with pytest.raises(Exception): for gs in goal_specs:
for gs in goal_specs: with pytest.raises(Exception):
Spec(gs).concretized() spack.concretize.concretize_one(gs)
_enable_splicing() _enable_splicing()
for gs in goal_specs: for gs in goal_specs:
assert Spec(gs).concretized().satisfies(gs) assert spack.concretize.concretize_one(gs).satisfies(gs)
def test_manyvariant_star_matching_variant_splice(splicing_setup): def test_manyvariant_star_matching_variant_splice(splicing_setup):
@ -166,10 +167,10 @@ def test_manyvariant_star_matching_variant_splice(splicing_setup):
spack.config.set("packages", freeze_build_config) spack.config.set("packages", freeze_build_config)
for goal in goal_specs: for goal in goal_specs:
with pytest.raises(Exception): with pytest.raises(Exception):
goal.concretized() spack.concretize.concretize_one(goal)
_enable_splicing() _enable_splicing()
for goal in goal_specs: for goal in goal_specs:
assert goal.concretized().satisfies(goal) assert spack.concretize.concretize_one(goal).satisfies(goal)
def test_manyvariant_limited_matching(splicing_setup): def test_manyvariant_limited_matching(splicing_setup):
@ -188,10 +189,10 @@ def test_manyvariant_limited_matching(splicing_setup):
spack.config.set("packages", freeze_build_config) spack.config.set("packages", freeze_build_config)
for s in goal_specs: for s in goal_specs:
with pytest.raises(Exception): with pytest.raises(Exception):
s.concretized() spack.concretize.concretize_one(s)
_enable_splicing() _enable_splicing()
for s in goal_specs: for s in goal_specs:
assert s.concretized().satisfies(s) assert spack.concretize.concretize_one(s).satisfies(s)
def test_external_splice_same_name(splicing_setup): def test_external_splice_same_name(splicing_setup):
@ -210,7 +211,7 @@ def test_external_splice_same_name(splicing_setup):
spack.config.set("packages", packages_yaml) spack.config.set("packages", packages_yaml)
_enable_splicing() _enable_splicing()
for s in goal_specs: for s in goal_specs:
assert s.concretized().satisfies(s) assert spack.concretize.concretize_one(s).satisfies(s)
def test_spliced_build_deps_only_in_build_spec(splicing_setup): def test_spliced_build_deps_only_in_build_spec(splicing_setup):
@ -219,7 +220,7 @@ def test_spliced_build_deps_only_in_build_spec(splicing_setup):
with CacheManager(cache): with CacheManager(cache):
_enable_splicing() _enable_splicing()
concr_goal = goal_spec.concretized() concr_goal = spack.concretize.concretize_one(goal_spec)
build_spec = concr_goal._build_spec build_spec = concr_goal._build_spec
# Spec has been spliced # Spec has been spliced
assert build_spec is not None assert build_spec is not None
@ -237,7 +238,7 @@ def test_spliced_transitive_dependency(splicing_setup):
with CacheManager(cache): with CacheManager(cache):
spack.config.set("packages", _make_specs_non_buildable(["splice-depends-on-t"])) spack.config.set("packages", _make_specs_non_buildable(["splice-depends-on-t"]))
_enable_splicing() _enable_splicing()
concr_goal = goal_spec.concretized() concr_goal = spack.concretize.concretize_one(goal_spec)
# Spec has been spliced # Spec has been spliced
assert concr_goal._build_spec is not None assert concr_goal._build_spec is not None
assert concr_goal["splice-t"]._build_spec is not None assert concr_goal["splice-t"]._build_spec is not None

View File

@ -133,5 +133,5 @@ def test_concretize_target_ranges(root_target_range, dep_target_range, result, m
f"pkg-a %gcc@10 foobar=bar target={root_target_range} ^pkg-b target={dep_target_range}" f"pkg-a %gcc@10 foobar=bar target={root_target_range} ^pkg-b target={dep_target_range}"
) )
with spack.concretize.disable_compiler_existence_check(): with spack.concretize.disable_compiler_existence_check():
spec.concretize() spec = spack.concretize.concretize_one(spec)
assert spec.target == spec["pkg-b"].target == result assert spec.target == spec["pkg-b"].target == result

View File

@ -28,6 +28,7 @@
import spack.binary_distribution as bindist import spack.binary_distribution as bindist
import spack.caches import spack.caches
import spack.compilers import spack.compilers
import spack.concretize
import spack.config import spack.config
import spack.fetch_strategy import spack.fetch_strategy
import spack.hooks.sbang as sbang import spack.hooks.sbang as sbang
@ -205,8 +206,9 @@ def test_default_rpaths_create_install_default_layout(temporary_mirror_dir):
Test the creation and installation of buildcaches with default rpaths Test the creation and installation of buildcaches with default rpaths
into the default directory layout scheme. into the default directory layout scheme.
""" """
gspec, cspec = Spec("garply").concretized(), Spec("corge").concretized() gspec = spack.concretize.concretize_one("garply")
sy_spec = Spec("symly").concretized() cspec = spack.concretize.concretize_one("corge")
sy_spec = spack.concretize.concretize_one("symly")
# Install 'corge' without using a cache # Install 'corge' without using a cache
install_cmd("--no-cache", cspec.name) install_cmd("--no-cache", cspec.name)
@ -253,9 +255,9 @@ def test_default_rpaths_install_nondefault_layout(temporary_mirror_dir):
Test the creation and installation of buildcaches with default rpaths Test the creation and installation of buildcaches with default rpaths
into the non-default directory layout scheme. into the non-default directory layout scheme.
""" """
cspec = Spec("corge").concretized() cspec = spack.concretize.concretize_one("corge")
# This guy tests for symlink relocation # This guy tests for symlink relocation
sy_spec = Spec("symly").concretized() sy_spec = spack.concretize.concretize_one("symly")
# Install some packages with dependent packages # Install some packages with dependent packages
# test install in non-default install path scheme # test install in non-default install path scheme
@ -276,7 +278,8 @@ def test_relative_rpaths_install_default_layout(temporary_mirror_dir):
Test the creation and installation of buildcaches with relative Test the creation and installation of buildcaches with relative
rpaths into the default directory layout scheme. rpaths into the default directory layout scheme.
""" """
gspec, cspec = Spec("garply").concretized(), Spec("corge").concretized() gspec = spack.concretize.concretize_one("garply")
cspec = spack.concretize.concretize_one("corge")
# Install buildcache created with relativized rpaths # Install buildcache created with relativized rpaths
buildcache_cmd("install", "-uf", cspec.name) buildcache_cmd("install", "-uf", cspec.name)
@ -305,7 +308,7 @@ def test_relative_rpaths_install_nondefault(temporary_mirror_dir):
Test the installation of buildcaches with relativized rpaths Test the installation of buildcaches with relativized rpaths
into the non-default directory layout scheme. into the non-default directory layout scheme.
""" """
cspec = Spec("corge").concretized() cspec = spack.concretize.concretize_one("corge")
# Test install in non-default install path scheme and relative path # Test install in non-default install path scheme and relative path
buildcache_cmd("install", "-uf", cspec.name) buildcache_cmd("install", "-uf", cspec.name)
@ -358,7 +361,8 @@ def test_built_spec_cache(temporary_mirror_dir):
that cache from a buildcache index.""" that cache from a buildcache index."""
buildcache_cmd("list", "-a", "-l") buildcache_cmd("list", "-a", "-l")
gspec, cspec = Spec("garply").concretized(), Spec("corge").concretized() gspec = spack.concretize.concretize_one("garply")
cspec = spack.concretize.concretize_one("corge")
for s in [gspec, cspec]: for s in [gspec, cspec]:
results = bindist.get_mirrors_for_spec(s) results = bindist.get_mirrors_for_spec(s)
@ -381,7 +385,7 @@ def test_spec_needs_rebuild(monkeypatch, tmpdir):
mirror_dir = tmpdir.join("mirror_dir") mirror_dir = tmpdir.join("mirror_dir")
mirror_url = url_util.path_to_file_url(mirror_dir.strpath) mirror_url = url_util.path_to_file_url(mirror_dir.strpath)
s = Spec("libdwarf").concretized() s = spack.concretize.concretize_one("libdwarf")
# Install a package # Install a package
install_cmd(s.name) install_cmd(s.name)
@ -410,7 +414,7 @@ def test_generate_index_missing(monkeypatch, tmpdir, mutable_config):
mirror_url = url_util.path_to_file_url(mirror_dir.strpath) mirror_url = url_util.path_to_file_url(mirror_dir.strpath)
spack.config.set("mirrors", {"test": mirror_url}) spack.config.set("mirrors", {"test": mirror_url})
s = Spec("libdwarf").concretized() s = spack.concretize.concretize_one("libdwarf")
# Install a package # Install a package
install_cmd("--no-cache", s.name) install_cmd("--no-cache", s.name)
@ -494,7 +498,7 @@ def mock_list_url(url, recursive=False):
def test_update_sbang(tmp_path, temporary_mirror, mock_fetch, install_mockery): def test_update_sbang(tmp_path, temporary_mirror, mock_fetch, install_mockery):
"""Test relocation of the sbang shebang line in a package script""" """Test relocation of the sbang shebang line in a package script"""
s = Spec("old-sbang").concretized() s = spack.concretize.concretize_one("old-sbang")
PackageInstaller([s.package]).install() PackageInstaller([s.package]).install()
old_prefix, old_sbang_shebang = s.prefix, sbang.sbang_shebang_line() old_prefix, old_sbang_shebang = s.prefix, sbang.sbang_shebang_line()
old_contents = f"""\ old_contents = f"""\

View File

@ -8,15 +8,15 @@
import pytest import pytest
import spack.binary_distribution as bd import spack.binary_distribution as bd
import spack.concretize
import spack.mirrors.mirror import spack.mirrors.mirror
import spack.spec
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
pytestmark = pytest.mark.not_on_windows("does not run on windows") pytestmark = pytest.mark.not_on_windows("does not run on windows")
def test_build_tarball_overwrite(install_mockery, mock_fetch, monkeypatch, tmp_path): def test_build_tarball_overwrite(install_mockery, mock_fetch, monkeypatch, tmp_path):
spec = spack.spec.Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
PackageInstaller([spec.package], fake=True).install() PackageInstaller([spec.package], fake=True).install()
specs = [spec] specs = [spec]

View File

@ -16,6 +16,7 @@
import spack.build_environment import spack.build_environment
import spack.compiler import spack.compiler
import spack.compilers import spack.compilers
import spack.concretize
import spack.config import spack.config
import spack.deptypes as dt import spack.deptypes as dt
import spack.package_base import spack.package_base
@ -163,8 +164,7 @@ def test_static_to_shared_library(build_environment):
@pytest.mark.regression("8345") @pytest.mark.regression("8345")
@pytest.mark.usefixtures("config", "mock_packages") @pytest.mark.usefixtures("config", "mock_packages")
def test_cc_not_changed_by_modules(monkeypatch, working_env): def test_cc_not_changed_by_modules(monkeypatch, working_env):
s = spack.spec.Spec("cmake") s = spack.concretize.concretize_one("cmake")
s.concretize()
pkg = s.package pkg = s.package
def _set_wrong_cc(x): def _set_wrong_cc(x):
@ -184,7 +184,7 @@ def test_setup_dependent_package_inherited_modules(
working_env, mock_packages, install_mockery, mock_fetch working_env, mock_packages, install_mockery, mock_fetch
): ):
# This will raise on regression # This will raise on regression
s = spack.spec.Spec("cmake-client-inheritor").concretized() s = spack.concretize.concretize_one("cmake-client-inheritor")
PackageInstaller([s.package]).install() PackageInstaller([s.package]).install()
@ -277,7 +277,7 @@ def platform_pathsep(pathlist):
return convert_to_platform_path(pathlist) return convert_to_platform_path(pathlist)
# Monkeypatch a pkg.compiler.environment with the required modifications # Monkeypatch a pkg.compiler.environment with the required modifications
pkg = spack.spec.Spec("cmake").concretized().package pkg = spack.concretize.concretize_one("cmake").package
monkeypatch.setattr(pkg.compiler, "environment", modifications) monkeypatch.setattr(pkg.compiler, "environment", modifications)
# Trigger the modifications # Trigger the modifications
spack.build_environment.setup_package(pkg, False) spack.build_environment.setup_package(pkg, False)
@ -301,7 +301,7 @@ def custom_env(pkg, env):
env.prepend_path("PATH", test_path) env.prepend_path("PATH", test_path)
env.append_flags("ENV_CUSTOM_CC_FLAGS", "--custom-env-flag1") env.append_flags("ENV_CUSTOM_CC_FLAGS", "--custom-env-flag1")
pkg = spack.spec.Spec("cmake").concretized().package pkg = spack.concretize.concretize_one("cmake").package
monkeypatch.setattr(pkg.compiler, "setup_custom_environment", custom_env) monkeypatch.setattr(pkg.compiler, "setup_custom_environment", custom_env)
spack.build_environment.setup_package(pkg, False) spack.build_environment.setup_package(pkg, False)
@ -322,7 +322,7 @@ def test_external_config_env(mock_packages, mutable_config, working_env):
} }
spack.config.set("packages:cmake", cmake_config) spack.config.set("packages:cmake", cmake_config)
cmake_client = spack.spec.Spec("cmake-client").concretized() cmake_client = spack.concretize.concretize_one("cmake-client")
spack.build_environment.setup_package(cmake_client.package, False) spack.build_environment.setup_package(cmake_client.package, False)
assert os.environ["TEST_ENV_VAR_SET"] == "yes it's set" assert os.environ["TEST_ENV_VAR_SET"] == "yes it's set"
@ -330,8 +330,7 @@ def test_external_config_env(mock_packages, mutable_config, working_env):
@pytest.mark.regression("9107") @pytest.mark.regression("9107")
def test_spack_paths_before_module_paths(config, mock_packages, monkeypatch, working_env): def test_spack_paths_before_module_paths(config, mock_packages, monkeypatch, working_env):
s = spack.spec.Spec("cmake") s = spack.concretize.concretize_one("cmake")
s.concretize()
pkg = s.package pkg = s.package
module_path = os.path.join("path", "to", "module") module_path = os.path.join("path", "to", "module")
@ -352,8 +351,7 @@ def _set_wrong_cc(x):
def test_package_inheritance_module_setup(config, mock_packages, working_env): def test_package_inheritance_module_setup(config, mock_packages, working_env):
s = spack.spec.Spec("multimodule-inheritance") s = spack.concretize.concretize_one("multimodule-inheritance")
s.concretize()
pkg = s.package pkg = s.package
spack.build_environment.setup_package(pkg, False) spack.build_environment.setup_package(pkg, False)
@ -387,8 +385,7 @@ def test_wrapper_variables(
not in cuda_include_dirs not in cuda_include_dirs
) )
root = spack.spec.Spec("dt-diamond") root = spack.concretize.concretize_one("dt-diamond")
root.concretize()
for s in root.traverse(): for s in root.traverse():
s.prefix = "/{0}-prefix/".format(s.name) s.prefix = "/{0}-prefix/".format(s.name)
@ -453,7 +450,7 @@ def test_external_prefixes_last(mutable_config, mock_packages, working_env, monk
""" """
) )
spack.config.set("packages", cfg_data) spack.config.set("packages", cfg_data)
top = spack.spec.Spec("dt-diamond").concretized() top = spack.concretize.concretize_one("dt-diamond")
def _trust_me_its_a_dir(path): def _trust_me_its_a_dir(path):
return True return True
@ -500,8 +497,7 @@ def test_parallel_false_is_not_propagating(default_mock_concretization):
) )
def test_setting_dtags_based_on_config(config_setting, expected_flag, config, mock_packages): def test_setting_dtags_based_on_config(config_setting, expected_flag, config, mock_packages):
# Pick a random package to be able to set compiler's variables # Pick a random package to be able to set compiler's variables
s = spack.spec.Spec("cmake") s = spack.concretize.concretize_one("cmake")
s.concretize()
pkg = s.package pkg = s.package
env = EnvironmentModifications() env = EnvironmentModifications()
@ -533,7 +529,7 @@ def setup_dependent_package(module, dependent_spec):
assert dependent_module.ninja is not None assert dependent_module.ninja is not None
dependent_spec.package.test_attr = True dependent_spec.package.test_attr = True
externaltool = spack.spec.Spec("externaltest").concretized() externaltool = spack.concretize.concretize_one("externaltest")
monkeypatch.setattr( monkeypatch.setattr(
externaltool["externaltool"].package, "setup_dependent_package", setup_dependent_package externaltool["externaltool"].package, "setup_dependent_package", setup_dependent_package
) )
@ -728,7 +724,7 @@ def test_build_system_globals_only_set_on_root_during_build(default_mock_concret
But obviously it can lead to very hard to find bugs... We should get rid of those globals and But obviously it can lead to very hard to find bugs... We should get rid of those globals and
define them instead as a property on the package instance. define them instead as a property on the package instance.
""" """
root = spack.spec.Spec("mpileaks").concretized() root = spack.concretize.concretize_one("mpileaks")
build_variables = ("std_cmake_args", "std_meson_args", "std_pip_args") build_variables = ("std_cmake_args", "std_meson_args", "std_pip_args")
# See todo above, we clear out any properties that may have been set by the previous test. # See todo above, we clear out any properties that may have been set by the previous test.

View File

@ -15,6 +15,7 @@
import spack.build_systems.autotools import spack.build_systems.autotools
import spack.build_systems.cmake import spack.build_systems.cmake
import spack.builder import spack.builder
import spack.concretize
import spack.environment import spack.environment
import spack.error import spack.error
import spack.paths import spack.paths
@ -146,7 +147,7 @@ def test_none_is_allowed(self, default_mock_concretization):
def test_libtool_archive_files_are_deleted_by_default(self, mutable_database): def test_libtool_archive_files_are_deleted_by_default(self, mutable_database):
# Install a package that creates a mock libtool archive # Install a package that creates a mock libtool archive
s = Spec("libtool-deletion").concretized() s = spack.concretize.concretize_one("libtool-deletion")
PackageInstaller([s.package], explicit=True).install() PackageInstaller([s.package], explicit=True).install()
# Assert the libtool archive is not there and we have # Assert the libtool archive is not there and we have
@ -161,7 +162,7 @@ def test_libtool_archive_files_might_be_installed_on_demand(
): ):
# Install a package that creates a mock libtool archive, # Install a package that creates a mock libtool archive,
# patch its package to preserve the installation # patch its package to preserve the installation
s = Spec("libtool-deletion").concretized() s = spack.concretize.concretize_one("libtool-deletion")
monkeypatch.setattr( monkeypatch.setattr(
type(spack.builder.create(s.package)), "install_libtool_archives", True type(spack.builder.create(s.package)), "install_libtool_archives", True
) )
@ -175,7 +176,9 @@ def test_autotools_gnuconfig_replacement(self, mutable_database):
Tests whether only broken config.sub and config.guess are replaced with Tests whether only broken config.sub and config.guess are replaced with
files from working alternatives from the gnuconfig package. files from working alternatives from the gnuconfig package.
""" """
s = Spec("autotools-config-replacement +patch_config_files +gnuconfig").concretized() s = spack.concretize.concretize_one(
Spec("autotools-config-replacement +patch_config_files +gnuconfig")
)
PackageInstaller([s.package]).install() PackageInstaller([s.package]).install()
with open(os.path.join(s.prefix.broken, "config.sub"), encoding="utf-8") as f: with open(os.path.join(s.prefix.broken, "config.sub"), encoding="utf-8") as f:
@ -194,7 +197,9 @@ def test_autotools_gnuconfig_replacement_disabled(self, mutable_database):
""" """
Tests whether disabling patch_config_files Tests whether disabling patch_config_files
""" """
s = Spec("autotools-config-replacement ~patch_config_files +gnuconfig").concretized() s = spack.concretize.concretize_one(
Spec("autotools-config-replacement ~patch_config_files +gnuconfig")
)
PackageInstaller([s.package]).install() PackageInstaller([s.package]).install()
with open(os.path.join(s.prefix.broken, "config.sub"), encoding="utf-8") as f: with open(os.path.join(s.prefix.broken, "config.sub"), encoding="utf-8") as f:
@ -219,8 +224,9 @@ def test_autotools_gnuconfig_replacement_no_gnuconfig(self, mutable_database, mo
enabled, but gnuconfig is not listed as a direct build dependency. enabled, but gnuconfig is not listed as a direct build dependency.
""" """
monkeypatch.setattr(spack.platforms.test.Test, "default", "x86_64") monkeypatch.setattr(spack.platforms.test.Test, "default", "x86_64")
s = Spec("autotools-config-replacement +patch_config_files ~gnuconfig") s = spack.concretize.concretize_one(
s.concretize() Spec("autotools-config-replacement +patch_config_files ~gnuconfig")
)
msg = "Cannot patch config files: missing dependencies: gnuconfig" msg = "Cannot patch config files: missing dependencies: gnuconfig"
with pytest.raises(ChildError, match=msg): with pytest.raises(ChildError, match=msg):
@ -300,7 +306,7 @@ def test_define(self, default_mock_concretization):
assert define("SINGLE", "red") == "-DSINGLE:STRING=red" assert define("SINGLE", "red") == "-DSINGLE:STRING=red"
def test_define_from_variant(self): def test_define_from_variant(self):
s = Spec("cmake-client multi=up,right ~truthy single=red").concretized() s = spack.concretize.concretize_one("cmake-client multi=up,right ~truthy single=red")
arg = s.package.define_from_variant("MULTI") arg = s.package.define_from_variant("MULTI")
assert arg == "-DMULTI:STRING=right;up" assert arg == "-DMULTI:STRING=right;up"

View File

@ -8,9 +8,9 @@
from llnl.util.filesystem import touch from llnl.util.filesystem import touch
import spack.builder import spack.builder
import spack.concretize
import spack.paths import spack.paths
import spack.repo import spack.repo
import spack.spec
@pytest.fixture() @pytest.fixture()
@ -78,7 +78,7 @@ def builder_test_repository():
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_callbacks_and_installation_procedure(spec_str, expected_values, working_env): def test_callbacks_and_installation_procedure(spec_str, expected_values, working_env):
"""Test the correct execution of callbacks and installation procedures for packages.""" """Test the correct execution of callbacks and installation procedures for packages."""
s = spack.spec.Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
for phase_fn in builder: for phase_fn in builder:
phase_fn.execute() phase_fn.execute()
@ -101,7 +101,7 @@ def test_callbacks_and_installation_procedure(spec_str, expected_values, working
], ],
) )
def test_old_style_compatibility_with_super(spec_str, method_name, expected): def test_old_style_compatibility_with_super(spec_str, method_name, expected):
s = spack.spec.Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
value = getattr(builder, method_name)() value = getattr(builder, method_name)()
assert value == expected assert value == expected
@ -112,7 +112,7 @@ def test_old_style_compatibility_with_super(spec_str, method_name, expected):
@pytest.mark.usefixtures("builder_test_repository", "config", "working_env") @pytest.mark.usefixtures("builder_test_repository", "config", "working_env")
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_build_time_tests_are_executed_from_default_builder(): def test_build_time_tests_are_executed_from_default_builder():
s = spack.spec.Spec("old-style-autotools").concretized() s = spack.concretize.concretize_one("old-style-autotools")
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
builder.pkg.run_tests = True builder.pkg.run_tests = True
for phase_fn in builder: for phase_fn in builder:
@ -126,7 +126,7 @@ def test_build_time_tests_are_executed_from_default_builder():
@pytest.mark.usefixtures("builder_test_repository", "config", "working_env") @pytest.mark.usefixtures("builder_test_repository", "config", "working_env")
def test_monkey_patching_wrapped_pkg(): def test_monkey_patching_wrapped_pkg():
"""Confirm 'run_tests' is accessible through wrappers.""" """Confirm 'run_tests' is accessible through wrappers."""
s = spack.spec.Spec("old-style-autotools").concretized() s = spack.concretize.concretize_one("old-style-autotools")
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
assert s.package.run_tests is False assert s.package.run_tests is False
assert builder.pkg.run_tests is False assert builder.pkg.run_tests is False
@ -141,7 +141,7 @@ def test_monkey_patching_wrapped_pkg():
@pytest.mark.usefixtures("builder_test_repository", "config", "working_env") @pytest.mark.usefixtures("builder_test_repository", "config", "working_env")
def test_monkey_patching_test_log_file(): def test_monkey_patching_test_log_file():
"""Confirm 'test_log_file' is accessible through wrappers.""" """Confirm 'test_log_file' is accessible through wrappers."""
s = spack.spec.Spec("old-style-autotools").concretized() s = spack.concretize.concretize_one("old-style-autotools")
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
s.package.tester.test_log_file = "/some/file" s.package.tester.test_log_file = "/some/file"
@ -154,7 +154,7 @@ def test_monkey_patching_test_log_file():
@pytest.mark.not_on_windows("Does not run on windows") @pytest.mark.not_on_windows("Does not run on windows")
def test_install_time_test_callback(tmpdir, config, mock_packages, mock_stage): def test_install_time_test_callback(tmpdir, config, mock_packages, mock_stage):
"""Confirm able to run stand-alone test as a post-install callback.""" """Confirm able to run stand-alone test as a post-install callback."""
s = spack.spec.Spec("py-test-callback").concretized() s = spack.concretize.concretize_one("py-test-callback")
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
builder.pkg.run_tests = True builder.pkg.run_tests = True
s.package.tester.test_log_file = tmpdir.join("install_test.log") s.package.tester.test_log_file = tmpdir.join("install_test.log")
@ -174,7 +174,7 @@ def test_mixins_with_builders(working_env):
"""Tests that run_after and run_before callbacks are accumulated correctly, """Tests that run_after and run_before callbacks are accumulated correctly,
when mixins are used with builders. when mixins are used with builders.
""" """
s = spack.spec.Spec("builder-and-mixins").concretized() s = spack.concretize.concretize_one("builder-and-mixins")
builder = spack.builder.create(s.package) builder = spack.builder.create(s.package)
# Check that callbacks added by the mixin are in the list # Check that callbacks added by the mixin are in the list

View File

@ -4,6 +4,7 @@
import pytest import pytest
import spack.concretize
import spack.deptypes as dt import spack.deptypes as dt
import spack.installer as inst import spack.installer as inst
import spack.repo import spack.repo
@ -21,8 +22,7 @@ def test_build_request_errors(install_mockery):
def test_build_request_basics(install_mockery): def test_build_request_basics(install_mockery):
spec = spack.spec.Spec("dependent-install") spec = spack.concretize.concretize_one("dependent-install")
spec.concretize()
assert spec.concrete assert spec.concrete
# Ensure key properties match expectations # Ensure key properties match expectations
@ -39,8 +39,7 @@ def test_build_request_basics(install_mockery):
def test_build_request_strings(install_mockery): def test_build_request_strings(install_mockery):
"""Tests of BuildRequest repr and str for coverage purposes.""" """Tests of BuildRequest repr and str for coverage purposes."""
# Using a package with one dependency # Using a package with one dependency
spec = spack.spec.Spec("dependent-install") spec = spack.concretize.concretize_one("dependent-install")
spec.concretize()
assert spec.concrete assert spec.concrete
# Ensure key properties match expectations # Ensure key properties match expectations
@ -72,7 +71,7 @@ def test_build_request_deptypes(
package_deptypes, package_deptypes,
dependencies_deptypes, dependencies_deptypes,
): ):
s = spack.spec.Spec("dependent-install").concretized() s = spack.concretize.concretize_one("dependent-install")
build_request = inst.BuildRequest( build_request = inst.BuildRequest(
s.package, s.package,

View File

@ -4,6 +4,7 @@
import pytest import pytest
import spack.concretize
import spack.error import spack.error
import spack.installer as inst import spack.installer as inst
import spack.repo import spack.repo
@ -24,7 +25,7 @@ def test_build_task_errors(install_mockery):
inst.BuildTask(pkg_cls(spec), None) inst.BuildTask(pkg_cls(spec), None)
# Using a concretized package now means the request argument is checked. # Using a concretized package now means the request argument is checked.
spec.concretize() spec = spack.concretize.concretize_one(spec)
assert spec.concrete assert spec.concrete
with pytest.raises(TypeError, match="is not a valid build request"): with pytest.raises(TypeError, match="is not a valid build request"):
@ -47,8 +48,7 @@ def test_build_task_errors(install_mockery):
def test_build_task_basics(install_mockery): def test_build_task_basics(install_mockery):
spec = spack.spec.Spec("dependent-install") spec = spack.concretize.concretize_one("dependent-install")
spec.concretize()
assert spec.concrete assert spec.concrete
# Ensure key properties match expectations # Ensure key properties match expectations
@ -69,8 +69,7 @@ def test_build_task_basics(install_mockery):
def test_build_task_strings(install_mockery): def test_build_task_strings(install_mockery):
"""Tests of build_task repr and str for coverage purposes.""" """Tests of build_task repr and str for coverage purposes."""
# Using a package with one dependency # Using a package with one dependency
spec = spack.spec.Spec("dependent-install") spec = spack.concretize.concretize_one("dependent-install")
spec.concretize()
assert spec.concrete assert spec.concrete
# Ensure key properties match expectations # Ensure key properties match expectations

View File

@ -9,13 +9,12 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.ci as ci import spack.ci as ci
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.error import spack.error
import spack.paths as spack_paths import spack.paths as spack_paths
import spack.repo as repo import spack.repo as repo
import spack.spec
import spack.util.git import spack.util.git
from spack.spec import Spec
pytestmark = [pytest.mark.usefixtures("mock_packages")] pytestmark = [pytest.mark.usefixtures("mock_packages")]
@ -54,7 +53,7 @@ def test_pipeline_dag(config, tmpdir):
builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)]) builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)])
with repo.use_repositories(builder.root): with repo.use_repositories(builder.root):
spec_a = Spec("pkg-a").concretized() spec_a = spack.concretize.concretize_one("pkg-a")
key_a = ci.common.PipelineDag.key(spec_a) key_a = ci.common.PipelineDag.key(spec_a)
key_b = ci.common.PipelineDag.key(spec_a["pkg-b"]) key_b = ci.common.PipelineDag.key(spec_a["pkg-b"])
@ -449,7 +448,7 @@ def test_ci_run_standalone_tests_not_installed_junit(
log_file = tmp_path / "junit.xml" log_file = tmp_path / "junit.xml"
args = { args = {
"log_file": str(log_file), "log_file": str(log_file),
"job_spec": spack.spec.Spec("printing-package").concretized(), "job_spec": spack.concretize.concretize_one("printing-package"),
"repro_dir": str(repro_dir), "repro_dir": str(repro_dir),
"fail_fast": True, "fail_fast": True,
} }
@ -468,7 +467,7 @@ def test_ci_run_standalone_tests_not_installed_cdash(
log_file = tmp_path / "junit.xml" log_file = tmp_path / "junit.xml"
args = { args = {
"log_file": str(log_file), "log_file": str(log_file),
"job_spec": spack.spec.Spec("printing-package").concretized(), "job_spec": spack.concretize.concretize_one("printing-package"),
"repro_dir": str(repro_dir), "repro_dir": str(repro_dir),
} }
@ -501,7 +500,7 @@ def test_ci_run_standalone_tests_not_installed_cdash(
def test_ci_skipped_report(tmpdir, mock_packages, config): def test_ci_skipped_report(tmpdir, mock_packages, config):
"""Test explicit skipping of report as well as CI's 'package' arg.""" """Test explicit skipping of report as well as CI's 'package' arg."""
pkg = "trivial-smoke-test" pkg = "trivial-smoke-test"
spec = spack.spec.Spec(pkg).concretized() spec = spack.concretize.concretize_one(pkg)
ci_cdash = { ci_cdash = {
"url": "file://fake", "url": "file://fake",
"build-group": "fake-group", "build-group": "fake-group",

View File

@ -10,6 +10,7 @@
import spack.bootstrap import spack.bootstrap
import spack.bootstrap.core import spack.bootstrap.core
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.main import spack.main
@ -183,7 +184,7 @@ def test_bootstrap_mirror_metadata(mutable_config, linux_os, monkeypatch, tmpdir
""" """
old_create = spack.mirrors.utils.create old_create = spack.mirrors.utils.create
monkeypatch.setattr(spack.mirrors.utils, "create", lambda p, s: old_create(p, [])) monkeypatch.setattr(spack.mirrors.utils, "create", lambda p, s: old_create(p, []))
monkeypatch.setattr(spack.spec.Spec, "concretized", lambda p: p) monkeypatch.setattr(spack.concretize, "concretize_one", lambda p: spack.spec.Spec(p))
# Create the mirror in a temporary folder # Create the mirror in a temporary folder
compilers = [ compilers = [

View File

@ -12,6 +12,7 @@
import spack.binary_distribution import spack.binary_distribution
import spack.cmd.buildcache import spack.cmd.buildcache
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.error import spack.error
import spack.main import spack.main
@ -19,7 +20,6 @@
import spack.spec import spack.spec
import spack.util.url import spack.util.url
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.spec import Spec
buildcache = spack.main.SpackCommand("buildcache") buildcache = spack.main.SpackCommand("buildcache")
install = spack.main.SpackCommand("install") install = spack.main.SpackCommand("install")
@ -81,7 +81,7 @@ def tests_buildcache_create(install_mockery, mock_fetch, monkeypatch, tmpdir):
buildcache("push", "--unsigned", str(tmpdir), pkg) buildcache("push", "--unsigned", str(tmpdir), pkg)
spec = Spec(pkg).concretized() spec = spack.concretize.concretize_one(pkg)
tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack") tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack")
tarball = spack.binary_distribution.tarball_name(spec, ".spec.json") tarball = spack.binary_distribution.tarball_name(spec, ".spec.json")
assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path)) assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path))
@ -101,7 +101,7 @@ def tests_buildcache_create_env(
buildcache("push", "--unsigned", str(tmpdir)) buildcache("push", "--unsigned", str(tmpdir))
spec = Spec(pkg).concretized() spec = spack.concretize.concretize_one(pkg)
tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack") tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack")
tarball = spack.binary_distribution.tarball_name(spec, ".spec.json") tarball = spack.binary_distribution.tarball_name(spec, ".spec.json")
assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path)) assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path))
@ -145,7 +145,7 @@ def test_update_key_index(
gpg("create", "Test Signing Key", "nobody@nowhere.com") gpg("create", "Test Signing Key", "nobody@nowhere.com")
s = Spec("libdwarf").concretized() s = spack.concretize.concretize_one("libdwarf")
# Install a package # Install a package
install(s.name) install(s.name)
@ -175,7 +175,7 @@ def test_buildcache_autopush(tmp_path, install_mockery, mock_fetch):
mirror("add", "--unsigned", "mirror", mirror_dir.as_uri()) mirror("add", "--unsigned", "mirror", mirror_dir.as_uri())
mirror("add", "--autopush", "--unsigned", "mirror-autopush", mirror_autopush_dir.as_uri()) mirror("add", "--autopush", "--unsigned", "mirror-autopush", mirror_autopush_dir.as_uri())
s = Spec("libdwarf").concretized() s = spack.concretize.concretize_one("libdwarf")
# Install and generate build cache index # Install and generate build cache index
PackageInstaller([s.package], explicit=True).install() PackageInstaller([s.package], explicit=True).install()
@ -219,7 +219,7 @@ def verify_mirror_contents():
assert False assert False
# Install a package and put it in the buildcache # Install a package and put it in the buildcache
s = Spec(out_env_pkg).concretized() s = spack.concretize.concretize_one(out_env_pkg)
install(s.name) install(s.name)
buildcache("push", "-u", "-f", src_mirror_url, s.name) buildcache("push", "-u", "-f", src_mirror_url, s.name)
@ -329,7 +329,7 @@ def test_buildcache_create_install(
buildcache("push", "--unsigned", str(tmpdir), pkg) buildcache("push", "--unsigned", str(tmpdir), pkg)
spec = Spec(pkg).concretized() spec = spack.concretize.concretize_one(pkg)
tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack") tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack")
tarball = spack.binary_distribution.tarball_name(spec, ".spec.json") tarball = spack.binary_distribution.tarball_name(spec, ".spec.json")
assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path)) assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path))
@ -450,7 +450,7 @@ def test_push_and_install_with_mirror_marked_unsigned_does_not_require_extra_fla
def test_skip_no_redistribute(mock_packages, config): def test_skip_no_redistribute(mock_packages, config):
specs = list(Spec("no-redistribute-dependent").concretized().traverse()) specs = list(spack.concretize.concretize_one("no-redistribute-dependent").traverse())
filtered = spack.cmd.buildcache._skip_no_redistribute_for_public(specs) filtered = spack.cmd.buildcache._skip_no_redistribute_for_public(specs)
assert not any(s.name == "no-redistribute" for s in filtered) assert not any(s.name == "no-redistribute" for s in filtered)
assert any(s.name == "no-redistribute-dependent" for s in filtered) assert any(s.name == "no-redistribute-dependent" for s in filtered)
@ -490,7 +490,7 @@ def test_push_without_build_deps(tmp_path, temporary_store, mock_packages, mutab
mirror("add", "--unsigned", "my-mirror", str(tmp_path)) mirror("add", "--unsigned", "my-mirror", str(tmp_path))
s = spack.spec.Spec("dtrun3").concretized() s = spack.concretize.concretize_one("dtrun3")
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
s["dtbuild3"].package.do_uninstall() s["dtbuild3"].package.do_uninstall()

View File

@ -7,10 +7,10 @@
import pytest import pytest
import spack.cmd.checksum import spack.cmd.checksum
import spack.concretize
import spack.error import spack.error
import spack.package_base import spack.package_base
import spack.repo import spack.repo
import spack.spec
import spack.stage import spack.stage
import spack.util.web import spack.util.web
from spack.main import SpackCommand from spack.main import SpackCommand
@ -308,7 +308,7 @@ def test_checksum_url(mock_packages, config):
def test_checksum_verification_fails(default_mock_concretization, capsys, can_fetch_versions): def test_checksum_verification_fails(default_mock_concretization, capsys, can_fetch_versions):
spec = spack.spec.Spec("zlib").concretized() spec = spack.concretize.concretize_one("zlib")
pkg = spec.package pkg = spec.package
versions = list(pkg.versions.keys()) versions = list(pkg.versions.keys())
version_hashes = {versions[0]: "abadhash", Version("0.1"): "123456789"} version_hashes = {versions[0]: "abadhash", Version("0.1"): "123456789"}

View File

@ -18,6 +18,7 @@
import spack.ci as ci import spack.ci as ci
import spack.cmd import spack.cmd
import spack.cmd.ci import spack.cmd.ci
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.hash_types as ht import spack.hash_types as ht
import spack.main import spack.main
@ -1056,7 +1057,7 @@ def test_ci_rebuild_index(
with working_dir(tmp_path): with working_dir(tmp_path):
env_cmd("create", "test", "./spack.yaml") env_cmd("create", "test", "./spack.yaml")
with ev.read("test"): with ev.read("test"):
concrete_spec = Spec("callpath").concretized() concrete_spec = spack.concretize.concretize_one("callpath")
with open(tmp_path / "spec.json", "w", encoding="utf-8") as f: with open(tmp_path / "spec.json", "w", encoding="utf-8") as f:
f.write(concrete_spec.to_json(hash=ht.dag_hash)) f.write(concrete_spec.to_json(hash=ht.dag_hash))
@ -1177,12 +1178,10 @@ def test_ci_generate_read_broken_specs_url(
ci_base_environment, ci_base_environment,
): ):
"""Verify that `broken-specs-url` works as intended""" """Verify that `broken-specs-url` works as intended"""
spec_a = Spec("pkg-a") spec_a = spack.concretize.concretize_one("pkg-a")
spec_a.concretize()
a_dag_hash = spec_a.dag_hash() a_dag_hash = spec_a.dag_hash()
spec_flattendeps = Spec("flatten-deps") spec_flattendeps = spack.concretize.concretize_one("flatten-deps")
spec_flattendeps.concretize()
flattendeps_dag_hash = spec_flattendeps.dag_hash() flattendeps_dag_hash = spec_flattendeps.dag_hash()
broken_specs_url = tmp_path.as_uri() broken_specs_url = tmp_path.as_uri()
@ -1533,8 +1532,7 @@ def dynamic_mapping_setup(tmpdir):
""" """
) )
spec_a = Spec("pkg-a") spec_a = spack.concretize.concretize_one("pkg-a")
spec_a.concretize()
return gitlab_generator.get_job_name(spec_a) return gitlab_generator.get_job_name(spec_a)

View File

@ -10,10 +10,8 @@
import spack.caches import spack.caches
import spack.cmd.clean import spack.cmd.clean
import spack.environment as ev
import spack.main import spack.main
import spack.package_base import spack.package_base
import spack.spec
import spack.stage import spack.stage
import spack.store import spack.store
@ -69,20 +67,6 @@ def test_function_calls(command_line, effects, mock_calls_for_clean):
assert mock_calls_for_clean[name] == (1 if name in effects else 0) assert mock_calls_for_clean[name] == (1 if name in effects else 0)
def test_env_aware_clean(mock_stage, install_mockery, mutable_mock_env_path, monkeypatch):
e = ev.create("test", with_view=False)
e.add("mpileaks")
e.concretize()
def fail(*args, **kwargs):
raise Exception("This should not have been called")
monkeypatch.setattr(spack.spec.Spec, "concretize", fail)
with e:
clean("mpileaks")
def test_remove_python_cache(tmpdir, monkeypatch): def test_remove_python_cache(tmpdir, monkeypatch):
cache_files = ["file1.pyo", "file2.pyc"] cache_files = ["file1.pyo", "file2.pyc"]
source_file = "file1.py" source_file = "file1.py"

View File

@ -8,12 +8,12 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.concretize
import spack.config import spack.config
import spack.database import spack.database
import spack.environment as ev import spack.environment as ev
import spack.main import spack.main
import spack.schema.config import spack.schema.config
import spack.spec
import spack.store import spack.store
import spack.util.spack_yaml as syaml import spack.util.spack_yaml as syaml
@ -593,8 +593,7 @@ def test_config_prefer_upstream(
prepared_db = spack.database.Database(mock_db_root, layout=gen_mock_layout("/a/")) prepared_db = spack.database.Database(mock_db_root, layout=gen_mock_layout("/a/"))
for spec in ["hdf5 +mpi", "hdf5 ~mpi", "boost+debug~icu+graph", "dependency-install", "patch"]: for spec in ["hdf5 +mpi", "hdf5 ~mpi", "boost+debug~icu+graph", "dependency-install", "patch"]:
dep = spack.spec.Spec(spec) dep = spack.concretize.concretize_one(spec)
dep.concretize()
prepared_db.add(dep) prepared_db.add(dep)
downstream_db_root = str(tmpdir_factory.mktemp("mock_downstream_db_root")) downstream_db_root = str(tmpdir_factory.mktemp("mock_downstream_db_root"))

View File

@ -4,6 +4,7 @@
import pytest import pytest
import spack.concretize
import spack.spec import spack.spec
import spack.store import spack.store
from spack.enums import InstallRecordStatus from spack.enums import InstallRecordStatus
@ -66,8 +67,8 @@ def test_deprecate_deps(mock_packages, mock_archive, mock_fetch, install_mockery
install("libdwarf@20130729 ^libelf@0.8.13") install("libdwarf@20130729 ^libelf@0.8.13")
install("libdwarf@20130207 ^libelf@0.8.10") install("libdwarf@20130207 ^libelf@0.8.10")
new_spec = spack.spec.Spec("libdwarf@20130729^libelf@0.8.13").concretized() new_spec = spack.concretize.concretize_one("libdwarf@20130729^libelf@0.8.13")
old_spec = spack.spec.Spec("libdwarf@20130207^libelf@0.8.10").concretized() old_spec = spack.concretize.concretize_one("libdwarf@20130207^libelf@0.8.10")
all_installed = spack.store.STORE.db.query() all_installed = spack.store.STORE.db.query()
@ -107,12 +108,12 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, i
install("libelf@0.8.12") install("libelf@0.8.12")
install("libelf@0.8.10") install("libelf@0.8.10")
deprecated_spec = spack.spec.Spec("libelf@0.8.10").concretized() deprecated_spec = spack.concretize.concretize_one("libelf@0.8.10")
deprecate("-y", "libelf@0.8.10", "libelf@0.8.12") deprecate("-y", "libelf@0.8.10", "libelf@0.8.12")
deprecator = spack.store.STORE.db.deprecator(deprecated_spec) deprecator = spack.store.STORE.db.deprecator(deprecated_spec)
assert deprecator == spack.spec.Spec("libelf@0.8.12").concretized() assert deprecator == spack.concretize.concretize_one("libelf@0.8.12")
deprecate("-y", "libelf@0.8.10", "libelf@0.8.13") deprecate("-y", "libelf@0.8.10", "libelf@0.8.13")
@ -122,7 +123,7 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, i
assert len(all_available) == 3 assert len(all_available) == 3
deprecator = spack.store.STORE.db.deprecator(deprecated_spec) deprecator = spack.store.STORE.db.deprecator(deprecated_spec)
assert deprecator == spack.spec.Spec("libelf@0.8.13").concretized() assert deprecator == spack.concretize.concretize_one("libelf@0.8.13")
def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_mockery): def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_mockery):
@ -132,9 +133,9 @@ def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_m
install("libelf@0.8.12") install("libelf@0.8.12")
install("libelf@0.8.10") install("libelf@0.8.10")
first_deprecated_spec = spack.spec.Spec("libelf@0.8.10").concretized() first_deprecated_spec = spack.concretize.concretize_one("libelf@0.8.10")
second_deprecated_spec = spack.spec.Spec("libelf@0.8.12").concretized() second_deprecated_spec = spack.concretize.concretize_one("libelf@0.8.12")
final_deprecator = spack.spec.Spec("libelf@0.8.13").concretized() final_deprecator = spack.concretize.concretize_one("libelf@0.8.13")
deprecate("-y", "libelf@0.8.10", "libelf@0.8.12") deprecate("-y", "libelf@0.8.10", "libelf@0.8.12")
@ -164,7 +165,7 @@ def test_concretize_deprecated(mock_packages, mock_archive, mock_fetch, install_
spec = spack.spec.Spec("libelf@0.8.10") spec = spack.spec.Spec("libelf@0.8.10")
with pytest.raises(spack.spec.SpecDeprecatedError): with pytest.raises(spack.spec.SpecDeprecatedError):
spec.concretize() spack.concretize.concretize_one(spec)
@pytest.mark.usefixtures("mock_packages", "mock_archive", "mock_fetch", "install_mockery") @pytest.mark.usefixtures("mock_packages", "mock_archive", "mock_fetch", "install_mockery")

View File

@ -8,6 +8,7 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.error import spack.error
import spack.repo import spack.repo
@ -23,7 +24,9 @@
def test_dev_build_basics(tmpdir, install_mockery): def test_dev_build_basics(tmpdir, install_mockery):
spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}").concretized() spec = spack.concretize.concretize_one(
spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}")
)
assert "dev_path" in spec.variants assert "dev_path" in spec.variants
@ -41,7 +44,9 @@ def test_dev_build_basics(tmpdir, install_mockery):
def test_dev_build_before(tmpdir, install_mockery): def test_dev_build_before(tmpdir, install_mockery):
spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}").concretized() spec = spack.concretize.concretize_one(
spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}")
)
with tmpdir.as_cwd(): with tmpdir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -57,7 +62,9 @@ def test_dev_build_before(tmpdir, install_mockery):
def test_dev_build_until(tmpdir, install_mockery): def test_dev_build_until(tmpdir, install_mockery):
spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}").concretized() spec = spack.concretize.concretize_one(
spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}")
)
with tmpdir.as_cwd(): with tmpdir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -75,7 +82,9 @@ def test_dev_build_until(tmpdir, install_mockery):
def test_dev_build_until_last_phase(tmpdir, install_mockery): def test_dev_build_until_last_phase(tmpdir, install_mockery):
# Test that we ignore the last_phase argument if it is already last # Test that we ignore the last_phase argument if it is already last
spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}").concretized() spec = spack.concretize.concretize_one(
spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}")
)
with tmpdir.as_cwd(): with tmpdir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -93,7 +102,9 @@ def test_dev_build_until_last_phase(tmpdir, install_mockery):
def test_dev_build_before_until(tmpdir, install_mockery): def test_dev_build_before_until(tmpdir, install_mockery):
spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}").concretized() spec = spack.concretize.concretize_one(
spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}")
)
with tmpdir.as_cwd(): with tmpdir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -129,8 +140,9 @@ def test_dev_build_drop_in(tmpdir, mock_packages, monkeypatch, install_mockery,
def test_dev_build_fails_already_installed(tmpdir, install_mockery): def test_dev_build_fails_already_installed(tmpdir, install_mockery):
spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir) spec = spack.concretize.concretize_one(
spec.concretize() spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir)
)
with tmpdir.as_cwd(): with tmpdir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -172,8 +184,9 @@ def test_dev_build_env(tmpdir, install_mockery, mutable_mock_env_path):
"""Test Spack does dev builds for packages in develop section of env.""" """Test Spack does dev builds for packages in develop section of env."""
# setup dev-build-test-install package for dev build # setup dev-build-test-install package for dev build
build_dir = tmpdir.mkdir("build") build_dir = tmpdir.mkdir("build")
spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir) spec = spack.concretize.concretize_one(
spec.concretize() spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir)
)
with build_dir.as_cwd(): with build_dir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -208,8 +221,9 @@ def test_dev_build_env_with_vars(tmpdir, install_mockery, mutable_mock_env_path,
"""Test Spack does dev builds for packages in develop section of env (path with variables).""" """Test Spack does dev builds for packages in develop section of env (path with variables)."""
# setup dev-build-test-install package for dev build # setup dev-build-test-install package for dev build
build_dir = tmpdir.mkdir("build") build_dir = tmpdir.mkdir("build")
spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={build_dir}") spec = spack.concretize.concretize_one(
spec.concretize() spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={build_dir}")
)
# store the build path in an environment variable that will be used in the environment # store the build path in an environment variable that will be used in the environment
monkeypatch.setenv("CUSTOM_BUILD_PATH", build_dir) monkeypatch.setenv("CUSTOM_BUILD_PATH", build_dir)
@ -246,8 +260,9 @@ def test_dev_build_env_version_mismatch(tmpdir, install_mockery, mutable_mock_en
"""Test Spack constraints concretization by develop specs.""" """Test Spack constraints concretization by develop specs."""
# setup dev-build-test-install package for dev build # setup dev-build-test-install package for dev build
build_dir = tmpdir.mkdir("build") build_dir = tmpdir.mkdir("build")
spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir) spec = spack.concretize.concretize_one(
spec.concretize() spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir)
)
with build_dir.as_cwd(): with build_dir.as_cwd():
with open(spec.package.filename, "w", encoding="utf-8") as f: with open(spec.package.filename, "w", encoding="utf-8") as f:
@ -327,8 +342,8 @@ def test_dev_build_multiple(tmpdir, install_mockery, mutable_mock_env_path, mock
with ev.read("test"): with ev.read("test"):
# Do concretization inside environment for dev info # Do concretization inside environment for dev info
# These specs are the source of truth to compare against the installs # These specs are the source of truth to compare against the installs
leaf_spec.concretize() leaf_spec = spack.concretize.concretize_one(leaf_spec)
root_spec.concretize() root_spec = spack.concretize.concretize_one(root_spec)
# Do install # Do install
install() install()
@ -374,8 +389,8 @@ def test_dev_build_env_dependency(tmpdir, install_mockery, mock_fetch, mutable_m
# concretize in the environment to get the dev build info # concretize in the environment to get the dev build info
# equivalent to setting dev_build and dev_path variants # equivalent to setting dev_build and dev_path variants
# on all specs above # on all specs above
spec.concretize() spec = spack.concretize.concretize_one(spec)
dep_spec.concretize() dep_spec = spack.concretize.concretize_one(dep_spec)
install() install()
# Ensure that both specs installed properly # Ensure that both specs installed properly
@ -399,8 +414,9 @@ def test_dev_build_rebuild_on_source_changes(
""" """
# setup dev-build-test-install package for dev build # setup dev-build-test-install package for dev build
build_dir = tmpdir.mkdir("build") build_dir = tmpdir.mkdir("build")
spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir) spec = spack.concretize.concretize_one(
spec.concretize() spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir)
)
def reset_string(): def reset_string():
with build_dir.as_cwd(): with build_dir.as_cwd():

View File

@ -8,6 +8,7 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.package_base import spack.package_base
@ -138,7 +139,8 @@ def check_path(stage, dest):
self.check_develop(e, spack.spec.Spec("mpich@=1.0"), path) self.check_develop(e, spack.spec.Spec("mpich@=1.0"), path)
# Check modifications actually worked # Check modifications actually worked
assert spack.spec.Spec("mpich@1.0").concretized().satisfies("dev_path=%s" % abspath) result = spack.concretize.concretize_one("mpich@1.0")
assert result.satisfies("dev_path=%s" % abspath)
def test_develop_canonicalize_path_no_args(self, monkeypatch): def test_develop_canonicalize_path_no_args(self, monkeypatch):
env("create", "test") env("create", "test")
@ -165,7 +167,8 @@ def check_path(stage, dest):
self.check_develop(e, spack.spec.Spec("mpich@=1.0"), path) self.check_develop(e, spack.spec.Spec("mpich@=1.0"), path)
# Check modifications actually worked # Check modifications actually worked
assert spack.spec.Spec("mpich@1.0").concretized().satisfies("dev_path=%s" % abspath) result = spack.concretize.concretize_one("mpich@1.0")
assert result.satisfies("dev_path=%s" % abspath)
def _git_commit_list(git_repo_dir): def _git_commit_list(git_repo_dir):
@ -190,7 +193,7 @@ def test_develop_full_git_repo(
spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False
) )
spec = spack.spec.Spec("git-test-commit@1.2").concretized() spec = spack.concretize.concretize_one("git-test-commit@1.2")
try: try:
spec.package.do_stage() spec.package.do_stage()
commits = _git_commit_list(spec.package.stage[0].source_path) commits = _git_commit_list(spec.package.stage[0].source_path)

View File

@ -5,9 +5,9 @@
import pytest import pytest
import spack.cmd.diff import spack.cmd.diff
import spack.concretize
import spack.main import spack.main
import spack.repo import spack.repo
import spack.spec
import spack.util.spack_json as sjson import spack.util.spack_json as sjson
from spack.test.conftest import create_test_repo from spack.test.conftest import create_test_repo
@ -133,8 +133,8 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage):
def test_diff_ignore(test_repo): def test_diff_ignore(test_repo):
specA = spack.spec.Spec("p1+usev1").concretized() specA = spack.concretize.concretize_one("p1+usev1")
specB = spack.spec.Spec("p1~usev1").concretized() specB = spack.concretize.concretize_one("p1~usev1")
c1 = spack.cmd.diff.compare_specs(specA, specB, to_string=False) c1 = spack.cmd.diff.compare_specs(specA, specB, to_string=False)
@ -154,8 +154,8 @@ def find(function_list, name, args):
# Check ignoring changes on multiple packages # Check ignoring changes on multiple packages
specA = spack.spec.Spec("p1+usev1 ^p3+p3var").concretized() specA = spack.concretize.concretize_one("p1+usev1 ^p3+p3var")
specA = spack.spec.Spec("p1~usev1 ^p3~p3var").concretized() specA = spack.concretize.concretize_one("p1~usev1 ^p3~p3var")
c3 = spack.cmd.diff.compare_specs(specA, specB, to_string=False) c3 = spack.cmd.diff.compare_specs(specA, specB, to_string=False)
assert find(c3["a_not_b"], "variant_value", ["p3", "p3var"]) assert find(c3["a_not_b"], "variant_value", ["p3", "p3var"])
@ -168,8 +168,8 @@ def find(function_list, name, args):
def test_diff_cmd(install_mockery, mock_fetch, mock_archive, mock_packages): def test_diff_cmd(install_mockery, mock_fetch, mock_archive, mock_packages):
"""Test that we can install two packages and diff them""" """Test that we can install two packages and diff them"""
specA = spack.spec.Spec("mpileaks").concretized() specA = spack.concretize.concretize_one("mpileaks")
specB = spack.spec.Spec("mpileaks+debug").concretized() specB = spack.concretize.concretize_one("mpileaks+debug")
# Specs should be the same as themselves # Specs should be the same as themselves
c = spack.cmd.diff.compare_specs(specA, specA, to_string=True) c = spack.cmd.diff.compare_specs(specA, specA, to_string=True)

View File

@ -19,6 +19,7 @@
from llnl.util.symlink import readlink from llnl.util.symlink import readlink
import spack.cmd.env import spack.cmd.env
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.environment.depfile as depfile import spack.environment.depfile as depfile
@ -957,7 +958,7 @@ def test_lockfile_spliced_specs(environment_from_manifest, install_mockery):
"""Test that an environment can round-trip a spliced spec.""" """Test that an environment can round-trip a spliced spec."""
# Create a local install for zmpi to splice in # Create a local install for zmpi to splice in
# Default concretization is not using zmpi # Default concretization is not using zmpi
zmpi = spack.spec.Spec("zmpi").concretized() zmpi = spack.concretize.concretize_one("zmpi")
PackageInstaller([zmpi.package], fake=True).install() PackageInstaller([zmpi.package], fake=True).install()
e1 = environment_from_manifest( e1 = environment_from_manifest(
@ -1320,39 +1321,43 @@ def test_config_change_existing(mutable_mock_env_path, tmp_path, mock_packages,
with e: with e:
# List of requirements, flip a variant # List of requirements, flip a variant
config("change", "packages:mpich:require:~debug") config("change", "packages:mpich:require:~debug")
test_spec = spack.spec.Spec("mpich").concretized() test_spec = spack.concretize.concretize_one("mpich")
assert test_spec.satisfies("@3.0.2~debug") assert test_spec.satisfies("@3.0.2~debug")
# List of requirements, change the version (in a different scope) # List of requirements, change the version (in a different scope)
config("change", "packages:mpich:require:@3.0.3") config("change", "packages:mpich:require:@3.0.3")
test_spec = spack.spec.Spec("mpich").concretized() test_spec = spack.concretize.concretize_one("mpich")
assert test_spec.satisfies("@3.0.3") assert test_spec.satisfies("@3.0.3")
# "require:" as a single string, also try specifying # "require:" as a single string, also try specifying
# a spec string that requires enclosing in quotes as # a spec string that requires enclosing in quotes as
# part of the config path # part of the config path
config("change", 'packages:libelf:require:"@0.8.12:"') config("change", 'packages:libelf:require:"@0.8.12:"')
spack.spec.Spec("libelf@0.8.12").concretized() spack.concretize.concretize_one("libelf@0.8.12")
# No need for assert, if there wasn't a failure, we # No need for assert, if there wasn't a failure, we
# changed the requirement successfully. # changed the requirement successfully.
# Use change to add a requirement for a package that # Use change to add a requirement for a package that
# has no requirements defined # has no requirements defined
config("change", "packages:fftw:require:+mpi") config("change", "packages:fftw:require:+mpi")
test_spec = spack.spec.Spec("fftw").concretized() test_spec = spack.concretize.concretize_one("fftw")
assert test_spec.satisfies("+mpi") assert test_spec.satisfies("+mpi")
config("change", "packages:fftw:require:~mpi") config("change", "packages:fftw:require:~mpi")
test_spec = spack.spec.Spec("fftw").concretized() test_spec = spack.concretize.concretize_one("fftw")
assert test_spec.satisfies("~mpi") assert test_spec.satisfies("~mpi")
config("change", "packages:fftw:require:@1.0") config("change", "packages:fftw:require:@1.0")
test_spec = spack.spec.Spec("fftw").concretized() test_spec = spack.concretize.concretize_one("fftw")
assert test_spec.satisfies("@1.0~mpi") assert test_spec.satisfies("@1.0~mpi")
# Use "--match-spec" to change one spec in a "one_of" # Use "--match-spec" to change one spec in a "one_of"
# list # list
config("change", "packages:bowtie:require:@1.2.2", "--match-spec", "@1.2.0") config("change", "packages:bowtie:require:@1.2.2", "--match-spec", "@1.2.0")
spack.spec.Spec("bowtie@1.3.0").concretize() # confirm that we can concretize to either value
spack.spec.Spec("bowtie@1.2.2").concretized() spack.concretize.concretize_one("bowtie@1.3.0")
spack.concretize.concretize_one("bowtie@1.2.2")
# confirm that we cannot concretize to the old value
with pytest.raises(spack.solver.asp.UnsatisfiableSpecError):
spack.concretize.concretize_one("bowtie@1.2.0")
def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutable_config): def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutable_config):
@ -1367,8 +1372,8 @@ def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutab
with ev.Environment(tmp_path): with ev.Environment(tmp_path):
config("change", "packages:mpich:require:~debug") config("change", "packages:mpich:require:~debug")
with pytest.raises(spack.solver.asp.UnsatisfiableSpecError): with pytest.raises(spack.solver.asp.UnsatisfiableSpecError):
spack.spec.Spec("mpich+debug").concretized() spack.concretize.concretize_one("mpich+debug")
spack.spec.Spec("mpich~debug").concretized() spack.concretize.concretize_one("mpich~debug")
# Now check that we raise an error if we need to add a require: constraint # Now check that we raise an error if we need to add a require: constraint
# when preexisting config manually specified it as a singular spec # when preexisting config manually specified it as a singular spec
@ -1382,7 +1387,7 @@ def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutab
""" """
) )
with ev.Environment(tmp_path): with ev.Environment(tmp_path):
assert spack.spec.Spec("mpich").concretized().satisfies("@3.0.3") assert spack.concretize.concretize_one("mpich").satisfies("@3.0.3")
with pytest.raises(spack.error.ConfigError, match="not a list"): with pytest.raises(spack.error.ConfigError, match="not a list"):
config("change", "packages:mpich:require:~debug") config("change", "packages:mpich:require:~debug")
@ -1690,7 +1695,7 @@ def test_stage(mock_stage, mock_fetch, install_mockery):
root = str(mock_stage) root = str(mock_stage)
def check_stage(spec): def check_stage(spec):
spec = Spec(spec).concretized() spec = spack.concretize.concretize_one(spec)
for dep in spec.traverse(): for dep in spec.traverse():
stage_name = f"{stage_prefix}{dep.name}-{dep.version}-{dep.dag_hash()}" stage_name = f"{stage_prefix}{dep.name}-{dep.version}-{dep.dag_hash()}"
assert os.path.isdir(os.path.join(root, stage_name)) assert os.path.isdir(os.path.join(root, stage_name))
@ -1791,7 +1796,7 @@ def test_indirect_build_dep(tmp_path):
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
x_spec = Spec("x") x_spec = Spec("x")
x_concretized = x_spec.concretized() x_concretized = spack.concretize.concretize_one(x_spec)
_env_create("test", with_view=False) _env_create("test", with_view=False)
e = ev.read("test") e = ev.read("test")
@ -1824,10 +1829,10 @@ def test_store_different_build_deps(tmp_path):
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
y_spec = Spec("y ^z@3") y_spec = Spec("y ^z@3")
y_concretized = y_spec.concretized() y_concretized = spack.concretize.concretize_one(y_spec)
x_spec = Spec("x ^z@2") x_spec = Spec("x ^z@2")
x_concretized = x_spec.concretized() x_concretized = spack.concretize.concretize_one(x_spec)
# Even though x chose a different 'z', the y it chooses should be identical # Even though x chose a different 'z', the y it chooses should be identical
# *aside* from the dependency on 'z'. The dag_hash() will show the difference # *aside* from the dependency on 'z'. The dag_hash() will show the difference

View File

@ -5,16 +5,18 @@
import pytest import pytest
import spack.concretize
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.main import SpackCommand, SpackCommandError from spack.main import SpackCommand, SpackCommandError
from spack.spec import Spec
extensions = SpackCommand("extensions") extensions = SpackCommand("extensions")
@pytest.fixture @pytest.fixture
def python_database(mock_packages, mutable_database): def python_database(mock_packages, mutable_database):
specs = [Spec(s).concretized() for s in ["python", "py-extension1", "py-extension2"]] specs = [
spack.concretize.concretize_one(s) for s in ["python", "py-extension1", "py-extension2"]
]
PackageInstaller([s.package for s in specs], explicit=True, fake=True).install() PackageInstaller([s.package for s in specs], explicit=True, fake=True).install()
yield yield
@ -22,7 +24,7 @@ def python_database(mock_packages, mutable_database):
@pytest.mark.not_on_windows("All Fetchers Failed") @pytest.mark.not_on_windows("All Fetchers Failed")
@pytest.mark.db @pytest.mark.db
def test_extensions(mock_packages, python_database, capsys): def test_extensions(mock_packages, python_database, capsys):
ext2 = Spec("py-extension2").concretized() ext2 = spack.concretize.concretize_one("py-extension2")
def check_output(ni): def check_output(ni):
with capsys.disabled(): with capsys.disabled():

View File

@ -12,13 +12,13 @@
import spack.cmd as cmd import spack.cmd as cmd
import spack.cmd.find import spack.cmd.find
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.repo import spack.repo
import spack.store import spack.store
import spack.user_environment as uenv import spack.user_environment as uenv
from spack.enums import InstallRecordStatus from spack.enums import InstallRecordStatus
from spack.main import SpackCommand from spack.main import SpackCommand
from spack.spec import Spec
from spack.test.conftest import create_test_repo from spack.test.conftest import create_test_repo
from spack.test.utilities import SpackCommandArgs from spack.test.utilities import SpackCommandArgs
from spack.util.pattern import Bunch from spack.util.pattern import Bunch
@ -201,7 +201,8 @@ def test_find_json_deps(database):
@pytest.mark.db @pytest.mark.db
def test_display_json(database, capsys): def test_display_json(database, capsys):
specs = [ specs = [
Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] spack.concretize.concretize_one(s)
for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"]
] ]
cmd.display_specs_as_json(specs) cmd.display_specs_as_json(specs)
@ -216,7 +217,8 @@ def test_display_json(database, capsys):
@pytest.mark.db @pytest.mark.db
def test_display_json_deps(database, capsys): def test_display_json_deps(database, capsys):
specs = [ specs = [
Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] spack.concretize.concretize_one(s)
for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"]
] ]
cmd.display_specs_as_json(specs, deps=True) cmd.display_specs_as_json(specs, deps=True)
@ -275,7 +277,7 @@ def test_find_format_deps(database, config):
def test_find_format_deps_paths(database, config): def test_find_format_deps_paths(database, config):
output = find("-dp", "--format", "{name}-{version}", "mpileaks", "^zmpi") output = find("-dp", "--format", "{name}-{version}", "mpileaks", "^zmpi")
spec = Spec("mpileaks ^zmpi").concretized() spec = spack.concretize.concretize_one("mpileaks ^zmpi")
prefixes = [s.prefix for s in spec.traverse()] prefixes = [s.prefix for s in spec.traverse()]
assert ( assert (
@ -300,7 +302,8 @@ def test_find_very_long(database, config):
output = find("-L", "--no-groups", "mpileaks") output = find("-L", "--no-groups", "mpileaks")
specs = [ specs = [
Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] spack.concretize.concretize_one(s)
for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"]
] ]
assert set(output.strip().split("\n")) == set( assert set(output.strip().split("\n")) == set(

View File

@ -5,6 +5,7 @@
import pytest import pytest
import spack.concretize
import spack.deptypes as dt import spack.deptypes as dt
import spack.environment as ev import spack.environment as ev
import spack.main import spack.main
@ -25,8 +26,7 @@ def test_gc_without_build_dependency(mutable_database):
@pytest.mark.db @pytest.mark.db
def test_gc_with_build_dependency(mutable_database): def test_gc_with_build_dependency(mutable_database):
s = spack.spec.Spec("simple-inheritance") s = spack.concretize.concretize_one("simple-inheritance")
s.concretize()
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
assert "There are no unused specs." in gc("-yb") assert "There are no unused specs." in gc("-yb")
@ -36,8 +36,8 @@ def test_gc_with_build_dependency(mutable_database):
@pytest.mark.db @pytest.mark.db
def test_gc_with_constraints(mutable_database): def test_gc_with_constraints(mutable_database):
s_cmake1 = spack.spec.Spec("simple-inheritance ^cmake@3.4.3").concretized() s_cmake1 = spack.concretize.concretize_one("simple-inheritance ^cmake@3.4.3")
s_cmake2 = spack.spec.Spec("simple-inheritance ^cmake@3.23.1").concretized() s_cmake2 = spack.concretize.concretize_one("simple-inheritance ^cmake@3.23.1")
PackageInstaller([s_cmake1.package], explicit=True, fake=True).install() PackageInstaller([s_cmake1.package], explicit=True, fake=True).install()
PackageInstaller([s_cmake2.package], explicit=True, fake=True).install() PackageInstaller([s_cmake2.package], explicit=True, fake=True).install()
@ -52,8 +52,7 @@ def test_gc_with_constraints(mutable_database):
@pytest.mark.db @pytest.mark.db
def test_gc_with_environment(mutable_database, mutable_mock_env_path): def test_gc_with_environment(mutable_database, mutable_mock_env_path):
s = spack.spec.Spec("simple-inheritance") s = spack.concretize.concretize_one("simple-inheritance")
s.concretize()
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
e = ev.create("test_gc") e = ev.create("test_gc")
@ -68,8 +67,7 @@ def test_gc_with_environment(mutable_database, mutable_mock_env_path):
@pytest.mark.db @pytest.mark.db
def test_gc_with_build_dependency_in_environment(mutable_database, mutable_mock_env_path): def test_gc_with_build_dependency_in_environment(mutable_database, mutable_mock_env_path):
s = spack.spec.Spec("simple-inheritance") s = spack.concretize.concretize_one("simple-inheritance")
s.concretize()
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
e = ev.create("test_gc") e = ev.create("test_gc")
@ -120,8 +118,7 @@ def test_gc_except_any_environments(mutable_database, mutable_mock_env_path):
@pytest.mark.db @pytest.mark.db
def test_gc_except_specific_environments(mutable_database, mutable_mock_env_path): def test_gc_except_specific_environments(mutable_database, mutable_mock_env_path):
s = spack.spec.Spec("simple-inheritance") s = spack.concretize.concretize_one("simple-inheritance")
s.concretize()
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
assert mutable_database.query_local("zmpi") assert mutable_database.query_local("zmpi")
@ -147,8 +144,7 @@ def test_gc_except_nonexisting_dir_env(mutable_database, mutable_mock_env_path,
@pytest.mark.db @pytest.mark.db
def test_gc_except_specific_dir_env(mutable_database, mutable_mock_env_path, tmpdir): def test_gc_except_specific_dir_env(mutable_database, mutable_mock_env_path, tmpdir):
s = spack.spec.Spec("simple-inheritance") s = spack.concretize.concretize_one("simple-inheritance")
s.concretize()
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
assert mutable_database.query_local("zmpi") assert mutable_database.query_local("zmpi")

View File

@ -19,6 +19,7 @@
import spack.build_environment import spack.build_environment
import spack.cmd.common.arguments import spack.cmd.common.arguments
import spack.cmd.install import spack.cmd.install
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.error import spack.error
@ -134,7 +135,7 @@ def test_package_output(tmpdir, capsys, install_mockery, mock_fetch):
# we can't use output capture here because it interferes with Spack's # we can't use output capture here because it interferes with Spack's
# logging. TODO: see whether we can get multiple log_outputs to work # logging. TODO: see whether we can get multiple log_outputs to work
# when nested AND in pytest # when nested AND in pytest
spec = Spec("printing-package").concretized() spec = spack.concretize.concretize_one("printing-package")
pkg = spec.package pkg = spec.package
PackageInstaller([pkg], explicit=True, verbose=True).install() PackageInstaller([pkg], explicit=True, verbose=True).install()
@ -174,7 +175,7 @@ def test_install_output_on_python_error(mock_packages, mock_archive, mock_fetch,
def test_install_with_source(mock_packages, mock_archive, mock_fetch, install_mockery): def test_install_with_source(mock_packages, mock_archive, mock_fetch, install_mockery):
"""Verify that source has been copied into place.""" """Verify that source has been copied into place."""
install("--source", "--keep-stage", "trivial-install-test-package") install("--source", "--keep-stage", "trivial-install-test-package")
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
src = os.path.join(spec.prefix.share, "trivial-install-test-package", "src") src = os.path.join(spec.prefix.share, "trivial-install-test-package", "src")
assert filecmp.cmp( assert filecmp.cmp(
os.path.join(mock_archive.path, "configure"), os.path.join(src, "configure") os.path.join(mock_archive.path, "configure"), os.path.join(src, "configure")
@ -182,8 +183,7 @@ def test_install_with_source(mock_packages, mock_archive, mock_fetch, install_mo
def test_install_env_variables(mock_packages, mock_archive, mock_fetch, install_mockery): def test_install_env_variables(mock_packages, mock_archive, mock_fetch, install_mockery):
spec = Spec("libdwarf") spec = spack.concretize.concretize_one("libdwarf")
spec.concretize()
install("libdwarf") install("libdwarf")
assert os.path.isfile(spec.package.install_env_path) assert os.path.isfile(spec.package.install_env_path)
@ -204,8 +204,7 @@ def test_show_log_on_error(mock_packages, mock_archive, mock_fetch, install_mock
def test_install_overwrite(mock_packages, mock_archive, mock_fetch, install_mockery): def test_install_overwrite(mock_packages, mock_archive, mock_fetch, install_mockery):
# Try to install a spec and then to reinstall it. # Try to install a spec and then to reinstall it.
spec = Spec("libdwarf") spec = spack.concretize.concretize_one("libdwarf")
spec.concretize()
install("libdwarf") install("libdwarf")
@ -238,8 +237,7 @@ def test_install_overwrite(mock_packages, mock_archive, mock_fetch, install_mock
def test_install_overwrite_not_installed(mock_packages, mock_archive, mock_fetch, install_mockery): def test_install_overwrite_not_installed(mock_packages, mock_archive, mock_fetch, install_mockery):
# Try to install a spec and then to reinstall it. # Try to install a spec and then to reinstall it.
spec = Spec("libdwarf") spec = spack.concretize.concretize_one("libdwarf")
spec.concretize()
assert not os.path.exists(spec.prefix) assert not os.path.exists(spec.prefix)
@ -260,7 +258,7 @@ def test_install_commit(mock_git_version_info, install_mockery, mock_packages, m
monkeypatch.setattr(spack.package_base.PackageBase, "git", file_url, raising=False) monkeypatch.setattr(spack.package_base.PackageBase, "git", file_url, raising=False)
# Use the earliest commit in the respository # Use the earliest commit in the respository
spec = Spec(f"git-test-commit@{commits[-1]}").concretized() spec = spack.concretize.concretize_one(f"git-test-commit@{commits[-1]}")
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
# Ensure first commit file contents were written # Ensure first commit file contents were written
@ -273,13 +271,11 @@ def test_install_commit(mock_git_version_info, install_mockery, mock_packages, m
def test_install_overwrite_multiple(mock_packages, mock_archive, mock_fetch, install_mockery): def test_install_overwrite_multiple(mock_packages, mock_archive, mock_fetch, install_mockery):
# Try to install a spec and then to reinstall it. # Try to install a spec and then to reinstall it.
libdwarf = Spec("libdwarf") libdwarf = spack.concretize.concretize_one("libdwarf")
libdwarf.concretize()
install("libdwarf") install("libdwarf")
cmake = Spec("cmake") cmake = spack.concretize.concretize_one("cmake")
cmake.concretize()
install("cmake") install("cmake")
@ -355,7 +351,7 @@ def test_install_invalid_spec():
) )
def test_install_from_file(spec, concretize, error_code, tmpdir): def test_install_from_file(spec, concretize, error_code, tmpdir):
if concretize: if concretize:
spec.concretize() spec = spack.concretize.concretize_one(spec)
specfile = tmpdir.join("spec.yaml") specfile = tmpdir.join("spec.yaml")
@ -485,8 +481,7 @@ def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir):
for spec in filespecs: for spec in filespecs:
filepath = tmpdir.join(spec + ".yaml") filepath = tmpdir.join(spec + ".yaml")
args = ["-f", str(filepath)] + args args = ["-f", str(filepath)] + args
s = Spec(spec) s = spack.concretize.concretize_one(spec)
s.concretize()
with filepath.open("w") as f: with filepath.open("w") as f:
s.to_yaml(f) s.to_yaml(f)
@ -495,8 +490,7 @@ def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir):
def test_extra_files_are_archived(mock_packages, mock_archive, mock_fetch, install_mockery): def test_extra_files_are_archived(mock_packages, mock_archive, mock_fetch, install_mockery):
s = Spec("archive-files") s = spack.concretize.concretize_one("archive-files")
s.concretize()
install("archive-files") install("archive-files")
@ -615,8 +609,7 @@ def test_cdash_install_from_spec_json(
with capfd.disabled(), tmpdir.as_cwd(): with capfd.disabled(), tmpdir.as_cwd():
spec_json_path = str(tmpdir.join("spec.json")) spec_json_path = str(tmpdir.join("spec.json"))
pkg_spec = Spec("pkg-a") pkg_spec = spack.concretize.concretize_one("pkg-a")
pkg_spec.concretize()
with open(spec_json_path, "w", encoding="utf-8") as fd: with open(spec_json_path, "w", encoding="utf-8") as fd:
fd.write(pkg_spec.to_json(hash=ht.dag_hash)) fd.write(pkg_spec.to_json(hash=ht.dag_hash))
@ -692,8 +685,8 @@ def test_cache_only_fails(tmpdir, mock_fetch, install_mockery, capfd):
def test_install_only_dependencies(tmpdir, mock_fetch, install_mockery): def test_install_only_dependencies(tmpdir, mock_fetch, install_mockery):
dep = Spec("dependency-install").concretized() dep = spack.concretize.concretize_one("dependency-install")
root = Spec("dependent-install").concretized() root = spack.concretize.concretize_one("dependent-install")
install("--only", "dependencies", "dependent-install") install("--only", "dependencies", "dependent-install")
@ -714,8 +707,8 @@ def test_install_only_package(tmpdir, mock_fetch, install_mockery, capfd):
def test_install_deps_then_package(tmpdir, mock_fetch, install_mockery): def test_install_deps_then_package(tmpdir, mock_fetch, install_mockery):
dep = Spec("dependency-install").concretized() dep = spack.concretize.concretize_one("dependency-install")
root = Spec("dependent-install").concretized() root = spack.concretize.concretize_one("dependent-install")
install("--only", "dependencies", "dependent-install") install("--only", "dependencies", "dependent-install")
assert os.path.exists(dep.prefix) assert os.path.exists(dep.prefix)
@ -733,8 +726,8 @@ def test_install_only_dependencies_in_env(
env("create", "test") env("create", "test")
with ev.read("test"): with ev.read("test"):
dep = Spec("dependency-install").concretized() dep = spack.concretize.concretize_one("dependency-install")
root = Spec("dependent-install").concretized() root = spack.concretize.concretize_one("dependent-install")
install("-v", "--only", "dependencies", "--add", "dependent-install") install("-v", "--only", "dependencies", "--add", "dependent-install")
@ -750,8 +743,8 @@ def test_install_only_dependencies_of_all_in_env(
with ev.read("test"): with ev.read("test"):
roots = [ roots = [
Spec("dependent-install@1.0").concretized(), spack.concretize.concretize_one("dependent-install@1.0"),
Spec("dependent-install@2.0").concretized(), spack.concretize.concretize_one("dependent-install@2.0"),
] ]
add("dependent-install@1.0") add("dependent-install@1.0")
@ -900,7 +893,7 @@ def test_cdash_configure_warning(tmpdir, mock_fetch, install_mockery, capfd):
# Ensure that even on non-x86_64 architectures, there are no # Ensure that even on non-x86_64 architectures, there are no
# dependencies installed # dependencies installed
spec = Spec("configure-warning").concretized() spec = spack.concretize.concretize_one("configure-warning")
spec.clear_dependencies() spec.clear_dependencies()
specfile = "./spec.json" specfile = "./spec.json"
with open(specfile, "w", encoding="utf-8") as f: with open(specfile, "w", encoding="utf-8") as f:
@ -946,7 +939,7 @@ def test_install_env_with_tests_all(
): ):
env("create", "test") env("create", "test")
with ev.read("test"): with ev.read("test"):
test_dep = Spec("test-dependency").concretized() test_dep = spack.concretize.concretize_one("test-dependency")
add("depb") add("depb")
install("--test", "all") install("--test", "all")
assert os.path.exists(test_dep.prefix) assert os.path.exists(test_dep.prefix)
@ -958,7 +951,7 @@ def test_install_env_with_tests_root(
): ):
env("create", "test") env("create", "test")
with ev.read("test"): with ev.read("test"):
test_dep = Spec("test-dependency").concretized() test_dep = spack.concretize.concretize_one("test-dependency")
add("depb") add("depb")
install("--test", "root") install("--test", "root")
assert not os.path.exists(test_dep.prefix) assert not os.path.exists(test_dep.prefix)

View File

@ -7,7 +7,7 @@
import pytest import pytest
import spack.spec import spack.concretize
import spack.user_environment as uenv import spack.user_environment as uenv
from spack.main import SpackCommand from spack.main import SpackCommand
@ -49,7 +49,7 @@ def test_load_shell(shell, set_command):
"""Test that `spack load` applies prefix inspections of its required runtime deps in """Test that `spack load` applies prefix inspections of its required runtime deps in
topo-order""" topo-order"""
install("mpileaks") install("mpileaks")
mpileaks_spec = spack.spec.Spec("mpileaks").concretized() mpileaks_spec = spack.concretize.concretize_one("mpileaks")
# Ensure our reference variable is clean. # Ensure our reference variable is clean.
os.environ["CMAKE_PREFIX_PATH"] = "/hello" + os.pathsep + "/world" os.environ["CMAKE_PREFIX_PATH"] = "/hello" + os.pathsep + "/world"
@ -166,7 +166,7 @@ def test_unload(
"""Tests that any variables set in the user environment are undone by the """Tests that any variables set in the user environment are undone by the
unload command""" unload command"""
install("mpileaks") install("mpileaks")
mpileaks_spec = spack.spec.Spec("mpileaks").concretized() mpileaks_spec = spack.concretize.concretize_one("mpileaks")
# Set so unload has something to do # Set so unload has something to do
os.environ["FOOBAR"] = "mpileaks" os.environ["FOOBAR"] = "mpileaks"
@ -187,7 +187,7 @@ def test_unload_fails_no_shell(
): ):
"""Test that spack unload prints an error message without a shell.""" """Test that spack unload prints an error message without a shell."""
install("mpileaks") install("mpileaks")
mpileaks_spec = spack.spec.Spec("mpileaks").concretized() mpileaks_spec = spack.concretize.concretize_one("mpileaks")
os.environ[uenv.spack_loaded_hashes_var] = mpileaks_spec.dag_hash() os.environ[uenv.spack_loaded_hashes_var] = mpileaks_spec.dag_hash()
out = unload("mpileaks", fail_on_error=False) out = unload("mpileaks", fail_on_error=False)

View File

@ -8,9 +8,9 @@
from llnl.util.filesystem import mkdirp from llnl.util.filesystem import mkdirp
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.paths import spack.paths
import spack.spec
import spack.stage import spack.stage
from spack.main import SpackCommand, SpackCommandError from spack.main import SpackCommand, SpackCommandError
@ -25,7 +25,7 @@
@pytest.fixture @pytest.fixture
def mock_spec(): def mock_spec():
# Make it look like the source was actually expanded. # Make it look like the source was actually expanded.
s = spack.spec.Spec("externaltest").concretized() s = spack.concretize.concretize_one("externaltest")
source_path = s.package.stage.source_path source_path = s.package.stage.source_path
mkdirp(source_path) mkdirp(source_path)
yield s, s.package yield s, s.package

View File

@ -13,6 +13,7 @@
import spack import spack
import spack.cmd.logs import spack.cmd.logs
import spack.concretize
import spack.main import spack.main
import spack.spec import spack.spec
from spack.main import SpackCommand from spack.main import SpackCommand
@ -53,7 +54,7 @@ def disable_capture(capfd):
def test_logs_cmd_errors(install_mockery, mock_fetch, mock_archive, mock_packages): def test_logs_cmd_errors(install_mockery, mock_fetch, mock_archive, mock_packages):
spec = spack.spec.Spec("libelf").concretized() spec = spack.concretize.concretize_one("libelf")
assert not spec.installed assert not spec.installed
with pytest.raises(spack.main.SpackCommandError, match="is not installed or staged"): with pytest.raises(spack.main.SpackCommandError, match="is not installed or staged"):
@ -82,7 +83,7 @@ def test_dump_logs(install_mockery, mock_fetch, mock_archive, mock_packages, dis
decompress them. decompress them.
""" """
cmdline_spec = spack.spec.Spec("libelf") cmdline_spec = spack.spec.Spec("libelf")
concrete_spec = cmdline_spec.concretized() concrete_spec = spack.concretize.concretize_one(cmdline_spec)
# Sanity check, make sure this test is checking what we want: to # Sanity check, make sure this test is checking what we want: to
# start with # start with

View File

@ -7,6 +7,7 @@
import pytest import pytest
import spack.cmd.mirror import spack.cmd.mirror
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.error import spack.error
@ -60,7 +61,7 @@ def test_mirror_from_env(tmp_path, mock_packages, mock_fetch, mutable_mock_env_p
@pytest.fixture @pytest.fixture
def source_for_pkg_with_hash(mock_packages, tmpdir): def source_for_pkg_with_hash(mock_packages, tmpdir):
s = spack.spec.Spec("trivial-pkg-with-valid-hash").concretized() s = spack.concretize.concretize_one("trivial-pkg-with-valid-hash")
local_url_basename = os.path.basename(s.package.url) local_url_basename = os.path.basename(s.package.url)
local_path = os.path.join(str(tmpdir), local_url_basename) local_path = os.path.join(str(tmpdir), local_url_basename)
with open(local_path, "w", encoding="utf-8") as f: with open(local_path, "w", encoding="utf-8") as f:
@ -72,7 +73,9 @@ def source_for_pkg_with_hash(mock_packages, tmpdir):
def test_mirror_skip_unstable(tmpdir_factory, mock_packages, config, source_for_pkg_with_hash): def test_mirror_skip_unstable(tmpdir_factory, mock_packages, config, source_for_pkg_with_hash):
mirror_dir = str(tmpdir_factory.mktemp("mirror-dir")) mirror_dir = str(tmpdir_factory.mktemp("mirror-dir"))
specs = [spack.spec.Spec(x).concretized() for x in ["git-test", "trivial-pkg-with-valid-hash"]] specs = [
spack.concretize.concretize_one(x) for x in ["git-test", "trivial-pkg-with-valid-hash"]
]
spack.mirrors.utils.create(mirror_dir, specs, skip_unstable_versions=True) spack.mirrors.utils.create(mirror_dir, specs, skip_unstable_versions=True)
assert set(os.listdir(mirror_dir)) - set(["_source-cache"]) == set( assert set(os.listdir(mirror_dir)) - set(["_source-cache"]) == set(
@ -111,7 +114,7 @@ def test_exclude_specs(mock_packages, config):
mirror_specs, _ = spack.cmd.mirror._specs_and_action(args) mirror_specs, _ = spack.cmd.mirror._specs_and_action(args)
expected_include = set( expected_include = set(
spack.spec.Spec(x).concretized() for x in ["mpich@3.0.3", "mpich@3.0.4", "mpich@3.0"] spack.concretize.concretize_one(x) for x in ["mpich@3.0.3", "mpich@3.0.4", "mpich@3.0"]
) )
expected_exclude = set(spack.spec.Spec(x) for x in ["mpich@3.0.1", "mpich@3.0.2", "mpich@1.0"]) expected_exclude = set(spack.spec.Spec(x) for x in ["mpich@3.0.1", "mpich@3.0.2", "mpich@1.0"])
assert expected_include <= set(mirror_specs) assert expected_include <= set(mirror_specs)
@ -145,7 +148,7 @@ def test_exclude_file(mock_packages, tmpdir, config):
mirror_specs, _ = spack.cmd.mirror._specs_and_action(args) mirror_specs, _ = spack.cmd.mirror._specs_and_action(args)
expected_include = set( expected_include = set(
spack.spec.Spec(x).concretized() for x in ["mpich@3.0.3", "mpich@3.0.4", "mpich@3.0"] spack.concretize.concretize_one(x) for x in ["mpich@3.0.3", "mpich@3.0.4", "mpich@3.0"]
) )
expected_exclude = set(spack.spec.Spec(x) for x in ["mpich@3.0.1", "mpich@3.0.2", "mpich@1.0"]) expected_exclude = set(spack.spec.Spec(x) for x in ["mpich@3.0.1", "mpich@3.0.2", "mpich@1.0"])
assert expected_include <= set(mirror_specs) assert expected_include <= set(mirror_specs)

View File

@ -7,12 +7,12 @@
import pytest import pytest
import spack.concretize
import spack.config import spack.config
import spack.main import spack.main
import spack.modules import spack.modules
import spack.modules.lmod import spack.modules.lmod
import spack.repo import spack.repo
import spack.spec
import spack.store import spack.store
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
@ -33,7 +33,7 @@ def ensure_module_files_are_there(mock_repo_path, mock_store, mock_configuration
def _module_files(module_type, *specs): def _module_files(module_type, *specs):
specs = [spack.spec.Spec(x).concretized() for x in specs] specs = [spack.concretize.concretize_one(x) for x in specs]
writer_cls = spack.modules.module_types[module_type] writer_cls = spack.modules.module_types[module_type]
return [writer_cls(spec, "default").layout.filename for spec in specs] return [writer_cls(spec, "default").layout.filename for spec in specs]
@ -184,12 +184,15 @@ def test_setdefault_command(mutable_database, mutable_config):
# Install two different versions of pkg-a # Install two different versions of pkg-a
other_spec, preferred = "pkg-a@1.0", "pkg-a@2.0" other_spec, preferred = "pkg-a@1.0", "pkg-a@2.0"
specs = [spack.spec.Spec(other_spec).concretized(), spack.spec.Spec(preferred).concretized()] specs = [
spack.concretize.concretize_one(other_spec),
spack.concretize.concretize_one(preferred),
]
PackageInstaller([s.package for s in specs], explicit=True, fake=True).install() PackageInstaller([s.package for s in specs], explicit=True, fake=True).install()
writers = { writers = {
preferred: writer_cls(spack.spec.Spec(preferred).concretized(), "default"), preferred: writer_cls(specs[1], "default"),
other_spec: writer_cls(spack.spec.Spec(other_spec).concretized(), "default"), other_spec: writer_cls(specs[0], "default"),
} }
# Create two module files for the same software # Create two module files for the same software

View File

@ -2,9 +2,9 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.concretize
import spack.main import spack.main
import spack.repo import spack.repo
import spack.spec
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
tags = spack.main.SpackCommand("tags") tags = spack.main.SpackCommand("tags")
@ -47,7 +47,7 @@ class tag_path:
def test_tags_installed(install_mockery, mock_fetch): def test_tags_installed(install_mockery, mock_fetch):
s = spack.spec.Spec("mpich").concretized() s = spack.concretize.concretize_one("mpich")
PackageInstaller([s.package], explicit=True, fake=True).install() PackageInstaller([s.package], explicit=True, fake=True).install()
out = tags("-i") out = tags("-i")

View File

@ -11,10 +11,10 @@
import spack.cmd.common.arguments import spack.cmd.common.arguments
import spack.cmd.test import spack.cmd.test
import spack.concretize
import spack.config import spack.config
import spack.install_test import spack.install_test
import spack.paths import spack.paths
import spack.spec
from spack.install_test import TestStatus from spack.install_test import TestStatus
from spack.main import SpackCommand from spack.main import SpackCommand
@ -240,7 +240,7 @@ def test_read_old_results(mock_packages, mock_test_stage):
def test_test_results_none(mock_packages, mock_test_stage): def test_test_results_none(mock_packages, mock_test_stage):
name = "trivial" name = "trivial"
spec = spack.spec.Spec("trivial-smoke-test").concretized() spec = spack.concretize.concretize_one("trivial-smoke-test")
suite = spack.install_test.TestSuite([spec], name) suite = spack.install_test.TestSuite([spec], name)
suite.ensure_stage() suite.ensure_stage()
spack.install_test.write_test_suite_file(suite) spack.install_test.write_test_suite_file(suite)
@ -255,7 +255,7 @@ def test_test_results_none(mock_packages, mock_test_stage):
def test_test_results_status(mock_packages, mock_test_stage, status): def test_test_results_status(mock_packages, mock_test_stage, status):
"""Confirm 'spack test results' returns expected status.""" """Confirm 'spack test results' returns expected status."""
name = "trivial" name = "trivial"
spec = spack.spec.Spec("trivial-smoke-test").concretized() spec = spack.concretize.concretize_one("trivial-smoke-test")
suite = spack.install_test.TestSuite([spec], name) suite = spack.install_test.TestSuite([spec], name)
suite.ensure_stage() suite.ensure_stage()
spack.install_test.write_test_suite_file(suite) spack.install_test.write_test_suite_file(suite)
@ -278,7 +278,7 @@ def test_test_results_status(mock_packages, mock_test_stage, status):
def test_report_filename_for_cdash(install_mockery, mock_fetch): def test_report_filename_for_cdash(install_mockery, mock_fetch):
"""Test that the temporary file used to write Testing.xml for CDash is not the upload URL""" """Test that the temporary file used to write Testing.xml for CDash is not the upload URL"""
name = "trivial" name = "trivial"
spec = spack.spec.Spec("trivial-smoke-test").concretized() spec = spack.concretize.concretize_one("trivial-smoke-test")
suite = spack.install_test.TestSuite([spec], name) suite = spack.install_test.TestSuite([spec], name)
suite.ensure_stage() suite.ensure_stage()

View File

@ -1,8 +1,8 @@
# Copyright Spack Project Developers. See COPYRIGHT file for details. # Copyright Spack Project Developers. See COPYRIGHT file for details.
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.concretize
import spack.environment as ev import spack.environment as ev
import spack.spec
from spack.main import SpackCommand from spack.main import SpackCommand
undevelop = SpackCommand("undevelop") undevelop = SpackCommand("undevelop")
@ -30,9 +30,9 @@ def test_undevelop(tmpdir, mutable_config, mock_packages, mutable_mock_env_path)
env("create", "test", "./spack.yaml") env("create", "test", "./spack.yaml")
with ev.read("test"): with ev.read("test"):
before = spack.spec.Spec("mpich").concretized() before = spack.concretize.concretize_one("mpich")
undevelop("mpich") undevelop("mpich")
after = spack.spec.Spec("mpich").concretized() after = spack.concretize.concretize_one("mpich")
# Removing dev spec from environment changes concretization # Removing dev spec from environment changes concretization
assert before.satisfies("dev_path=*") assert before.satisfies("dev_path=*")

View File

@ -7,7 +7,7 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.spec import spack.concretize
import spack.store import spack.store
import spack.util.spack_json as sjson import spack.util.spack_json as sjson
import spack.verify import spack.verify
@ -65,7 +65,7 @@ def test_single_file_verify_cmd(tmpdir):
def test_single_spec_verify_cmd(tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery): def test_single_spec_verify_cmd(tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery):
# Test the verify command interface to verify a single spec # Test the verify command interface to verify a single spec
install("libelf") install("libelf")
s = spack.spec.Spec("libelf").concretized() s = spack.concretize.concretize_one("libelf")
prefix = s.prefix prefix = s.prefix
hash = s.dag_hash() hash = s.dag_hash()

View File

@ -9,10 +9,10 @@
from llnl.util.symlink import _windows_can_symlink from llnl.util.symlink import _windows_can_symlink
import spack.concretize
import spack.util.spack_yaml as s_yaml import spack.util.spack_yaml as s_yaml
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.main import SpackCommand from spack.main import SpackCommand
from spack.spec import Spec
extensions = SpackCommand("extensions") extensions = SpackCommand("extensions")
install = SpackCommand("install") install = SpackCommand("install")
@ -190,7 +190,7 @@ def test_view_fails_with_missing_projections_file(tmpdir):
def test_view_files_not_ignored( def test_view_files_not_ignored(
tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery, cmd, with_projection tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery, cmd, with_projection
): ):
spec = Spec("view-not-ignored").concretized() spec = spack.concretize.concretize_one("view-not-ignored")
pkg = spec.package pkg = spec.package
PackageInstaller([pkg], explicit=True).install() PackageInstaller([pkg], explicit=True).install()
pkg.assert_installed(spec.prefix) pkg.assert_installed(spec.prefix)

View File

@ -8,6 +8,7 @@
import archspec.cpu import archspec.cpu
import spack.concretize
import spack.config import spack.config
import spack.paths import spack.paths
import spack.repo import spack.repo
@ -20,7 +21,7 @@
def _concretize_with_reuse(*, root_str, reused_str): def _concretize_with_reuse(*, root_str, reused_str):
reused_spec = spack.spec.Spec(reused_str).concretized() reused_spec = spack.concretize.concretize_one(reused_str)
setup = spack.solver.asp.SpackSolverSetup(tests=False) setup = spack.solver.asp.SpackSolverSetup(tests=False)
driver = spack.solver.asp.PyclingoDriver() driver = spack.solver.asp.PyclingoDriver()
result, _, _ = driver.solve(setup, [spack.spec.Spec(f"{root_str}")], reuse=[reused_spec]) result, _, _ = driver.solve(setup, [spack.spec.Spec(f"{root_str}")], reuse=[reused_spec])
@ -44,7 +45,7 @@ def enable_runtimes():
def test_correct_gcc_runtime_is_injected_as_dependency(runtime_repo): def test_correct_gcc_runtime_is_injected_as_dependency(runtime_repo):
s = spack.spec.Spec("pkg-a%gcc@10.2.1 ^pkg-b%gcc@9.4.0").concretized() s = spack.concretize.concretize_one("pkg-a%gcc@10.2.1 ^pkg-b%gcc@9.4.0")
a, b = s["pkg-a"], s["pkg-b"] a, b = s["pkg-a"], s["pkg-b"]
# Both a and b should depend on the same gcc-runtime directly # Both a and b should depend on the same gcc-runtime directly
@ -61,7 +62,7 @@ def test_external_nodes_do_not_have_runtimes(runtime_repo, mutable_config, tmp_p
packages_yaml = {"pkg-b": {"externals": [{"spec": "pkg-b@1.0", "prefix": f"{str(tmp_path)}"}]}} packages_yaml = {"pkg-b": {"externals": [{"spec": "pkg-b@1.0", "prefix": f"{str(tmp_path)}"}]}}
spack.config.set("packages", packages_yaml) spack.config.set("packages", packages_yaml)
s = spack.spec.Spec("pkg-a%gcc@10.2.1").concretized() s = spack.concretize.concretize_one("pkg-a%gcc@10.2.1")
a, b = s["pkg-a"], s["pkg-b"] a, b = s["pkg-a"], s["pkg-b"]

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,9 @@
import pytest import pytest
import spack.concretize
import spack.config import spack.config
import spack.solver.asp import spack.solver.asp
import spack.spec
version_error_messages = [ version_error_messages = [
"Cannot satisfy 'fftw@:1.0' and 'fftw@1.1:", "Cannot satisfy 'fftw@:1.0' and 'fftw@1.1:",
@ -57,7 +57,7 @@ def test_error_messages(error_messages, config_set, spec, mock_packages, mutable
spack.config.set(path, conf) spack.config.set(path, conf)
with pytest.raises(spack.solver.asp.UnsatisfiableSpecError) as e: with pytest.raises(spack.solver.asp.UnsatisfiableSpecError) as e:
_ = spack.spec.Spec(spec).concretized() _ = spack.concretize.concretize_one(spec)
for em in error_messages: for em in error_messages:
assert em in str(e.value) assert em in str(e.value)

View File

@ -11,7 +11,6 @@
import spack.paths import spack.paths
import spack.repo import spack.repo
import spack.util.spack_yaml as syaml import spack.util.spack_yaml as syaml
from spack.spec import Spec
""" """
These tests include the following package DAGs: These tests include the following package DAGs:
@ -63,12 +62,12 @@ def test_mix_spec_and_requirements(concretize_scope, test_repo):
""" """
update_concretize_scope(conf_str, "packages") update_concretize_scope(conf_str, "packages")
s1 = Spec('y cflags="-a"').concretized() s1 = spack.concretize.concretize_one('y cflags="-a"')
assert s1.satisfies('cflags="-a -c"') assert s1.satisfies('cflags="-a -c"')
def test_mix_spec_and_dependent(concretize_scope, test_repo): def test_mix_spec_and_dependent(concretize_scope, test_repo):
s1 = Spec('x ^y cflags="-a"').concretized() s1 = spack.concretize.concretize_one('x ^y cflags="-a"')
assert s1["y"].satisfies('cflags="-a -d1"') assert s1["y"].satisfies('cflags="-a -d1"')
@ -93,7 +92,7 @@ def test_mix_spec_and_compiler_cfg(concretize_scope, test_repo):
conf_str = _compiler_cfg_one_entry_with_cflags("-Wall") conf_str = _compiler_cfg_one_entry_with_cflags("-Wall")
update_concretize_scope(conf_str, "compilers") update_concretize_scope(conf_str, "compilers")
s1 = Spec('y %gcc@12.100.100 cflags="-O2"').concretized() s1 = spack.concretize.concretize_one('y %gcc@12.100.100 cflags="-O2"')
assert s1.satisfies('cflags="-Wall -O2"') assert s1.satisfies('cflags="-Wall -O2"')
@ -160,7 +159,7 @@ def test_flag_order_and_grouping(
if cmd_flags: if cmd_flags:
spec_str += f' cflags="{cmd_flags}"' spec_str += f' cflags="{cmd_flags}"'
root_spec = Spec(spec_str).concretized() root_spec = spack.concretize.concretize_one(spec_str)
spec = root_spec["y"] spec = root_spec["y"]
satisfy_flags = " ".join(x for x in [cmd_flags, req_flags, cmp_flags, expected_dflags] if x) satisfy_flags = " ".join(x for x in [cmd_flags, req_flags, cmp_flags, expected_dflags] if x)
assert spec.satisfies(f'cflags="{satisfy_flags}"') assert spec.satisfies(f'cflags="{satisfy_flags}"')
@ -168,11 +167,11 @@ def test_flag_order_and_grouping(
def test_two_dependents_flag_mixing(concretize_scope, test_repo): def test_two_dependents_flag_mixing(concretize_scope, test_repo):
root_spec1 = Spec("w~moveflaglater").concretized() root_spec1 = spack.concretize.concretize_one("w~moveflaglater")
spec1 = root_spec1["y"] spec1 = root_spec1["y"]
assert spec1.compiler_flags["cflags"] == "-d0 -d1 -d2".split() assert spec1.compiler_flags["cflags"] == "-d0 -d1 -d2".split()
root_spec2 = Spec("w+moveflaglater").concretized() root_spec2 = spack.concretize.concretize_one("w+moveflaglater")
spec2 = root_spec2["y"] spec2 = root_spec2["y"]
assert spec2.compiler_flags["cflags"] == "-d3 -d1 -d2".split() assert spec2.compiler_flags["cflags"] == "-d3 -d1 -d2".split()
@ -181,7 +180,7 @@ def test_propagate_and_compiler_cfg(concretize_scope, test_repo):
conf_str = _compiler_cfg_one_entry_with_cflags("-f2") conf_str = _compiler_cfg_one_entry_with_cflags("-f2")
update_concretize_scope(conf_str, "compilers") update_concretize_scope(conf_str, "compilers")
root_spec = Spec("v %gcc@12.100.100 cflags=='-f1'").concretized() root_spec = spack.concretize.concretize_one("v %gcc@12.100.100 cflags=='-f1'")
assert root_spec["y"].satisfies("cflags='-f1 -f2'") assert root_spec["y"].satisfies("cflags='-f1 -f2'")
@ -190,7 +189,7 @@ def test_propagate_and_compiler_cfg(concretize_scope, test_repo):
def test_propagate_and_pkg_dep(concretize_scope, test_repo): def test_propagate_and_pkg_dep(concretize_scope, test_repo):
root_spec1 = Spec("x ~activatemultiflag cflags=='-f1'").concretized() root_spec1 = spack.concretize.concretize_one("x ~activatemultiflag cflags=='-f1'")
assert root_spec1["y"].satisfies("cflags='-f1 -d1'") assert root_spec1["y"].satisfies("cflags='-f1 -d1'")
@ -202,7 +201,7 @@ def test_propagate_and_require(concretize_scope, test_repo):
""" """
update_concretize_scope(conf_str, "packages") update_concretize_scope(conf_str, "packages")
root_spec1 = Spec("v cflags=='-f1'").concretized() root_spec1 = spack.concretize.concretize_one("v cflags=='-f1'")
assert root_spec1["y"].satisfies("cflags='-f1 -f2'") assert root_spec1["y"].satisfies("cflags='-f1 -f2'")
# Next, check that a requirement does not "undo" a request for # Next, check that a requirement does not "undo" a request for
@ -214,7 +213,7 @@ def test_propagate_and_require(concretize_scope, test_repo):
""" """
update_concretize_scope(conf_str, "packages") update_concretize_scope(conf_str, "packages")
root_spec2 = Spec("v cflags=='-f1'").concretized() root_spec2 = spack.concretize.concretize_one("v cflags=='-f1'")
assert root_spec2["y"].satisfies("cflags='-f1'") assert root_spec2["y"].satisfies("cflags='-f1'")
# Note: requirements cannot enforce propagation: any attempt to do # Note: requirements cannot enforce propagation: any attempt to do
@ -258,7 +257,7 @@ def test_diamond_dep_flag_mixing(concretize_scope, test_repo):
nodes of the diamond always appear in the same order). nodes of the diamond always appear in the same order).
`Spec.traverse` is responsible for handling both of these needs. `Spec.traverse` is responsible for handling both of these needs.
""" """
root_spec1 = Spec("t").concretized() root_spec1 = spack.concretize.concretize_one("t")
spec1 = root_spec1["y"] spec1 = root_spec1["y"]
assert spec1.satisfies('cflags="-c1 -c2 -d1 -d2 -e1 -e2"') assert spec1.satisfies('cflags="-c1 -c2 -d1 -d2 -e1 -e2"')
assert spec1.compiler_flags["cflags"] == "-c1 -c2 -e1 -e2 -d1 -d2".split() assert spec1.compiler_flags["cflags"] == "-c1 -c2 -e1 -e2 -d1 -d2".split()

View File

@ -7,6 +7,7 @@
import pytest import pytest
import spack.concretize
import spack.config import spack.config
import spack.package_prefs import spack.package_prefs
import spack.repo import spack.repo
@ -46,7 +47,7 @@ def configure_permissions():
def concretize(abstract_spec): def concretize(abstract_spec):
return Spec(abstract_spec).concretized() return spack.concretize.concretize_one(abstract_spec)
def update_packages(pkgname, section, value): def update_packages(pkgname, section, value):
@ -111,7 +112,7 @@ def test_preferred_variants_from_wildcard(self):
def test_preferred_compilers(self, compiler_str, spec_str): def test_preferred_compilers(self, compiler_str, spec_str):
"""Test preferred compilers are applied correctly""" """Test preferred compilers are applied correctly"""
update_packages("all", "compiler", [compiler_str]) update_packages("all", "compiler", [compiler_str])
spec = spack.spec.Spec(spec_str).concretized() spec = spack.concretize.concretize_one(spec_str)
assert spec.compiler == CompilerSpec(compiler_str) assert spec.compiler == CompilerSpec(compiler_str)
def test_preferred_target(self, mutable_mock_repo): def test_preferred_target(self, mutable_mock_repo):
@ -213,15 +214,13 @@ def test_config_set_pkg_property_new(self, mock_repo_path):
def test_preferred(self): def test_preferred(self):
""" "Test packages with some version marked as preferred=True""" """ "Test packages with some version marked as preferred=True"""
spec = Spec("python") spec = spack.concretize.concretize_one("python")
spec.concretize()
assert spec.version == Version("2.7.11") assert spec.version == Version("2.7.11")
# now add packages.yaml with versions other than preferred # now add packages.yaml with versions other than preferred
# ensure that once config is in place, non-preferred version is used # ensure that once config is in place, non-preferred version is used
update_packages("python", "version", ["3.5.0"]) update_packages("python", "version", ["3.5.0"])
spec = Spec("python") spec = spack.concretize.concretize_one("python")
spec.concretize()
assert spec.version == Version("3.5.0") assert spec.version == Version("3.5.0")
def test_preferred_undefined_raises(self): def test_preferred_undefined_raises(self):
@ -229,7 +228,7 @@ def test_preferred_undefined_raises(self):
update_packages("python", "version", ["3.5.0.1"]) update_packages("python", "version", ["3.5.0.1"])
spec = Spec("python") spec = Spec("python")
with pytest.raises(ConfigError): with pytest.raises(ConfigError):
spec.concretize() spack.concretize.concretize_one(spec)
def test_preferred_truncated(self): def test_preferred_truncated(self):
"""Versions without "=" are treated as version ranges: if there is """Versions without "=" are treated as version ranges: if there is
@ -237,35 +236,29 @@ def test_preferred_truncated(self):
(don't define a new version). (don't define a new version).
""" """
update_packages("python", "version", ["3.5"]) update_packages("python", "version", ["3.5"])
spec = Spec("python") spec = spack.concretize.concretize_one("python")
spec.concretize()
assert spec.satisfies("@3.5.1") assert spec.satisfies("@3.5.1")
def test_develop(self): def test_develop(self):
"""Test concretization with develop-like versions""" """Test concretization with develop-like versions"""
spec = Spec("develop-test") spec = spack.concretize.concretize_one("develop-test")
spec.concretize()
assert spec.version == Version("0.2.15") assert spec.version == Version("0.2.15")
spec = Spec("develop-test2") spec = spack.concretize.concretize_one("develop-test2")
spec.concretize()
assert spec.version == Version("0.2.15") assert spec.version == Version("0.2.15")
# now add packages.yaml with develop-like versions # now add packages.yaml with develop-like versions
# ensure that once config is in place, develop-like version is used # ensure that once config is in place, develop-like version is used
update_packages("develop-test", "version", ["develop"]) update_packages("develop-test", "version", ["develop"])
spec = Spec("develop-test") spec = spack.concretize.concretize_one("develop-test")
spec.concretize()
assert spec.version == Version("develop") assert spec.version == Version("develop")
update_packages("develop-test2", "version", ["0.2.15.develop"]) update_packages("develop-test2", "version", ["0.2.15.develop"])
spec = Spec("develop-test2") spec = spack.concretize.concretize_one("develop-test2")
spec.concretize()
assert spec.version == Version("0.2.15.develop") assert spec.version == Version("0.2.15.develop")
def test_external_mpi(self): def test_external_mpi(self):
# make sure this doesn't give us an external first. # make sure this doesn't give us an external first.
spec = Spec("mpi") spec = spack.concretize.concretize_one("mpi")
spec.concretize()
assert not spec["mpi"].external assert not spec["mpi"].external
# load config # load config
@ -284,8 +277,7 @@ def test_external_mpi(self):
spack.config.set("packages", conf, scope="concretize") spack.config.set("packages", conf, scope="concretize")
# ensure that once config is in place, external is used # ensure that once config is in place, external is used
spec = Spec("mpi") spec = spack.concretize.concretize_one("mpi")
spec.concretize()
assert spec["mpich"].external_path == os.path.sep + os.path.join("dummy", "path") assert spec["mpich"].external_path == os.path.sep + os.path.join("dummy", "path")
def test_external_module(self, monkeypatch): def test_external_module(self, monkeypatch):
@ -300,8 +292,7 @@ def mock_module(cmd, module):
monkeypatch.setattr(spack.util.module_cmd, "module", mock_module) monkeypatch.setattr(spack.util.module_cmd, "module", mock_module)
spec = Spec("mpi") spec = spack.concretize.concretize_one("mpi")
spec.concretize()
assert not spec["mpi"].external assert not spec["mpi"].external
# load config # load config
@ -320,8 +311,7 @@ def mock_module(cmd, module):
spack.config.set("packages", conf, scope="concretize") spack.config.set("packages", conf, scope="concretize")
# ensure that once config is in place, external is used # ensure that once config is in place, external is used
spec = Spec("mpi") spec = spack.concretize.concretize_one("mpi")
spec.concretize()
assert spec["mpich"].external_path == os.path.sep + os.path.join("dummy", "path") assert spec["mpich"].external_path == os.path.sep + os.path.join("dummy", "path")
def test_buildable_false(self): def test_buildable_false(self):
@ -467,7 +457,7 @@ def test_variant_not_flipped_to_pull_externals(self):
"""Test that a package doesn't prefer pulling in an """Test that a package doesn't prefer pulling in an
external to using the default value of a variant. external to using the default value of a variant.
""" """
s = Spec("vdefault-or-external-root").concretized() s = spack.concretize.concretize_one("vdefault-or-external-root")
assert "~external" in s["vdefault-or-external"] assert "~external" in s["vdefault-or-external"]
assert "externaltool" not in s assert "externaltool" not in s
@ -479,7 +469,7 @@ def test_dependencies_cant_make_version_parent_score_better(self):
that makes the overall version score even or better and maybe that makes the overall version score even or better and maybe
has a better score in some lower priority criteria. has a better score in some lower priority criteria.
""" """
s = Spec("version-test-root").concretized() s = spack.concretize.concretize_one("version-test-root")
assert s.satisfies("^version-test-pkg@2.4.6") assert s.satisfies("^version-test-pkg@2.4.6")
assert "version-test-dependency-preferred" not in s assert "version-test-dependency-preferred" not in s
@ -497,13 +487,13 @@ def test_multivalued_variants_are_lower_priority_than_providers(self):
with spack.config.override( with spack.config.override(
"packages:all", {"providers": {"somevirtual": ["some-virtual-preferred"]}} "packages:all", {"providers": {"somevirtual": ["some-virtual-preferred"]}}
): ):
s = Spec("somevirtual").concretized() s = spack.concretize.concretize_one("somevirtual")
assert s.name == "some-virtual-preferred" assert s.name == "some-virtual-preferred"
@pytest.mark.regression("26721,19736") @pytest.mark.regression("26721,19736")
def test_sticky_variant_accounts_for_packages_yaml(self): def test_sticky_variant_accounts_for_packages_yaml(self):
with spack.config.override("packages:sticky-variant", {"variants": "+allow-gcc"}): with spack.config.override("packages:sticky-variant", {"variants": "+allow-gcc"}):
s = Spec("sticky-variant %gcc").concretized() s = spack.concretize.concretize_one("sticky-variant %gcc")
assert s.satisfies("%gcc") and s.satisfies("+allow-gcc") assert s.satisfies("%gcc") and s.satisfies("+allow-gcc")
@pytest.mark.regression("41134") @pytest.mark.regression("41134")
@ -512,5 +502,5 @@ def test_default_preference_variant_different_type_does_not_error(self):
packages.yaml doesn't fail with an error. packages.yaml doesn't fail with an error.
""" """
with spack.config.override("packages:all", {"variants": "+foo"}): with spack.config.override("packages:all", {"variants": "+foo"}):
s = Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
assert s.satisfies("foo=bar") assert s.satisfies("foo=bar")

View File

@ -6,6 +6,7 @@
import pytest import pytest
import spack.concretize
import spack.config import spack.config
import spack.error import spack.error
import spack.package_base import spack.package_base
@ -42,7 +43,7 @@ def test_one_package_multiple_reqs(concretize_scope, test_repo):
- "~shared" - "~shared"
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
y_spec = Spec("y").concretized() y_spec = spack.concretize.concretize_one("y")
assert y_spec.satisfies("@2.4~shared") assert y_spec.satisfies("@2.4~shared")
@ -57,7 +58,7 @@ def test_requirement_isnt_optional(concretize_scope, test_repo):
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
with pytest.raises(UnsatisfiableSpecError): with pytest.raises(UnsatisfiableSpecError):
Spec("x@1.1").concretize() spack.concretize.concretize_one("x@1.1")
def test_require_undefined_version(concretize_scope, test_repo): def test_require_undefined_version(concretize_scope, test_repo):
@ -74,7 +75,7 @@ def test_require_undefined_version(concretize_scope, test_repo):
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
with pytest.raises(spack.error.ConfigError): with pytest.raises(spack.error.ConfigError):
Spec("x").concretize() spack.concretize.concretize_one("x")
def test_require_truncated(concretize_scope, test_repo): def test_require_truncated(concretize_scope, test_repo):
@ -89,7 +90,7 @@ def test_require_truncated(concretize_scope, test_repo):
require: "@1" require: "@1"
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
xspec = Spec("x").concretized() xspec = spack.concretize.concretize_one("x")
assert xspec.satisfies("@1.1") assert xspec.satisfies("@1.1")
@ -159,7 +160,7 @@ def test_requirement_adds_new_version(
) )
update_packages_config(conf_str) update_packages_config(conf_str)
s1 = Spec("v").concretized() s1 = spack.concretize.concretize_one("v")
assert s1.satisfies("@2.2") assert s1.satisfies("@2.2")
# Make sure the git commit info is retained # Make sure the git commit info is retained
assert isinstance(s1.version, spack.version.GitVersion) assert isinstance(s1.version, spack.version.GitVersion)
@ -180,7 +181,7 @@ def test_requirement_adds_version_satisfies(
) )
# Sanity check: early version of T does not include U # Sanity check: early version of T does not include U
s0 = Spec("t@2.0").concretized() s0 = spack.concretize.concretize_one("t@2.0")
assert not ("u" in s0) assert not ("u" in s0)
conf_str = """\ conf_str = """\
@ -192,7 +193,7 @@ def test_requirement_adds_version_satisfies(
) )
update_packages_config(conf_str) update_packages_config(conf_str)
s1 = Spec("t").concretized() s1 = spack.concretize.concretize_one("t")
assert "u" in s1 assert "u" in s1
assert s1.satisfies("@2.2") assert s1.satisfies("@2.2")
@ -218,7 +219,7 @@ def test_requirement_adds_git_hash_version(
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
s1 = Spec("v").concretized() s1 = spack.concretize.concretize_one("v")
assert isinstance(s1.version, spack.version.GitVersion) assert isinstance(s1.version, spack.version.GitVersion)
assert s1.satisfies(f"v@{a_commit_hash}") assert s1.satisfies(f"v@{a_commit_hash}")
@ -239,8 +240,8 @@ def test_requirement_adds_multiple_new_versions(
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
assert Spec("v").concretized().satisfies(f"@{commits[0]}=2.2") assert spack.concretize.concretize_one("v").satisfies(f"@{commits[0]}=2.2")
assert Spec("v@2.3").concretized().satisfies(f"v@{commits[1]}=2.3") assert spack.concretize.concretize_one("v@2.3").satisfies(f"v@{commits[1]}=2.3")
# TODO: this belongs in the concretize_preferences test module but uses # TODO: this belongs in the concretize_preferences test module but uses
@ -263,11 +264,11 @@ def test_preference_adds_new_version(
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
assert Spec("v").concretized().satisfies(f"@{commits[0]}=2.2") assert spack.concretize.concretize_one("v").satisfies(f"@{commits[0]}=2.2")
assert Spec("v@2.3").concretized().satisfies(f"@{commits[1]}=2.3") assert spack.concretize.concretize_one("v@2.3").satisfies(f"@{commits[1]}=2.3")
# When installing by hash, a lookup is triggered, so it's not mapped to =2.3. # When installing by hash, a lookup is triggered, so it's not mapped to =2.3.
s3 = Spec(f"v@{commits[1]}").concretized() s3 = spack.concretize.concretize_one(f"v@{commits[1]}")
assert s3.satisfies(f"v@{commits[1]}") assert s3.satisfies(f"v@{commits[1]}")
assert not s3.satisfies("@2.3") assert not s3.satisfies("@2.3")
@ -287,7 +288,7 @@ def test_external_adds_new_version_that_is_preferred(concretize_scope, test_repo
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("x").concretized() spec = spack.concretize.concretize_one("x")
assert spec["y"].satisfies("@2.7") assert spec["y"].satisfies("@2.7")
assert spack.version.Version("2.7") not in spec["y"].package.versions assert spack.version.Version("2.7") not in spec["y"].package.versions
@ -296,7 +297,7 @@ def test_requirement_is_successfully_applied(concretize_scope, test_repo):
"""If a simple requirement can be satisfied, make sure the """If a simple requirement can be satisfied, make sure the
concretization succeeds and the requirement spec is applied. concretization succeeds and the requirement spec is applied.
""" """
s1 = Spec("x").concretized() s1 = spack.concretize.concretize_one("x")
# Without any requirements/preferences, the later version is preferred # Without any requirements/preferences, the later version is preferred
assert s1.satisfies("@1.1") assert s1.satisfies("@1.1")
@ -306,7 +307,7 @@ def test_requirement_is_successfully_applied(concretize_scope, test_repo):
require: "@1.0" require: "@1.0"
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
s2 = Spec("x").concretized() s2 = spack.concretize.concretize_one("x")
# The requirement forces choosing the eariler version # The requirement forces choosing the eariler version
assert s2.satisfies("@1.0") assert s2.satisfies("@1.0")
@ -323,7 +324,7 @@ def test_multiple_packages_requirements_are_respected(concretize_scope, test_rep
require: "@2.4" require: "@2.4"
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("x").concretized() spec = spack.concretize.concretize_one("x")
assert spec["x"].satisfies("@1.0") assert spec["x"].satisfies("@1.0")
assert spec["y"].satisfies("@2.4") assert spec["y"].satisfies("@2.4")
@ -339,7 +340,7 @@ def test_oneof(concretize_scope, test_repo):
- one_of: ["@2.4", "~shared"] - one_of: ["@2.4", "~shared"]
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("x").concretized() spec = spack.concretize.concretize_one("x")
# The concretizer only has to satisfy one of @2.4/~shared, and @2.4 # The concretizer only has to satisfy one of @2.4/~shared, and @2.4
# comes first so it is prioritized # comes first so it is prioritized
assert spec["y"].satisfies("@2.4+shared") assert spec["y"].satisfies("@2.4+shared")
@ -358,10 +359,10 @@ def test_one_package_multiple_oneof_groups(concretize_scope, test_repo):
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
s1 = Spec("y@2.5").concretized() s1 = spack.concretize.concretize_one("y@2.5")
assert s1.satisfies("%clang~shared") assert s1.satisfies("%clang~shared")
s2 = Spec("y@2.4").concretized() s2 = spack.concretize.concretize_one("y@2.4")
assert s2.satisfies("%gcc+shared") assert s2.satisfies("%gcc+shared")
@ -377,10 +378,10 @@ def test_require_cflags(concretize_scope, mock_packages):
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec_mpich2 = Spec("mpich2").concretized() spec_mpich2 = spack.concretize.concretize_one("mpich2")
assert spec_mpich2.satisfies("cflags=-g") assert spec_mpich2.satisfies("cflags=-g")
spec_mpi = Spec("mpi").concretized() spec_mpi = spack.concretize.concretize_one("mpi")
assert spec_mpi.satisfies("mpich cflags=-O1") assert spec_mpi.satisfies("mpich cflags=-O1")
@ -403,7 +404,7 @@ def test_requirements_for_package_that_is_not_needed(concretize_scope, test_repo
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
s1 = Spec("v").concretized() s1 = spack.concretize.concretize_one("v")
assert s1.satisfies("@2.1") assert s1.satisfies("@2.1")
@ -420,10 +421,10 @@ def test_oneof_ordering(concretize_scope, test_repo):
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
s1 = Spec("y").concretized() s1 = spack.concretize.concretize_one("y")
assert s1.satisfies("@2.4") assert s1.satisfies("@2.4")
s2 = Spec("y@2.5").concretized() s2 = spack.concretize.concretize_one("y@2.5")
assert s2.satisfies("@2.5") assert s2.satisfies("@2.5")
@ -437,14 +438,14 @@ def test_reuse_oneof(concretize_scope, test_repo, tmp_path, mock_fetch):
store_dir = tmp_path / "store" store_dir = tmp_path / "store"
with spack.store.use_store(str(store_dir)): with spack.store.use_store(str(store_dir)):
s1 = Spec("y@2.5 ~shared").concretized() s1 = spack.concretize.concretize_one("y@2.5~shared")
PackageInstaller([s1.package], fake=True, explicit=True).install() PackageInstaller([s1.package], fake=True, explicit=True).install()
update_packages_config(conf_str) update_packages_config(conf_str)
with spack.config.override("concretizer:reuse", True): with spack.config.override("concretizer:reuse", True):
s2 = Spec("y").concretized() s2 = spack.concretize.concretize_one("y")
assert not s2.satisfies("@2.5 ~shared") assert not s2.satisfies("@2.5~shared")
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -472,7 +473,7 @@ def test_requirements_and_deprecated_versions(
update_packages_config(conf_str) update_packages_config(conf_str)
with spack.config.override("config:deprecated", allow_deprecated): with spack.config.override("config:deprecated", allow_deprecated):
s1 = Spec("y").concretized() s1 = spack.concretize.concretize_one("y")
for constrain in expected: for constrain in expected:
assert s1.satisfies(constrain) assert s1.satisfies(constrain)
@ -490,7 +491,7 @@ def test_default_requirements_with_all(spec_str, requirement_str, concretize_sco
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec(spec_str).concretized() spec = spack.concretize.concretize_one(spec_str)
for s in spec.traverse(): for s in spec.traverse():
assert s.satisfies(requirement_str) assert s.satisfies(requirement_str)
@ -499,7 +500,7 @@ def test_default_requirements_with_all(spec_str, requirement_str, concretize_sco
"requirements,expectations", "requirements,expectations",
[ [
(("%gcc", "%clang"), ("%gcc", "%clang")), (("%gcc", "%clang"), ("%gcc", "%clang")),
(("%gcc ~shared", "@1.0"), ("%gcc ~shared", "@1.0 +shared")), (("%gcc~shared", "@1.0"), ("%gcc~shared", "@1.0+shared")),
], ],
) )
def test_default_and_package_specific_requirements( def test_default_and_package_specific_requirements(
@ -517,7 +518,7 @@ def test_default_and_package_specific_requirements(
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("x").concretized() spec = spack.concretize.concretize_one("x")
assert spec.satisfies(specific_exp) assert spec.satisfies(specific_exp)
for s in spec.traverse(root=False): for s in spec.traverse(root=False):
assert s.satisfies(generic_exp) assert s.satisfies(generic_exp)
@ -532,7 +533,7 @@ def test_requirements_on_virtual(mpi_requirement, concretize_scope, mock_package
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("callpath").concretized() spec = spack.concretize.concretize_one("callpath")
assert "mpi" in spec assert "mpi" in spec
assert mpi_requirement in spec assert mpi_requirement in spec
@ -553,7 +554,7 @@ def test_requirements_on_virtual_and_on_package(
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("callpath").concretized() spec = spack.concretize.concretize_one("callpath")
assert "mpi" in spec assert "mpi" in spec
assert mpi_requirement in spec assert mpi_requirement in spec
assert spec["mpi"].satisfies(specific_requirement) assert spec["mpi"].satisfies(specific_requirement)
@ -567,10 +568,10 @@ def test_incompatible_virtual_requirements_raise(concretize_scope, mock_packages
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("callpath ^zmpi") spec = Spec("callpath^zmpi")
# TODO (multiple nodes): recover a better error message later # TODO (multiple nodes): recover a better error message later
with pytest.raises((UnsatisfiableSpecError, InternalConcretizerError)): with pytest.raises((UnsatisfiableSpecError, InternalConcretizerError)):
spec.concretize() spack.concretize.concretize_one(spec)
def test_non_existing_variants_under_all(concretize_scope, mock_packages): def test_non_existing_variants_under_all(concretize_scope, mock_packages):
@ -582,7 +583,7 @@ def test_non_existing_variants_under_all(concretize_scope, mock_packages):
""" """
update_packages_config(conf_str) update_packages_config(conf_str)
spec = Spec("callpath ^zmpi").concretized() spec = spack.concretize.concretize_one("callpath^zmpi")
assert "~foo" not in spec assert "~foo" not in spec
@ -657,7 +658,7 @@ def test_conditional_requirements_from_packages_yaml(
and optional when the condition is not met. and optional when the condition is not met.
""" """
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
spec = Spec(spec_str).concretized() spec = spack.concretize.concretize_one(spec_str)
for match_str, expected in expected_satisfies: for match_str, expected in expected_satisfies:
assert spec.satisfies(match_str) is expected assert spec.satisfies(match_str) is expected
@ -733,7 +734,7 @@ def test_requirements_fail_with_custom_message(
""" """
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
with pytest.raises(spack.error.SpackError, match=expected_message): with pytest.raises(spack.error.SpackError, match=expected_message):
Spec(spec_str).concretized() spack.concretize.concretize_one(spec_str)
def test_skip_requirement_when_default_requirement_condition_cannot_be_met( def test_skip_requirement_when_default_requirement_condition_cannot_be_met(
@ -752,9 +753,9 @@ def test_skip_requirement_when_default_requirement_condition_cannot_be_met(
when: "+shared" when: "+shared"
""" """
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
s = Spec("mpileaks").concretized() s = spack.concretize.concretize_one("mpileaks")
assert s.satisfies("%clang +shared") assert s.satisfies("%clang+shared")
# Sanity checks that 'callpath' doesn't have the shared variant, but that didn't # Sanity checks that 'callpath' doesn't have the shared variant, but that didn't
# cause failures during concretization. # cause failures during concretization.
assert "shared" not in s["callpath"].variants assert "shared" not in s["callpath"].variants
@ -781,12 +782,12 @@ def test_requires_directive(concretize_scope, mock_packages):
spack.config.CONFIG.clear_caches() spack.config.CONFIG.clear_caches()
# This package requires either clang or gcc # This package requires either clang or gcc
s = Spec("requires_clang_or_gcc").concretized() s = spack.concretize.concretize_one("requires_clang_or_gcc")
assert s.satisfies("%gcc@12.0.0") assert s.satisfies("%gcc@12.0.0")
# This package can only be compiled with clang # This package can only be compiled with clang
with pytest.raises(spack.error.SpackError, match="can only be compiled with Clang"): with pytest.raises(spack.error.SpackError, match="can only be compiled with Clang"):
Spec("requires_clang").concretized() spack.concretize.concretize_one("requires_clang")
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -839,20 +840,20 @@ def test_default_requirements_semantic(packages_yaml, concretize_scope, mock_pac
""" """
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
# Regular zlib concretize to +shared # Regular zlib concretize to+shared
s = Spec("zlib").concretized() s = spack.concretize.concretize_one("zlib")
assert s.satisfies("+shared") assert s.satisfies("+shared")
# If we specify the variant we can concretize only the one matching the constraint # If we specify the variant we can concretize only the one matching the constraint
s = Spec("zlib +shared").concretized() s = spack.concretize.concretize_one("zlib+shared")
assert s.satisfies("+shared") assert s.satisfies("+shared")
with pytest.raises(UnsatisfiableSpecError): with pytest.raises(UnsatisfiableSpecError):
Spec("zlib ~shared").concretized() spack.concretize.concretize_one("zlib~shared")
# A spec without the shared variant still concretize # A spec without the shared variant still concretize
s = Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
assert not s.satisfies("pkg-a +shared") assert not s.satisfies("pkg-a+shared")
assert not s.satisfies("pkg-a ~shared") assert not s.satisfies("pkg-a~shared")
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -896,7 +897,7 @@ def test_default_requirements_semantic(packages_yaml, concretize_scope, mock_pac
""" """
packages: packages:
all: all:
require: "libs=static +feefoo" require: "libs=static+feefoo"
""", """,
"multivalue-variant", "multivalue-variant",
["libs=shared"], ["libs=shared"],
@ -911,7 +912,7 @@ def test_default_requirements_semantic_with_mv_variants(
from MV variants. from MV variants.
""" """
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
s = Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
for constraint in expected: for constraint in expected:
assert s.satisfies(constraint), constraint assert s.satisfies(constraint), constraint
@ -936,7 +937,7 @@ def test_requiring_package_on_multiple_virtuals(concretize_scope, mock_packages)
require: intel-parallel-studio require: intel-parallel-studio
""" """
) )
s = Spec("dla-future").concretized() s = spack.concretize.concretize_one("dla-future")
assert s["blas"].name == "intel-parallel-studio" assert s["blas"].name == "intel-parallel-studio"
assert s["lapack"].name == "intel-parallel-studio" assert s["lapack"].name == "intel-parallel-studio"
@ -989,7 +990,7 @@ def test_strong_preferences_packages_yaml(
): ):
"""Tests that "preferred" specs are stronger than usual preferences, but can be overridden.""" """Tests that "preferred" specs are stronger than usual preferences, but can be overridden."""
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
s = Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
for constraint in expected: for constraint in expected:
assert s.satisfies(constraint), constraint assert s.satisfies(constraint), constraint
@ -1038,29 +1039,29 @@ def test_conflict_packages_yaml(packages_yaml, spec_str, concretize_scope, mock_
"""Tests conflicts that are specified from configuration files.""" """Tests conflicts that are specified from configuration files."""
update_packages_config(packages_yaml) update_packages_config(packages_yaml)
with pytest.raises(UnsatisfiableSpecError): with pytest.raises(UnsatisfiableSpecError):
Spec(spec_str).concretized() spack.concretize.concretize_one(spec_str)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"spec_str,expected,not_expected", "spec_str,expected,not_expected",
[ [
( (
"forward-multi-value +cuda cuda_arch=10 ^dependency-mv~cuda", "forward-multi-value+cuda cuda_arch=10^dependency-mv~cuda",
["cuda_arch=10", "^dependency-mv~cuda"], ["cuda_arch=10", "^dependency-mv~cuda"],
["cuda_arch=11", "^dependency-mv cuda_arch=10", "^dependency-mv cuda_arch=11"], ["cuda_arch=11", "^dependency-mv cuda_arch=10", "^dependency-mv cuda_arch=11"],
), ),
( (
"forward-multi-value +cuda cuda_arch=10 ^dependency-mv+cuda", "forward-multi-value+cuda cuda_arch=10^dependency-mv+cuda",
["cuda_arch=10", "^dependency-mv cuda_arch=10"], ["cuda_arch=10", "^dependency-mv cuda_arch=10"],
["cuda_arch=11", "^dependency-mv cuda_arch=11"], ["cuda_arch=11", "^dependency-mv cuda_arch=11"],
), ),
( (
"forward-multi-value +cuda cuda_arch=11 ^dependency-mv+cuda", "forward-multi-value+cuda cuda_arch=11^dependency-mv+cuda",
["cuda_arch=11", "^dependency-mv cuda_arch=11"], ["cuda_arch=11", "^dependency-mv cuda_arch=11"],
["cuda_arch=10", "^dependency-mv cuda_arch=10"], ["cuda_arch=10", "^dependency-mv cuda_arch=10"],
), ),
( (
"forward-multi-value +cuda cuda_arch=10,11 ^dependency-mv+cuda", "forward-multi-value+cuda cuda_arch=10,11^dependency-mv+cuda",
["cuda_arch=10,11", "^dependency-mv cuda_arch=10,11"], ["cuda_arch=10,11", "^dependency-mv cuda_arch=10,11"],
[], [],
), ),
@ -1073,9 +1074,9 @@ def test_forward_multi_valued_variant_using_requires(
`requires` directives of the form: `requires` directives of the form:
for _val in ("shared", "static"): for _val in ("shared", "static"):
requires(f"^some-virtual-mv libs={_val}", when=f"libs={_val} ^some-virtual-mv") requires(f"^some-virtual-mv libs={_val}", when=f"libs={_val}^some-virtual-mv")
""" """
s = Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
for constraint in expected: for constraint in expected:
assert s.satisfies(constraint) assert s.satisfies(constraint)
@ -1086,7 +1087,7 @@ def test_forward_multi_valued_variant_using_requires(
def test_strong_preferences_higher_priority_than_reuse(concretize_scope, mock_packages): def test_strong_preferences_higher_priority_than_reuse(concretize_scope, mock_packages):
"""Tests that strong preferences have a higher priority than reusing specs.""" """Tests that strong preferences have a higher priority than reusing specs."""
reused_spec = Spec("adios2~bzip2").concretized() reused_spec = spack.concretize.concretize_one("adios2~bzip2")
reuse_nodes = list(reused_spec.traverse()) reuse_nodes = list(reused_spec.traverse())
root_specs = [Spec("ascent+adios2")] root_specs = [Spec("ascent+adios2")]
@ -1121,7 +1122,7 @@ def test_strong_preferences_higher_priority_than_reuse(concretize_scope, mock_pa
solver = spack.solver.asp.Solver() solver = spack.solver.asp.Solver()
setup = spack.solver.asp.SpackSolverSetup() setup = spack.solver.asp.SpackSolverSetup()
result, _, _ = solver.driver.solve( result, _, _ = solver.driver.solve(
setup, [Spec("ascent+adios2 ^adios2~bzip2")], reuse=reuse_nodes setup, [Spec("ascent+adios2^adios2~bzip2")], reuse=reuse_nodes
) )
ascent = result.specs[0] ascent = result.specs[0]
assert ascent["adios2"].dag_hash() == reused_spec.dag_hash(), ascent assert ascent["adios2"].dag_hash() == reused_spec.dag_hash(), ascent

View File

@ -4,7 +4,7 @@
import pytest import pytest
import spack.spec import spack.concretize
import spack.store import spack.store
@ -13,7 +13,7 @@
def test_set_install_hash_length(hash_length, mutable_config, tmpdir): def test_set_install_hash_length(hash_length, mutable_config, tmpdir):
mutable_config.set("config:install_hash_length", hash_length) mutable_config.set("config:install_hash_length", hash_length)
with spack.store.use_store(str(tmpdir)): with spack.store.use_store(str(tmpdir)):
spec = spack.spec.Spec("libelf").concretized() spec = spack.concretize.concretize_one("libelf")
prefix = spec.prefix prefix = spec.prefix
hash_str = prefix.rsplit("-")[-1] hash_str = prefix.rsplit("-")[-1]
assert len(hash_str) == hash_length assert len(hash_str) == hash_length
@ -23,7 +23,7 @@ def test_set_install_hash_length(hash_length, mutable_config, tmpdir):
def test_set_install_hash_length_upper_case(mutable_config, tmpdir): def test_set_install_hash_length_upper_case(mutable_config, tmpdir):
mutable_config.set("config:install_hash_length", 5) mutable_config.set("config:install_hash_length", 5)
with spack.store.use_store(str(tmpdir), extra_data={"projections": {"all": "{name}-{HASH}"}}): with spack.store.use_store(str(tmpdir), extra_data={"projections": {"all": "{name}-{HASH}"}}):
spec = spack.spec.Spec("libelf").concretized() spec = spack.concretize.concretize_one("libelf")
prefix = spec.prefix prefix = spec.prefix
hash_str = prefix.rsplit("-")[-1] hash_str = prefix.rsplit("-")[-1]
assert len(hash_str) == 5 assert len(hash_str) == 5

View File

@ -36,6 +36,7 @@
import spack.caches import spack.caches
import spack.compiler import spack.compiler
import spack.compilers import spack.compilers
import spack.concretize
import spack.config import spack.config
import spack.directives_meta import spack.directives_meta
import spack.environment as ev import spack.environment as ev
@ -849,7 +850,7 @@ def _populate(mock_db):
""" """
def _install(spec): def _install(spec):
s = spack.spec.Spec(spec).concretized() s = spack.concretize.concretize_one(spec)
PackageInstaller([s.package], fake=True, explicit=True).install() PackageInstaller([s.package], fake=True, explicit=True).install()
_install("mpileaks ^mpich") _install("mpileaks ^mpich")
@ -1983,7 +1984,9 @@ def default_mock_concretization(config, mock_packages, concretized_specs_cache):
def _func(spec_str, tests=False): def _func(spec_str, tests=False):
key = spec_str, tests key = spec_str, tests
if key not in concretized_specs_cache: if key not in concretized_specs_cache:
concretized_specs_cache[key] = spack.spec.Spec(spec_str).concretized(tests=tests) concretized_specs_cache[key] = spack.concretize.concretize_one(
spack.spec.Spec(spec_str), tests=tests
)
return concretized_specs_cache[key].copy() return concretized_specs_cache[key].copy()
return _func return _func

View File

@ -8,8 +8,8 @@
from llnl.util.filesystem import mkdirp, touch, working_dir from llnl.util.filesystem import mkdirp, touch, working_dir
import spack.concretize
from spack.fetch_strategy import CvsFetchStrategy from spack.fetch_strategy import CvsFetchStrategy
from spack.spec import Spec
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import which from spack.util.executable import which
from spack.version import Version from spack.version import Version
@ -37,7 +37,7 @@ def test_fetch(type_of_test, mock_cvs_repository, config, mutable_mock_repo):
get_date = mock_cvs_repository.get_date get_date = mock_cvs_repository.get_date
# Construct the package under test # Construct the package under test
spec = Spec("cvs-test").concretized() spec = spack.concretize.concretize_one("cvs-test")
spec.package.versions[Version("cvs")] = test.args spec.package.versions[Version("cvs")] = test.args
# Enter the stage directory and check some properties # Enter the stage directory and check some properties

View File

@ -28,6 +28,7 @@
import llnl.util.lock as lk import llnl.util.lock as lk
from llnl.util.tty.colify import colify from llnl.util.tty.colify import colify
import spack.concretize
import spack.database import spack.database
import spack.deptypes as dt import spack.deptypes as dt
import spack.package_base import spack.package_base
@ -108,8 +109,8 @@ def test_query_by_install_tree(
up_db, down_db = upstream_and_downstream_db up_db, down_db = upstream_and_downstream_db
# Set the upstream DB to contain "pkg-c" and downstream to contain "pkg-b") # Set the upstream DB to contain "pkg-c" and downstream to contain "pkg-b")
b = spack.spec.Spec("pkg-b").concretized() b = spack.concretize.concretize_one("pkg-b")
c = spack.spec.Spec("pkg-c").concretized() c = spack.concretize.concretize_one("pkg-c")
with writable(up_db): with writable(up_db):
up_db.add(c) up_db.add(c)
up_db._read() up_db._read()
@ -127,7 +128,7 @@ def test_spec_installed_upstream(
# a known installed spec should say that it's installed # a known installed spec should say that it's installed
with spack.repo.use_repositories(mock_custom_repository): with spack.repo.use_repositories(mock_custom_repository):
spec = spack.spec.Spec("pkg-c").concretized() spec = spack.concretize.concretize_one("pkg-c")
assert not spec.installed assert not spec.installed
assert not spec.installed_upstream assert not spec.installed_upstream
@ -157,7 +158,7 @@ def test_installed_upstream(upstream_and_downstream_db, tmpdir):
builder.add_package("w", dependencies=[("x", None, None), ("y", None, None)]) builder.add_package("w", dependencies=[("x", None, None), ("y", None, None)])
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
spec = spack.spec.Spec("w").concretized() spec = spack.concretize.concretize_one("w")
with writable(upstream_db): with writable(upstream_db):
for dep in spec.traverse(root=False): for dep in spec.traverse(root=False):
upstream_db.add(dep) upstream_db.add(dep)
@ -169,7 +170,7 @@ def test_installed_upstream(upstream_and_downstream_db, tmpdir):
with pytest.raises(spack.database.ForbiddenLockError): with pytest.raises(spack.database.ForbiddenLockError):
upstream_db.get_by_hash(dep.dag_hash()) upstream_db.get_by_hash(dep.dag_hash())
new_spec = spack.spec.Spec("w").concretized() new_spec = spack.concretize.concretize_one("w")
downstream_db.add(new_spec) downstream_db.add(new_spec)
for dep in new_spec.traverse(root=False): for dep in new_spec.traverse(root=False):
upstream, record = downstream_db.query_by_spec_hash(dep.dag_hash()) upstream, record = downstream_db.query_by_spec_hash(dep.dag_hash())
@ -191,7 +192,7 @@ def test_removed_upstream_dep(upstream_and_downstream_db, tmpdir, capsys, config
builder.add_package("y", dependencies=[("z", None, None)]) builder.add_package("y", dependencies=[("z", None, None)])
with spack.repo.use_repositories(builder): with spack.repo.use_repositories(builder):
y = spack.spec.Spec("y").concretized() y = spack.concretize.concretize_one("y")
z = y["z"] z = y["z"]
# add dependency to upstream, dependents to downstream # add dependency to upstream, dependents to downstream
@ -225,7 +226,7 @@ def test_add_to_upstream_after_downstream(upstream_and_downstream_db, tmpdir):
builder.add_package("x") builder.add_package("x")
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
spec = spack.spec.Spec("x").concretized() spec = spack.concretize.concretize_one("x")
downstream_db.add(spec) downstream_db.add(spec)
with writable(upstream_db): with writable(upstream_db):
@ -258,7 +259,7 @@ def test_cannot_write_upstream(tmp_path, mock_packages, config):
db = spack.database.Database(str(tmp_path), is_upstream=True) db = spack.database.Database(str(tmp_path), is_upstream=True)
with pytest.raises(spack.database.ForbiddenLockError): with pytest.raises(spack.database.ForbiddenLockError):
db.add(spack.spec.Spec("pkg-a").concretized()) db.add(spack.concretize.concretize_one("pkg-a"))
@pytest.mark.usefixtures("config", "temporary_store") @pytest.mark.usefixtures("config", "temporary_store")
@ -272,7 +273,7 @@ def test_recursive_upstream_dbs(tmpdir, gen_mock_layout):
builder.add_package("x", dependencies=[("y", None, None)]) builder.add_package("x", dependencies=[("y", None, None)])
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
spec = spack.spec.Spec("x").concretized() spec = spack.concretize.concretize_one("x")
db_c = spack.database.Database(roots[2], layout=layouts[2]) db_c = spack.database.Database(roots[2], layout=layouts[2])
db_c.add(spec["z"]) db_c.add(spec["z"])
@ -422,7 +423,7 @@ def _check_remove_and_add_package(database: spack.database.Database, spec):
def _mock_install(spec: str): def _mock_install(spec: str):
s = spack.spec.Spec(spec).concretized() s = spack.concretize.concretize_one(spec)
PackageInstaller([s.package], fake=True, explicit=True).install() PackageInstaller([s.package], fake=True, explicit=True).install()
@ -767,8 +768,7 @@ def test_regression_issue_8036(mutable_database, usr_folder_exists):
# existing. Even when the package prefix exists, the package should # existing. Even when the package prefix exists, the package should
# not be considered installed until it is added to the database by # not be considered installed until it is added to the database by
# the installer with install(). # the installer with install().
s = spack.spec.Spec("externaltool@0.9") s = spack.concretize.concretize_one("externaltool@0.9")
s.concretize()
assert not s.installed assert not s.installed
# Now install the external package and check again the `installed` property # Now install the external package and check again the `installed` property
@ -783,8 +783,7 @@ def test_old_external_entries_prefix(mutable_database):
jsonschema.validate(db_obj, schema) jsonschema.validate(db_obj, schema)
s = spack.spec.Spec("externaltool") s = spack.concretize.concretize_one("externaltool")
s.concretize()
db_obj["database"]["installs"][s.dag_hash()]["path"] = "None" db_obj["database"]["installs"][s.dag_hash()]["path"] = "None"
@ -813,8 +812,7 @@ def test_uninstall_by_spec(mutable_database):
def test_query_unused_specs(mutable_database): def test_query_unused_specs(mutable_database):
# This spec installs a fake cmake as a build only dependency # This spec installs a fake cmake as a build only dependency
s = spack.spec.Spec("simple-inheritance") s = spack.concretize.concretize_one("simple-inheritance")
s.concretize()
PackageInstaller([s.package], fake=True, explicit=True).install() PackageInstaller([s.package], fake=True, explicit=True).install()
si = s.dag_hash() si = s.dag_hash()
@ -856,8 +854,7 @@ def check_unused(roots, deptype, expected):
def test_query_spec_with_conditional_dependency(mutable_database): def test_query_spec_with_conditional_dependency(mutable_database):
# The issue is triggered by having dependencies that are # The issue is triggered by having dependencies that are
# conditional on a Boolean variant # conditional on a Boolean variant
s = spack.spec.Spec("hdf5~mpi") s = spack.concretize.concretize_one("hdf5~mpi")
s.concretize()
PackageInstaller([s.package], fake=True, explicit=True).install() PackageInstaller([s.package], fake=True, explicit=True).install()
results = spack.store.STORE.db.query_local("hdf5 ^mpich") results = spack.store.STORE.db.query_local("hdf5 ^mpich")
@ -897,7 +894,7 @@ def _is(self, spec):
# Pretend the spec has been failure locked # Pretend the spec has been failure locked
monkeypatch.setattr(spack.database.FailureTracker, "lock_taken", _is) monkeypatch.setattr(spack.database.FailureTracker, "lock_taken", _is)
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
spack.store.STORE.failure_tracker.clear(s) spack.store.STORE.failure_tracker.clear(s)
out = capfd.readouterr()[0] out = capfd.readouterr()[0]
assert "Retaining failure marking" in out assert "Retaining failure marking" in out
@ -915,7 +912,7 @@ def _is(self, spec):
# Ensure raise OSError when try to remove the non-existent marking # Ensure raise OSError when try to remove the non-existent marking
monkeypatch.setattr(spack.database.FailureTracker, "persistent_mark", _is) monkeypatch.setattr(spack.database.FailureTracker, "persistent_mark", _is)
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
spack.store.STORE.failure_tracker.clear(s, force=True) spack.store.STORE.failure_tracker.clear(s, force=True)
out = capfd.readouterr()[1] out = capfd.readouterr()[1]
assert "Removing failure marking despite lock" in out assert "Removing failure marking despite lock" in out
@ -930,7 +927,7 @@ def _raise_exc(lock):
raise lk.LockTimeoutError("write", "/mock-lock", 1.234, 10) raise lk.LockTimeoutError("write", "/mock-lock", 1.234, 10)
with tmpdir.as_cwd(): with tmpdir.as_cwd():
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
# Ensure attempt to acquire write lock on the mark raises the exception # Ensure attempt to acquire write lock on the mark raises the exception
monkeypatch.setattr(lk.Lock, "acquire_write", _raise_exc) monkeypatch.setattr(lk.Lock, "acquire_write", _raise_exc)
@ -946,7 +943,7 @@ def _raise_exc(lock):
def test_prefix_failed(mutable_database, monkeypatch): def test_prefix_failed(mutable_database, monkeypatch):
"""Add coverage to failed operation.""" """Add coverage to failed operation."""
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
# Confirm the spec is not already marked as failed # Confirm the spec is not already marked as failed
assert not spack.store.STORE.failure_tracker.has_failed(s) assert not spack.store.STORE.failure_tracker.has_failed(s)
@ -970,7 +967,7 @@ def test_prefix_write_lock_error(mutable_database, monkeypatch):
def _raise(db, spec): def _raise(db, spec):
raise lk.LockError("Mock lock error") raise lk.LockError("Mock lock error")
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
# Ensure subsequent lock operations fail # Ensure subsequent lock operations fail
monkeypatch.setattr(lk.Lock, "acquire_write", _raise) monkeypatch.setattr(lk.Lock, "acquire_write", _raise)
@ -1178,7 +1175,7 @@ def test_reindex_with_upstreams(tmp_path, monkeypatch, mock_packages, config):
# we install `mpileaks` locally with dependencies in the upstream. And we even install # we install `mpileaks` locally with dependencies in the upstream. And we even install
# `mpileaks` with the same hash in the upstream. After reindexing, `mpileaks` should still be # `mpileaks` with the same hash in the upstream. After reindexing, `mpileaks` should still be
# in the local db, and `callpath` should not. # in the local db, and `callpath` should not.
mpileaks = spack.spec.Spec("mpileaks").concretized() mpileaks = spack.concretize.concretize_one("mpileaks")
callpath = mpileaks.dependencies("callpath")[0] callpath = mpileaks.dependencies("callpath")[0]
upstream_store = spack.store.create( upstream_store = spack.store.create(

View File

@ -5,6 +5,7 @@
import pytest import pytest
import spack.concretize
import spack.directives import spack.directives
import spack.repo import spack.repo
import spack.spec import spack.spec
@ -59,8 +60,8 @@ def test_constraints_from_context_are_merged(mock_packages):
@pytest.mark.regression("27754") @pytest.mark.regression("27754")
def test_extends_spec(config, mock_packages): def test_extends_spec(config, mock_packages):
extender = spack.spec.Spec("extends-spec").concretized() extender = spack.concretize.concretize_one("extends-spec")
extendee = spack.spec.Spec("extendee").concretized() extendee = spack.concretize.concretize_one("extendee")
assert extender.dependencies assert extender.dependencies
assert extender.package.extends(extendee) assert extender.package.extends(extendee)
@ -206,7 +207,7 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage):
def test_redistribute_directive(test_repo, spec_str, distribute_src, distribute_bin): def test_redistribute_directive(test_repo, spec_str, distribute_src, distribute_bin):
spec = spack.spec.Spec(spec_str) spec = spack.spec.Spec(spec_str)
assert spec.package_class.redistribute_source(spec) == distribute_src assert spec.package_class.redistribute_source(spec) == distribute_src
concretized_spec = spec.concretized() concretized_spec = spack.concretize.concretize_one(spec)
assert concretized_spec.package.redistribute_binary == distribute_bin assert concretized_spec.package.redistribute_binary == distribute_bin

View File

@ -13,6 +13,7 @@
from llnl.path import path_to_os_path from llnl.path import path_to_os_path
import spack.concretize
import spack.hash_types import spack.hash_types
import spack.paths import spack.paths
import spack.repo import spack.repo
@ -59,7 +60,7 @@ def test_yaml_directory_layout_parameters(tmpdir, default_mock_concretization):
assert package7 == path_package7 assert package7 == path_package7
# Test separation of architecture or namespace # Test separation of architecture or namespace
spec2 = Spec("libelf").concretized() spec2 = spack.concretize.concretize_one("libelf")
arch_scheme = ( arch_scheme = (
"{architecture.platform}/{architecture.target}/{architecture.os}/{name}/{version}/{hash:7}" "{architecture.platform}/{architecture.target}/{architecture.os}/{name}/{version}/{hash:7}"
@ -97,7 +98,7 @@ def test_read_and_write_spec(temporary_store, config, mock_packages):
# If a spec fails to concretize, just skip it. If it is a # If a spec fails to concretize, just skip it. If it is a
# real error, it will be caught by concretization tests. # real error, it will be caught by concretization tests.
try: try:
spec = spack.spec.Spec(name).concretized() spec = spack.concretize.concretize_one(name)
except Exception: except Exception:
continue continue
@ -136,7 +137,7 @@ def test_read_and_write_spec(temporary_store, config, mock_packages):
assert norm.eq_dag(spec_from_file) assert norm.eq_dag(spec_from_file)
# TODO: revise this when build deps are in dag_hash # TODO: revise this when build deps are in dag_hash
conc = read_separately.concretized().copy(deps=stored_deptypes) conc = spack.concretize.concretize_one(read_separately).copy(deps=stored_deptypes)
assert conc == spec_from_file assert conc == spec_from_file
assert conc.eq_dag(spec_from_file) assert conc.eq_dag(spec_from_file)
@ -172,12 +173,10 @@ def test_handle_unknown_package(temporary_store, config, mock_packages, tmp_path
# Create all the packages that are not in mock. # Create all the packages that are not in mock.
installed_specs = {} installed_specs = {}
for pkg_name in packages: for pkg_name in packages:
spec = spack.spec.Spec(pkg_name)
# If a spec fails to concretize, just skip it. If it is a # If a spec fails to concretize, just skip it. If it is a
# real error, it will be caught by concretization tests. # real error, it will be caught by concretization tests.
try: try:
spec.concretize() spec = spack.concretize.concretize_one(pkg_name)
except Exception: except Exception:
continue continue
@ -209,7 +208,7 @@ def test_find(temporary_store, config, mock_packages):
if name.startswith("external"): if name.startswith("external"):
# External package tests cannot be installed # External package tests cannot be installed
continue continue
spec = spack.spec.Spec(name).concretized() spec = spack.concretize.concretize_one(name)
installed_specs[spec.name] = spec installed_specs[spec.name] = spec
layout.create_install_directory(spec) layout.create_install_directory(spec)

View File

@ -7,7 +7,7 @@
import pytest import pytest
import spack.build_environment import spack.build_environment
import spack.spec import spack.concretize
from spack.package import build_system_flags, env_flags, inject_flags from spack.package import build_system_flags, env_flags, inject_flags
@ -30,10 +30,10 @@ def add_o3_to_build_system_cflags(pkg, name, flags):
class TestFlagHandlers: class TestFlagHandlers:
def test_no_build_system_flags(self, temp_env): def test_no_build_system_flags(self, temp_env):
# Test that both autotools and cmake work getting no build_system flags # Test that both autotools and cmake work getting no build_system flags
s1 = spack.spec.Spec("cmake-client").concretized() s1 = spack.concretize.concretize_one("cmake-client")
spack.build_environment.setup_package(s1.package, False) spack.build_environment.setup_package(s1.package, False)
s2 = spack.spec.Spec("patchelf").concretized() s2 = spack.concretize.concretize_one("patchelf")
spack.build_environment.setup_package(s2.package, False) spack.build_environment.setup_package(s2.package, False)
# Use cppflags as a canary # Use cppflags as a canary
@ -43,28 +43,28 @@ def test_no_build_system_flags(self, temp_env):
def test_unbound_method(self, temp_env): def test_unbound_method(self, temp_env):
# Other tests test flag_handlers set as bound methods and functions. # Other tests test flag_handlers set as bound methods and functions.
# This tests an unbound method in python2 (no change in python3). # This tests an unbound method in python2 (no change in python3).
s = spack.spec.Spec("mpileaks cppflags=-g").concretized() s = spack.concretize.concretize_one("mpileaks cppflags=-g")
s.package.flag_handler = s.package.__class__.inject_flags s.package.flag_handler = s.package.__class__.inject_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert os.environ["SPACK_CPPFLAGS"] == "-g" assert os.environ["SPACK_CPPFLAGS"] == "-g"
assert "CPPFLAGS" not in os.environ assert "CPPFLAGS" not in os.environ
def test_inject_flags(self, temp_env): def test_inject_flags(self, temp_env):
s = spack.spec.Spec("mpileaks cppflags=-g").concretized() s = spack.concretize.concretize_one("mpileaks cppflags=-g")
s.package.flag_handler = inject_flags s.package.flag_handler = inject_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert os.environ["SPACK_CPPFLAGS"] == "-g" assert os.environ["SPACK_CPPFLAGS"] == "-g"
assert "CPPFLAGS" not in os.environ assert "CPPFLAGS" not in os.environ
def test_env_flags(self, temp_env): def test_env_flags(self, temp_env):
s = spack.spec.Spec("mpileaks cppflags=-g").concretized() s = spack.concretize.concretize_one("mpileaks cppflags=-g")
s.package.flag_handler = env_flags s.package.flag_handler = env_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert os.environ["CPPFLAGS"] == "-g" assert os.environ["CPPFLAGS"] == "-g"
assert "SPACK_CPPFLAGS" not in os.environ assert "SPACK_CPPFLAGS" not in os.environ
def test_build_system_flags_cmake(self, temp_env): def test_build_system_flags_cmake(self, temp_env):
s = spack.spec.Spec("cmake-client cppflags=-g").concretized() s = spack.concretize.concretize_one("cmake-client cppflags=-g")
s.package.flag_handler = build_system_flags s.package.flag_handler = build_system_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert "SPACK_CPPFLAGS" not in os.environ assert "SPACK_CPPFLAGS" not in os.environ
@ -76,7 +76,7 @@ def test_build_system_flags_cmake(self, temp_env):
} }
def test_build_system_flags_autotools(self, temp_env): def test_build_system_flags_autotools(self, temp_env):
s = spack.spec.Spec("patchelf cppflags=-g").concretized() s = spack.concretize.concretize_one("patchelf cppflags=-g")
s.package.flag_handler = build_system_flags s.package.flag_handler = build_system_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert "SPACK_CPPFLAGS" not in os.environ assert "SPACK_CPPFLAGS" not in os.environ
@ -85,7 +85,7 @@ def test_build_system_flags_autotools(self, temp_env):
def test_build_system_flags_not_implemented(self, temp_env): def test_build_system_flags_not_implemented(self, temp_env):
"""Test the command line flags method raises a NotImplementedError""" """Test the command line flags method raises a NotImplementedError"""
s = spack.spec.Spec("mpileaks cppflags=-g").concretized() s = spack.concretize.concretize_one("mpileaks cppflags=-g")
s.package.flag_handler = build_system_flags s.package.flag_handler = build_system_flags
try: try:
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
@ -94,7 +94,7 @@ def test_build_system_flags_not_implemented(self, temp_env):
assert True assert True
def test_add_build_system_flags_autotools(self, temp_env): def test_add_build_system_flags_autotools(self, temp_env):
s = spack.spec.Spec("patchelf cppflags=-g").concretized() s = spack.concretize.concretize_one("patchelf cppflags=-g")
s.package.flag_handler = add_o3_to_build_system_cflags s.package.flag_handler = add_o3_to_build_system_cflags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert "-g" in os.environ["SPACK_CPPFLAGS"] assert "-g" in os.environ["SPACK_CPPFLAGS"]
@ -102,7 +102,7 @@ def test_add_build_system_flags_autotools(self, temp_env):
assert s.package.configure_flag_args == ["CFLAGS=-O3"] assert s.package.configure_flag_args == ["CFLAGS=-O3"]
def test_add_build_system_flags_cmake(self, temp_env): def test_add_build_system_flags_cmake(self, temp_env):
s = spack.spec.Spec("cmake-client cppflags=-g").concretized() s = spack.concretize.concretize_one("cmake-client cppflags=-g")
s.package.flag_handler = add_o3_to_build_system_cflags s.package.flag_handler = add_o3_to_build_system_cflags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert "-g" in os.environ["SPACK_CPPFLAGS"] assert "-g" in os.environ["SPACK_CPPFLAGS"]
@ -110,7 +110,7 @@ def test_add_build_system_flags_cmake(self, temp_env):
assert s.package.cmake_flag_args == ["-DCMAKE_C_FLAGS=-O3"] assert s.package.cmake_flag_args == ["-DCMAKE_C_FLAGS=-O3"]
def test_ld_flags_cmake(self, temp_env): def test_ld_flags_cmake(self, temp_env):
s = spack.spec.Spec("cmake-client ldflags=-mthreads").concretized() s = spack.concretize.concretize_one("cmake-client ldflags=-mthreads")
s.package.flag_handler = build_system_flags s.package.flag_handler = build_system_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert "SPACK_LDFLAGS" not in os.environ assert "SPACK_LDFLAGS" not in os.environ
@ -122,7 +122,7 @@ def test_ld_flags_cmake(self, temp_env):
} }
def test_ld_libs_cmake(self, temp_env): def test_ld_libs_cmake(self, temp_env):
s = spack.spec.Spec("cmake-client ldlibs=-lfoo").concretized() s = spack.concretize.concretize_one("cmake-client ldlibs=-lfoo")
s.package.flag_handler = build_system_flags s.package.flag_handler = build_system_flags
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)
assert "SPACK_LDLIBS" not in os.environ assert "SPACK_LDLIBS" not in os.environ
@ -138,7 +138,7 @@ def test_flag_handler(self, name, flags):
flags.append("-foo") flags.append("-foo")
return (flags, None, None) return (flags, None, None)
s = spack.spec.Spec("cmake-client").concretized() s = spack.concretize.concretize_one("cmake-client")
s.package.flag_handler = test_flag_handler s.package.flag_handler = test_flag_handler
spack.build_environment.setup_package(s.package, False) spack.build_environment.setup_package(s.package, False)

View File

@ -10,6 +10,7 @@
from llnl.util.filesystem import mkdirp, touch, working_dir from llnl.util.filesystem import mkdirp, touch, working_dir
import spack.concretize
import spack.config import spack.config
import spack.error import spack.error
import spack.fetch_strategy import spack.fetch_strategy
@ -185,8 +186,9 @@ def test_adhoc_version_submodules(
monkeypatch.setitem(pkg_class.versions, Version("git"), t.args) monkeypatch.setitem(pkg_class.versions, Version("git"), t.args)
monkeypatch.setattr(pkg_class, "git", "file://%s" % mock_git_repository.path, raising=False) monkeypatch.setattr(pkg_class, "git", "file://%s" % mock_git_repository.path, raising=False)
spec = Spec("git-test@{0}".format(mock_git_repository.unversioned_commit)) spec = spack.concretize.concretize_one(
spec.concretize() Spec("git-test@{0}".format(mock_git_repository.unversioned_commit))
)
spec.package.do_stage() spec.package.do_stage()
collected_fnames = set() collected_fnames = set()
for root, dirs, files in os.walk(spec.package.stage.source_path): for root, dirs, files in os.walk(spec.package.stage.source_path):

View File

@ -3,8 +3,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import io import io
import spack.concretize
import spack.graph import spack.graph
import spack.spec
def test_dynamic_dot_graph_mpileaks(default_mock_concretization): def test_dynamic_dot_graph_mpileaks(default_mock_concretization):
@ -38,7 +38,7 @@ def test_dynamic_dot_graph_mpileaks(default_mock_concretization):
def test_ascii_graph_mpileaks(config, mock_packages, monkeypatch): def test_ascii_graph_mpileaks(config, mock_packages, monkeypatch):
monkeypatch.setattr(spack.graph.AsciiGraph, "_node_label", lambda self, node: node.name) monkeypatch.setattr(spack.graph.AsciiGraph, "_node_label", lambda self, node: node.name)
s = spack.spec.Spec("mpileaks").concretized() s = spack.concretize.concretize_one("mpileaks")
stream = io.StringIO() stream = io.StringIO()
graph = spack.graph.AsciiGraph() graph = spack.graph.AsciiGraph()

View File

@ -8,9 +8,9 @@
from llnl.util.filesystem import mkdirp, touch, working_dir from llnl.util.filesystem import mkdirp, touch, working_dir
import spack.concretize
import spack.config import spack.config
from spack.fetch_strategy import HgFetchStrategy from spack.fetch_strategy import HgFetchStrategy
from spack.spec import Spec
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import which from spack.util.executable import which
from spack.version import Version from spack.version import Version
@ -40,7 +40,7 @@ def test_fetch(type_of_test, secure, mock_hg_repository, config, mutable_mock_re
h = mock_hg_repository.hash h = mock_hg_repository.hash
# Construct the package under test # Construct the package under test
s = Spec("hg-test").concretized() s = spack.concretize.concretize_one("hg-test")
monkeypatch.setitem(s.package.versions, Version("hg"), t.args) monkeypatch.setitem(s.package.versions, Version("hg"), t.args)
# Enter the stage directory and check some properties # Enter the stage directory and check some properties

View File

@ -11,6 +11,7 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.build_environment import spack.build_environment
import spack.concretize
import spack.config import spack.config
import spack.database import spack.database
import spack.error import spack.error
@ -41,7 +42,7 @@ def find_nothing(*args):
def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch): def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch):
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
assert spec.installed assert spec.installed
@ -53,7 +54,7 @@ def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch):
@pytest.mark.regression("11870") @pytest.mark.regression("11870")
def test_uninstall_non_existing_package(install_mockery, mock_fetch, monkeypatch): def test_uninstall_non_existing_package(install_mockery, mock_fetch, monkeypatch):
"""Ensure that we can uninstall a package that has been deleted from the repo""" """Ensure that we can uninstall a package that has been deleted from the repo"""
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
assert spec.installed assert spec.installed
@ -71,8 +72,7 @@ def test_uninstall_non_existing_package(install_mockery, mock_fetch, monkeypatch
def test_pkg_attributes(install_mockery, mock_fetch, monkeypatch): def test_pkg_attributes(install_mockery, mock_fetch, monkeypatch):
# Get a basic concrete spec for the dummy package. # Get a basic concrete spec for the dummy package.
spec = Spec("attributes-foo-app ^attributes-foo") spec = spack.concretize.concretize_one("attributes-foo-app ^attributes-foo")
spec.concretize()
assert spec.concrete assert spec.concrete
pkg = spec.package pkg = spec.package
@ -127,7 +127,7 @@ def remove_prefix(self):
def test_partial_install_delete_prefix_and_stage(install_mockery, mock_fetch, working_env): def test_partial_install_delete_prefix_and_stage(install_mockery, mock_fetch, working_env):
s = Spec("canfail").concretized() s = spack.concretize.concretize_one("canfail")
instance_rm_prefix = s.package.remove_prefix instance_rm_prefix = s.package.remove_prefix
@ -157,7 +157,7 @@ def test_failing_overwrite_install_should_keep_previous_installation(
the original install prefix instead of cleaning it. the original install prefix instead of cleaning it.
""" """
# Do a successful install # Do a successful install
s = Spec("canfail").concretized() s = spack.concretize.concretize_one("canfail")
s.package.set_install_succeed() s.package.set_install_succeed()
# Do a failing overwrite install # Do a failing overwrite install
@ -173,13 +173,11 @@ def test_failing_overwrite_install_should_keep_previous_installation(
def test_dont_add_patches_to_installed_package(install_mockery, mock_fetch, monkeypatch): def test_dont_add_patches_to_installed_package(install_mockery, mock_fetch, monkeypatch):
dependency = Spec("dependency-install") dependency = spack.concretize.concretize_one("dependency-install")
dependency.concretize()
PackageInstaller([dependency.package], explicit=True).install() PackageInstaller([dependency.package], explicit=True).install()
dependency_hash = dependency.dag_hash() dependency_hash = dependency.dag_hash()
dependent = Spec("dependent-install ^/" + dependency_hash) dependent = spack.concretize.concretize_one("dependent-install ^/" + dependency_hash)
dependent.concretize()
monkeypatch.setitem( monkeypatch.setitem(
dependency.package.patches, dependency.package.patches,
@ -191,20 +189,18 @@ def test_dont_add_patches_to_installed_package(install_mockery, mock_fetch, monk
def test_installed_dependency_request_conflicts(install_mockery, mock_fetch, mutable_mock_repo): def test_installed_dependency_request_conflicts(install_mockery, mock_fetch, mutable_mock_repo):
dependency = Spec("dependency-install") dependency = spack.concretize.concretize_one("dependency-install")
dependency.concretize()
PackageInstaller([dependency.package], explicit=True).install() PackageInstaller([dependency.package], explicit=True).install()
dependency_hash = dependency.dag_hash() dependency_hash = dependency.dag_hash()
dependent = Spec("conflicting-dependent ^/" + dependency_hash) dependent = Spec("conflicting-dependent ^/" + dependency_hash)
with pytest.raises(spack.error.UnsatisfiableSpecError): with pytest.raises(spack.error.UnsatisfiableSpecError):
dependent.concretize() spack.concretize.concretize_one(dependent)
def test_install_dependency_symlinks_pkg(install_mockery, mock_fetch, mutable_mock_repo): def test_install_dependency_symlinks_pkg(install_mockery, mock_fetch, mutable_mock_repo):
"""Test dependency flattening/symlinks mock package.""" """Test dependency flattening/symlinks mock package."""
spec = Spec("flatten-deps") spec = spack.concretize.concretize_one("flatten-deps")
spec.concretize()
pkg = spec.package pkg = spec.package
PackageInstaller([pkg], explicit=True).install() PackageInstaller([pkg], explicit=True).install()
@ -215,7 +211,7 @@ def test_install_dependency_symlinks_pkg(install_mockery, mock_fetch, mutable_mo
def test_install_times(install_mockery, mock_fetch, mutable_mock_repo): def test_install_times(install_mockery, mock_fetch, mutable_mock_repo):
"""Test install times added.""" """Test install times added."""
spec = Spec("dev-build-test-install-phases").concretized() spec = spack.concretize.concretize_one("dev-build-test-install-phases")
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
# Ensure dependency directory exists after the installation. # Ensure dependency directory exists after the installation.
@ -236,8 +232,7 @@ def test_flatten_deps(install_mockery, mock_fetch, mutable_mock_repo):
"""Explicitly test the flattening code for coverage purposes.""" """Explicitly test the flattening code for coverage purposes."""
# Unfortunately, executing the 'flatten-deps' spec's installation does # Unfortunately, executing the 'flatten-deps' spec's installation does
# not affect code coverage results, so be explicit here. # not affect code coverage results, so be explicit here.
spec = Spec("dependent-install") spec = spack.concretize.concretize_one("dependent-install")
spec.concretize()
pkg = spec.package pkg = spec.package
PackageInstaller([pkg], explicit=True).install() PackageInstaller([pkg], explicit=True).install()
@ -272,7 +267,7 @@ def install_upstream(tmpdir_factory, gen_mock_layout, install_mockery):
def _install_upstream(*specs): def _install_upstream(*specs):
for spec_str in specs: for spec_str in specs:
prepared_db.add(Spec(spec_str).concretized()) prepared_db.add(spack.concretize.concretize_one(spec_str))
downstream_root = str(tmpdir_factory.mktemp("mock_downstream_db_root")) downstream_root = str(tmpdir_factory.mktemp("mock_downstream_db_root"))
return downstream_root, upstream_layout return downstream_root, upstream_layout
@ -285,8 +280,7 @@ def test_installed_upstream_external(install_upstream, mock_fetch):
""" """
store_root, _ = install_upstream("externaltool") store_root, _ = install_upstream("externaltool")
with spack.store.use_store(store_root): with spack.store.use_store(store_root):
dependent = Spec("externaltest") dependent = spack.concretize.concretize_one("externaltest")
dependent.concretize()
new_dependency = dependent["externaltool"] new_dependency = dependent["externaltool"]
assert new_dependency.external assert new_dependency.external
@ -304,8 +298,8 @@ def test_installed_upstream(install_upstream, mock_fetch):
""" """
store_root, upstream_layout = install_upstream("dependency-install") store_root, upstream_layout = install_upstream("dependency-install")
with spack.store.use_store(store_root): with spack.store.use_store(store_root):
dependency = Spec("dependency-install").concretized() dependency = spack.concretize.concretize_one("dependency-install")
dependent = Spec("dependent-install").concretized() dependent = spack.concretize.concretize_one("dependent-install")
new_dependency = dependent["dependency-install"] new_dependency = dependent["dependency-install"]
assert new_dependency.installed_upstream assert new_dependency.installed_upstream
@ -319,7 +313,7 @@ def test_installed_upstream(install_upstream, mock_fetch):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_partial_install_keep_prefix(install_mockery, mock_fetch, monkeypatch, working_env): def test_partial_install_keep_prefix(install_mockery, mock_fetch, monkeypatch, working_env):
s = Spec("canfail").concretized() s = spack.concretize.concretize_one("canfail")
# If remove_prefix is called at any point in this test, that is an error # If remove_prefix is called at any point in this test, that is an error
monkeypatch.setattr(spack.package_base.PackageBase, "remove_prefix", mock_remove_prefix) monkeypatch.setattr(spack.package_base.PackageBase, "remove_prefix", mock_remove_prefix)
@ -336,7 +330,7 @@ def test_partial_install_keep_prefix(install_mockery, mock_fetch, monkeypatch, w
def test_second_install_no_overwrite_first(install_mockery, mock_fetch, monkeypatch): def test_second_install_no_overwrite_first(install_mockery, mock_fetch, monkeypatch):
s = Spec("canfail").concretized() s = spack.concretize.concretize_one("canfail")
monkeypatch.setattr(spack.package_base.PackageBase, "remove_prefix", mock_remove_prefix) monkeypatch.setattr(spack.package_base.PackageBase, "remove_prefix", mock_remove_prefix)
s.package.set_install_succeed() s.package.set_install_succeed()
@ -356,8 +350,8 @@ def test_install_prefix_collision_fails(config, mock_fetch, mock_packages, tmpdi
projections = {"projections": {"all": "one-prefix-per-package-{name}"}} projections = {"projections": {"all": "one-prefix-per-package-{name}"}}
with spack.store.use_store(str(tmpdir), extra_data=projections): with spack.store.use_store(str(tmpdir), extra_data=projections):
with spack.config.override("config:checksum", False): with spack.config.override("config:checksum", False):
pkg_a = Spec("libelf@0.8.13").concretized().package pkg_a = spack.concretize.concretize_one("libelf@0.8.13").package
pkg_b = Spec("libelf@0.8.12").concretized().package pkg_b = spack.concretize.concretize_one("libelf@0.8.12").package
PackageInstaller([pkg_a], explicit=True, fake=True).install() PackageInstaller([pkg_a], explicit=True, fake=True).install()
with pytest.raises(InstallError, match="Install prefix collision"): with pytest.raises(InstallError, match="Install prefix collision"):
@ -365,14 +359,14 @@ def test_install_prefix_collision_fails(config, mock_fetch, mock_packages, tmpdi
def test_store(install_mockery, mock_fetch): def test_store(install_mockery, mock_fetch):
spec = Spec("cmake-client").concretized() spec = spack.concretize.concretize_one("cmake-client")
pkg = spec.package pkg = spec.package
PackageInstaller([pkg], fake=True, explicit=True).install() PackageInstaller([pkg], fake=True, explicit=True).install()
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_failing_build(install_mockery, mock_fetch, capfd): def test_failing_build(install_mockery, mock_fetch, capfd):
spec = Spec("failing-build").concretized() spec = spack.concretize.concretize_one("failing-build")
pkg = spec.package pkg = spec.package
with pytest.raises(spack.build_environment.ChildError, match="Expected failure"): with pytest.raises(spack.build_environment.ChildError, match="Expected failure"):
@ -387,8 +381,7 @@ def test_uninstall_by_spec_errors(mutable_database):
"""Test exceptional cases with the uninstall command.""" """Test exceptional cases with the uninstall command."""
# Try to uninstall a spec that has not been installed # Try to uninstall a spec that has not been installed
spec = Spec("dependent-install") spec = spack.concretize.concretize_one("dependent-install")
spec.concretize()
with pytest.raises(InstallError, match="is not installed"): with pytest.raises(InstallError, match="is not installed"):
PackageBase.uninstall_by_spec(spec) PackageBase.uninstall_by_spec(spec)
@ -401,7 +394,7 @@ def test_uninstall_by_spec_errors(mutable_database):
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
def test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages, capfd, ensure_debug): def test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages, capfd, ensure_debug):
"""Test install phases with the nosource package.""" """Test install phases with the nosource package."""
spec = Spec("nosource").concretized() spec = spack.concretize.concretize_one("nosource")
pkg = spec.package pkg = spec.package
# Make sure install works even though there is no associated code. # Make sure install works even though there is no associated code.
@ -418,7 +411,7 @@ def test_nosource_bundle_pkg_install(
install_mockery, mock_fetch, mock_packages, capfd, ensure_debug install_mockery, mock_fetch, mock_packages, capfd, ensure_debug
): ):
"""Test install phases with the nosource-bundle package.""" """Test install phases with the nosource-bundle package."""
spec = Spec("nosource-bundle").concretized() spec = spack.concretize.concretize_one("nosource-bundle")
pkg = spec.package pkg = spec.package
# Make sure install works even though there is no associated code. # Make sure install works even though there is no associated code.
@ -432,7 +425,7 @@ def test_nosource_bundle_pkg_install(
def test_nosource_pkg_install_post_install(install_mockery, mock_fetch, mock_packages): def test_nosource_pkg_install_post_install(install_mockery, mock_fetch, mock_packages):
"""Test install phases with the nosource package with post-install.""" """Test install phases with the nosource package with post-install."""
spec = Spec("nosource-install").concretized() spec = spack.concretize.concretize_one("nosource-install")
pkg = spec.package pkg = spec.package
# Make sure both the install and post-install package methods work. # Make sure both the install and post-install package methods work.
@ -449,14 +442,14 @@ def test_nosource_pkg_install_post_install(install_mockery, mock_fetch, mock_pac
def test_pkg_build_paths(install_mockery): def test_pkg_build_paths(install_mockery):
# Get a basic concrete spec for the trivial install package. # Get a basic concrete spec for the trivial install package.
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
assert spec.package.log_path.endswith(_spack_build_logfile) assert spec.package.log_path.endswith(_spack_build_logfile)
assert spec.package.env_path.endswith(_spack_build_envfile) assert spec.package.env_path.endswith(_spack_build_envfile)
def test_pkg_install_paths(install_mockery): def test_pkg_install_paths(install_mockery):
# Get a basic concrete spec for the trivial install package. # Get a basic concrete spec for the trivial install package.
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
log_path = os.path.join(spec.prefix, ".spack", _spack_build_logfile + ".gz") log_path = os.path.join(spec.prefix, ".spack", _spack_build_logfile + ".gz")
assert spec.package.install_log_path == log_path assert spec.package.install_log_path == log_path
@ -493,7 +486,7 @@ def test_pkg_install_paths(install_mockery):
def test_log_install_without_build_files(install_mockery): def test_log_install_without_build_files(install_mockery):
"""Test the installer log function when no build files are present.""" """Test the installer log function when no build files are present."""
# Get a basic concrete spec for the trivial install package. # Get a basic concrete spec for the trivial install package.
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
# Attempt installing log without the build log file # Attempt installing log without the build log file
with pytest.raises(IOError, match="No such file or directory"): with pytest.raises(IOError, match="No such file or directory"):
@ -515,7 +508,7 @@ def _install(src, dest):
monkeypatch.setattr(fs, "install", _install) monkeypatch.setattr(fs, "install", _install)
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
# Set up mock build files and try again to include archive failure # Set up mock build files and try again to include archive failure
log_path = spec.package.log_path log_path = spec.package.log_path
@ -587,7 +580,7 @@ def test_empty_install_sanity_check_prefix(
monkeypatch, install_mockery, mock_fetch, mock_packages monkeypatch, install_mockery, mock_fetch, mock_packages
): ):
"""Test empty install triggers sanity_check_prefix.""" """Test empty install triggers sanity_check_prefix."""
spec = Spec("failing-empty-install").concretized() spec = spack.concretize.concretize_one("failing-empty-install")
with pytest.raises(spack.build_environment.ChildError, match="Nothing was installed"): with pytest.raises(spack.build_environment.ChildError, match="Nothing was installed"):
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
@ -599,7 +592,7 @@ def test_install_from_binary_with_missing_patch_succeeds(
pushing the package to a binary cache, installation from that binary cache shouldn't error out pushing the package to a binary cache, installation from that binary cache shouldn't error out
because of the missing patch.""" because of the missing patch."""
# Create a spec s with non-existing patches # Create a spec s with non-existing patches
s = Spec("trivial-install-test-package").concretized() s = spack.concretize.concretize_one("trivial-install-test-package")
patches = ["a" * 64] patches = ["a" * 64]
s_dict = s.to_dict() s_dict = s.to_dict()
s_dict["spec"]["nodes"][0]["patches"] = patches s_dict["spec"]["nodes"][0]["patches"] = patches

View File

@ -16,6 +16,7 @@
import llnl.util.tty as tty import llnl.util.tty as tty
import spack.binary_distribution import spack.binary_distribution
import spack.concretize
import spack.database import spack.database
import spack.deptypes as dt import spack.deptypes as dt
import spack.error import spack.error
@ -81,7 +82,7 @@ def create_installer(
) -> inst.PackageInstaller: ) -> inst.PackageInstaller:
"""Create an installer instance for a list of specs or package names that will be """Create an installer instance for a list of specs or package names that will be
concretized.""" concretized."""
_specs = [spack.spec.Spec(s).concretized() if isinstance(s, str) else s for s in specs] _specs = [spack.concretize.concretize_one(s) if isinstance(s, str) else s for s in specs]
_install_args = {} if install_args is None else install_args _install_args = {} if install_args is None else install_args
return inst.PackageInstaller([spec.package for spec in _specs], **_install_args) return inst.PackageInstaller([spec.package for spec in _specs], **_install_args)
@ -96,8 +97,7 @@ def test_hms(sec, result):
def test_get_dependent_ids(install_mockery, mock_packages): def test_get_dependent_ids(install_mockery, mock_packages):
# Concretize the parent package, which handle dependency too # Concretize the parent package, which handle dependency too
spec = spack.spec.Spec("pkg-a") spec = spack.concretize.concretize_one("pkg-a")
spec.concretize()
assert spec.concrete assert spec.concrete
pkg_id = inst.package_id(spec) pkg_id = inst.package_id(spec)
@ -133,8 +133,7 @@ def test_install_msg(monkeypatch):
def test_install_from_cache_errors(install_mockery): def test_install_from_cache_errors(install_mockery):
"""Test to ensure cover install from cache errors.""" """Test to ensure cover install from cache errors."""
spec = spack.spec.Spec("trivial-install-test-package") spec = spack.concretize.concretize_one("trivial-install-test-package")
spec.concretize()
assert spec.concrete assert spec.concrete
# Check with cache-only # Check with cache-only
@ -153,8 +152,7 @@ def test_install_from_cache_errors(install_mockery):
def test_install_from_cache_ok(install_mockery, monkeypatch): def test_install_from_cache_ok(install_mockery, monkeypatch):
"""Test to ensure cover _install_from_cache to the return.""" """Test to ensure cover _install_from_cache to the return."""
spec = spack.spec.Spec("trivial-install-test-package") spec = spack.concretize.concretize_one("trivial-install-test-package")
spec.concretize()
monkeypatch.setattr(inst, "_try_install_from_binary_cache", _true) monkeypatch.setattr(inst, "_try_install_from_binary_cache", _true)
monkeypatch.setattr(spack.hooks, "post_install", _noop) monkeypatch.setattr(spack.hooks, "post_install", _noop)
@ -163,8 +161,7 @@ def test_install_from_cache_ok(install_mockery, monkeypatch):
def test_process_external_package_module(install_mockery, monkeypatch, capfd): def test_process_external_package_module(install_mockery, monkeypatch, capfd):
"""Test to simply cover the external module message path.""" """Test to simply cover the external module message path."""
spec = spack.spec.Spec("trivial-install-test-package") spec = spack.concretize.concretize_one("trivial-install-test-package")
spec.concretize()
assert spec.concrete assert spec.concrete
# Ensure take the external module path WITHOUT any changes to the database # Ensure take the external module path WITHOUT any changes to the database
@ -191,7 +188,7 @@ def _spec(spec, unsigned=False, mirrors_for_spec=None):
# Skip database updates # Skip database updates
monkeypatch.setattr(spack.database.Database, "add", _noop) monkeypatch.setattr(spack.database.Database, "add", _noop)
spec = spack.spec.Spec("pkg-a").concretized() spec = spack.concretize.concretize_one("pkg-a")
assert inst._process_binary_cache_tarball(spec.package, explicit=False, unsigned=False) assert inst._process_binary_cache_tarball(spec.package, explicit=False, unsigned=False)
out = capfd.readouterr()[0] out = capfd.readouterr()[0]
@ -201,8 +198,7 @@ def _spec(spec, unsigned=False, mirrors_for_spec=None):
def test_try_install_from_binary_cache(install_mockery, mock_packages, monkeypatch): def test_try_install_from_binary_cache(install_mockery, mock_packages, monkeypatch):
"""Test return false when no match exists in the mirror""" """Test return false when no match exists in the mirror"""
spec = spack.spec.Spec("mpich") spec = spack.concretize.concretize_one("mpich")
spec.concretize()
result = inst._try_install_from_binary_cache(spec.package, False, False) result = inst._try_install_from_binary_cache(spec.package, False, False)
assert not result assert not result
@ -274,7 +270,7 @@ def _mock_installed(self):
def test_check_before_phase_error(install_mockery): def test_check_before_phase_error(install_mockery):
s = spack.spec.Spec("trivial-install-test-package").concretized() s = spack.concretize.concretize_one("trivial-install-test-package")
s.package.stop_before_phase = "beforephase" s.package.stop_before_phase = "beforephase"
with pytest.raises(inst.BadInstallPhase) as exc_info: with pytest.raises(inst.BadInstallPhase) as exc_info:
inst._check_last_phase(s.package) inst._check_last_phase(s.package)
@ -285,7 +281,7 @@ def test_check_before_phase_error(install_mockery):
def test_check_last_phase_error(install_mockery): def test_check_last_phase_error(install_mockery):
s = spack.spec.Spec("trivial-install-test-package").concretized() s = spack.concretize.concretize_one("trivial-install-test-package")
s.package.stop_before_phase = None s.package.stop_before_phase = None
s.package.last_phase = "badphase" s.package.last_phase = "badphase"
with pytest.raises(inst.BadInstallPhase) as exc_info: with pytest.raises(inst.BadInstallPhase) as exc_info:
@ -420,15 +416,13 @@ def test_package_id_err(install_mockery):
def test_package_id_ok(install_mockery): def test_package_id_ok(install_mockery):
spec = spack.spec.Spec("trivial-install-test-package") spec = spack.concretize.concretize_one("trivial-install-test-package")
spec.concretize()
assert spec.concrete assert spec.concrete
assert spec.name in inst.package_id(spec) assert spec.name in inst.package_id(spec)
def test_fake_install(install_mockery): def test_fake_install(install_mockery):
spec = spack.spec.Spec("trivial-install-test-package") spec = spack.concretize.concretize_one("trivial-install-test-package")
spec.concretize()
assert spec.concrete assert spec.concrete
pkg = spec.package pkg = spec.package
@ -440,7 +434,7 @@ def test_dump_packages_deps_ok(install_mockery, tmpdir, mock_packages):
"""Test happy path for dump_packages with dependencies.""" """Test happy path for dump_packages with dependencies."""
spec_name = "simple-inheritance" spec_name = "simple-inheritance"
spec = spack.spec.Spec(spec_name).concretized() spec = spack.concretize.concretize_one(spec_name)
inst.dump_packages(spec, str(tmpdir)) inst.dump_packages(spec, str(tmpdir))
repo = mock_packages.repos[0] repo = mock_packages.repos[0]
@ -471,7 +465,7 @@ def _repoerr(repo, name):
# the try-except block # the try-except block
monkeypatch.setattr(spack.store.STORE.layout, "build_packages_path", bpp_path) monkeypatch.setattr(spack.store.STORE.layout, "build_packages_path", bpp_path)
spec = spack.spec.Spec("simple-inheritance").concretized() spec = spack.concretize.concretize_one("simple-inheritance")
path = str(tmpdir) path = str(tmpdir)
# The call to install_tree will raise the exception since not mocking # The call to install_tree will raise the exception since not mocking
@ -581,7 +575,7 @@ def test_check_deps_status_install_failure(install_mockery):
"""Tests that checking the dependency status on a request to install """Tests that checking the dependency status on a request to install
'a' fails, if we mark the dependency as failed. 'a' fails, if we mark the dependency as failed.
""" """
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
for dep in s.traverse(root=False): for dep in s.traverse(root=False):
spack.store.STORE.failure_tracker.mark(dep) spack.store.STORE.failure_tracker.mark(dep)
@ -654,8 +648,8 @@ def test_installer_init_requests(install_mockery):
@pytest.mark.parametrize("transitive", [True, False]) @pytest.mark.parametrize("transitive", [True, False])
def test_install_spliced(install_mockery, mock_fetch, monkeypatch, capsys, transitive): def test_install_spliced(install_mockery, mock_fetch, monkeypatch, capsys, transitive):
"""Test installing a spliced spec""" """Test installing a spliced spec"""
spec = spack.spec.Spec("splice-t").concretized() spec = spack.concretize.concretize_one("splice-t")
dep = spack.spec.Spec("splice-h+foo").concretized() dep = spack.concretize.concretize_one("splice-h+foo")
# Do the splice. # Do the splice.
out = spec.splice(dep, transitive) out = spec.splice(dep, transitive)
@ -669,8 +663,8 @@ def test_install_spliced(install_mockery, mock_fetch, monkeypatch, capsys, trans
@pytest.mark.parametrize("transitive", [True, False]) @pytest.mark.parametrize("transitive", [True, False])
def test_install_spliced_build_spec_installed(install_mockery, capfd, mock_fetch, transitive): def test_install_spliced_build_spec_installed(install_mockery, capfd, mock_fetch, transitive):
"""Test installing a spliced spec with the build spec already installed""" """Test installing a spliced spec with the build spec already installed"""
spec = spack.spec.Spec("splice-t").concretized() spec = spack.concretize.concretize_one("splice-t")
dep = spack.spec.Spec("splice-h+foo").concretized() dep = spack.concretize.concretize_one("splice-h+foo")
# Do the splice. # Do the splice.
out = spec.splice(dep, transitive) out = spec.splice(dep, transitive)
@ -696,8 +690,8 @@ def test_install_splice_root_from_binary(
): ):
"""Test installing a spliced spec with the root available in binary cache""" """Test installing a spliced spec with the root available in binary cache"""
# Test splicing and rewiring a spec with the same name, different hash. # Test splicing and rewiring a spec with the same name, different hash.
original_spec = spack.spec.Spec(root_str).concretized() original_spec = spack.concretize.concretize_one(root_str)
spec_to_splice = spack.spec.Spec("splice-h+foo").concretized() spec_to_splice = spack.concretize.concretize_one("splice-h+foo")
PackageInstaller([original_spec.package, spec_to_splice.package]).install() PackageInstaller([original_spec.package, spec_to_splice.package]).install()
@ -853,7 +847,7 @@ def _chgrp(path, group, follow_symlinks=True):
monkeypatch.setattr(fs, "chgrp", _chgrp) monkeypatch.setattr(fs, "chgrp", _chgrp)
build_task = create_build_task( build_task = create_build_task(
spack.spec.Spec("trivial-install-test-package").concretized().package spack.concretize.concretize_one("trivial-install-test-package").package
) )
spec = build_task.request.pkg.spec spec = build_task.request.pkg.spec
@ -1024,7 +1018,8 @@ def test_install_fail_multi(install_mockery, mock_fetch, monkeypatch):
def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys): def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys):
"""Test fail_fast install when an install failure is detected.""" """Test fail_fast install when an install failure is detected."""
b, c = spack.spec.Spec("pkg-b").concretized(), spack.spec.Spec("pkg-c").concretized() b = spack.concretize.concretize_one("pkg-b")
c = spack.concretize.concretize_one("pkg-c")
b_id, c_id = inst.package_id(b), inst.package_id(c) b_id, c_id = inst.package_id(b), inst.package_id(c)
installer = create_installer([b, c], {"fail_fast": True}) installer = create_installer([b, c], {"fail_fast": True})
@ -1093,7 +1088,7 @@ def _requeued(installer, task, install_status):
def test_install_lock_installed_requeue(install_mockery, monkeypatch, capfd): def test_install_lock_installed_requeue(install_mockery, monkeypatch, capfd):
"""Cover basic install handling for installed package.""" """Cover basic install handling for installed package."""
b = spack.spec.Spec("pkg-b").concretized() b = spack.concretize.concretize_one("pkg-b")
b_pkg_id = inst.package_id(b) b_pkg_id = inst.package_id(b)
installer = create_installer([b]) installer = create_installer([b])
@ -1279,7 +1274,7 @@ def test_term_status_line():
@pytest.mark.parametrize("explicit", [True, False]) @pytest.mark.parametrize("explicit", [True, False])
def test_single_external_implicit_install(install_mockery, explicit): def test_single_external_implicit_install(install_mockery, explicit):
pkg = "trivial-install-test-package" pkg = "trivial-install-test-package"
s = spack.spec.Spec(pkg).concretized() s = spack.concretize.concretize_one(pkg)
s.external_path = "/usr" s.external_path = "/usr"
args = {"explicit": [s.dag_hash()] if explicit else []} args = {"explicit": [s.dag_hash()] if explicit else []}
create_installer([s], args).install() create_installer([s], args).install()
@ -1288,7 +1283,7 @@ def test_single_external_implicit_install(install_mockery, explicit):
def test_overwrite_install_does_install_build_deps(install_mockery, mock_fetch): def test_overwrite_install_does_install_build_deps(install_mockery, mock_fetch):
"""When overwrite installing something from sources, build deps should be installed.""" """When overwrite installing something from sources, build deps should be installed."""
s = spack.spec.Spec("dtrun3").concretized() s = spack.concretize.concretize_one("dtrun3")
create_installer([s]).install() create_installer([s]).install()
# Verify there is a pure build dep # Verify there is a pure build dep
@ -1310,7 +1305,7 @@ def test_overwrite_install_does_install_build_deps(install_mockery, mock_fetch):
def test_print_install_test_log_skipped(install_mockery, mock_packages, capfd, run_tests): def test_print_install_test_log_skipped(install_mockery, mock_packages, capfd, run_tests):
"""Confirm printing of install log skipped if not run/no failures.""" """Confirm printing of install log skipped if not run/no failures."""
name = "trivial-install-test-package" name = "trivial-install-test-package"
s = spack.spec.Spec(name).concretized() s = spack.concretize.concretize_one(name)
pkg = s.package pkg = s.package
pkg.run_tests = run_tests pkg.run_tests = run_tests
@ -1324,7 +1319,7 @@ def test_print_install_test_log_failures(
): ):
"""Confirm expected outputs when there are test failures.""" """Confirm expected outputs when there are test failures."""
name = "trivial-install-test-package" name = "trivial-install-test-package"
s = spack.spec.Spec(name).concretized() s = spack.concretize.concretize_one(name)
pkg = s.package pkg = s.package
# Missing test log is an error # Missing test log is an error

View File

@ -11,6 +11,7 @@
from llnl.util.symlink import resolve_link_target_relative_to_the_link from llnl.util.symlink import resolve_link_target_relative_to_the_link
import spack.caches import spack.caches
import spack.concretize
import spack.config import spack.config
import spack.fetch_strategy import spack.fetch_strategy
import spack.mirrors.layout import spack.mirrors.layout
@ -43,7 +44,7 @@ def set_up_package(name, repository, url_attr):
2. Point the package's version args at that repo. 2. Point the package's version args at that repo.
""" """
# Set up packages to point at mock repos. # Set up packages to point at mock repos.
s = Spec(name).concretized() s = spack.concretize.concretize_one(name)
repos[name] = repository repos[name] = repository
# change the fetch args of the first (only) version. # change the fetch args of the first (only) version.
@ -60,7 +61,7 @@ def check_mirror():
mirrors = {"spack-mirror-test": url_util.path_to_file_url(mirror_root)} mirrors = {"spack-mirror-test": url_util.path_to_file_url(mirror_root)}
with spack.config.override("mirrors", mirrors): with spack.config.override("mirrors", mirrors):
with spack.config.override("config:checksum", False): with spack.config.override("config:checksum", False):
specs = [Spec(x).concretized() for x in repos] specs = [spack.concretize.concretize_one(x) for x in repos]
spack.mirrors.utils.create(mirror_root, specs) spack.mirrors.utils.create(mirror_root, specs)
# Stage directory exists # Stage directory exists
@ -77,7 +78,7 @@ def check_mirror():
# Now try to fetch each package. # Now try to fetch each package.
for name, mock_repo in repos.items(): for name, mock_repo in repos.items():
spec = Spec(name).concretized() spec = spack.concretize.concretize_one(name)
pkg = spec.package pkg = spec.package
with spack.config.override("config:checksum", False): with spack.config.override("config:checksum", False):
@ -212,13 +213,15 @@ def test_invalid_json_mirror_collection(invalid_json, error_message):
def test_mirror_archive_paths_no_version(mock_packages, mock_archive): def test_mirror_archive_paths_no_version(mock_packages, mock_archive):
spec = Spec("trivial-install-test-package@=nonexistingversion").concretized() spec = spack.concretize.concretize_one(
Spec("trivial-install-test-package@=nonexistingversion")
)
fetcher = spack.fetch_strategy.URLFetchStrategy(url=mock_archive.url) fetcher = spack.fetch_strategy.URLFetchStrategy(url=mock_archive.url)
spack.mirrors.layout.default_mirror_layout(fetcher, "per-package-ref", spec) spack.mirrors.layout.default_mirror_layout(fetcher, "per-package-ref", spec)
def test_mirror_with_url_patches(mock_packages, monkeypatch): def test_mirror_with_url_patches(mock_packages, monkeypatch):
spec = Spec("patch-several-dependencies").concretized() spec = spack.concretize.concretize_one("patch-several-dependencies")
files_cached_in_mirror = set() files_cached_in_mirror = set()
def record_store(_class, fetcher, relative_dst, cosmetic_path=None): def record_store(_class, fetcher, relative_dst, cosmetic_path=None):

View File

@ -9,6 +9,7 @@
from llnl.util.symlink import readlink from llnl.util.symlink import readlink
import spack.cmd.modules import spack.cmd.modules
import spack.concretize
import spack.config import spack.config
import spack.error import spack.error
import spack.modules import spack.modules
@ -17,10 +18,8 @@
import spack.package_base import spack.package_base
import spack.package_prefs import spack.package_prefs
import spack.repo import spack.repo
import spack.spec
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.modules.common import UpstreamModuleIndex from spack.modules.common import UpstreamModuleIndex
from spack.spec import Spec
pytestmark = [ pytestmark = [
pytest.mark.not_on_windows("does not run on windows"), pytest.mark.not_on_windows("does not run on windows"),
@ -60,7 +59,7 @@ def mock_package_perms(monkeypatch):
def test_modules_written_with_proper_permissions( def test_modules_written_with_proper_permissions(
mock_module_filename, mock_package_perms, mock_packages, config mock_module_filename, mock_package_perms, mock_packages, config
): ):
spec = spack.spec.Spec("mpileaks").concretized() spec = spack.concretize.concretize_one("mpileaks")
# The code tested is common to all module types, but has to be tested from # The code tested is common to all module types, but has to be tested from
# one. Tcl picked at random # one. Tcl picked at random
@ -74,7 +73,7 @@ def test_modules_written_with_proper_permissions(
def test_modules_default_symlink( def test_modules_default_symlink(
module_type, mock_packages, mock_module_filename, mock_module_defaults, config module_type, mock_packages, mock_module_filename, mock_module_defaults, config
): ):
spec = spack.spec.Spec("mpileaks@2.3").concretized() spec = spack.concretize.concretize_one("mpileaks@2.3")
mock_module_defaults(spec.format("{name}{@version}"), True) mock_module_defaults(spec.format("{name}{@version}"), True)
generator_cls = spack.modules.module_types[module_type] generator_cls = spack.modules.module_types[module_type]
@ -180,7 +179,7 @@ def test_get_module_upstream():
@pytest.mark.regression("14347") @pytest.mark.regression("14347")
def test_load_installed_package_not_in_repo(install_mockery, mock_fetch, monkeypatch): def test_load_installed_package_not_in_repo(install_mockery, mock_fetch, monkeypatch):
"""Test that installed packages that have been removed are still loadable""" """Test that installed packages that have been removed are still loadable"""
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
spack.modules.module_types["tcl"](spec, "default", True).write() spack.modules.module_types["tcl"](spec, "default", True).write()

View File

@ -5,6 +5,7 @@
import pytest import pytest
import spack.concretize
import spack.modules.lmod import spack.modules.lmod
import spack.modules.tcl import spack.modules.tcl
import spack.spec import spack.spec
@ -18,7 +19,7 @@ def modulefile_content(request):
def _impl(spec_like, module_set_name="default", explicit=True): def _impl(spec_like, module_set_name="default", explicit=True):
if isinstance(spec_like, str): if isinstance(spec_like, str):
spec_like = spack.spec.Spec(spec_like) spec_like = spack.spec.Spec(spec_like)
spec = spec_like.concretized() spec = spack.concretize.concretize_one(spec_like)
generator = writer_cls(spec, module_set_name, explicit) generator = writer_cls(spec, module_set_name, explicit)
generator.write(overwrite=True) generator.write(overwrite=True)
written_module = pathlib.Path(generator.layout.filename) written_module = pathlib.Path(generator.layout.filename)
@ -35,7 +36,7 @@ def factory(request, mock_modules_root):
writer_cls = getattr(request.module, "writer_cls") writer_cls = getattr(request.module, "writer_cls")
def _mock(spec_string, module_set_name="default", explicit=True): def _mock(spec_string, module_set_name="default", explicit=True):
spec = spack.spec.Spec(spec_string).concretized() spec = spack.concretize.concretize_one(spec_string)
return writer_cls(spec, module_set_name, explicit), spec return writer_cls(spec, module_set_name, explicit), spec
return _mock return _mock

View File

@ -8,6 +8,7 @@
import archspec.cpu import archspec.cpu
import spack.concretize
import spack.config import spack.config
import spack.environment as ev import spack.environment as ev
import spack.main import spack.main
@ -435,7 +436,7 @@ def test_modules_relative_to_view(
module_configuration("with_view") module_configuration("with_view")
install("--add", "cmake") install("--add", "cmake")
spec = spack.spec.Spec("cmake").concretized() spec = spack.concretize.concretize_one("cmake")
content = modulefile_content("cmake") content = modulefile_content("cmake")
expected = e.default_view.get_projection_for_spec(spec) expected = e.default_view.get_projection_for_spec(spec)
@ -455,7 +456,7 @@ def test_hide_implicits(self, module_configuration, temporary_store):
"""Tests the addition and removal of hide command in modulerc.""" """Tests the addition and removal of hide command in modulerc."""
module_configuration("hide_implicits") module_configuration("hide_implicits")
spec = spack.spec.Spec("mpileaks@2.3").concretized() spec = spack.concretize.concretize_one("mpileaks@2.3")
# mpileaks is defined as implicit, thus hide command should appear in modulerc # mpileaks is defined as implicit, thus hide command should appear in modulerc
writer = writer_cls(spec, "default", False) writer = writer_cls(spec, "default", False)
@ -507,8 +508,8 @@ def test_hide_implicits(self, module_configuration, temporary_store):
# three versions of mpileaks are implicit # three versions of mpileaks are implicit
writer = writer_cls(spec, "default", False) writer = writer_cls(spec, "default", False)
writer.write(overwrite=True) writer.write(overwrite=True)
spec_alt1 = spack.spec.Spec("mpileaks@2.2").concretized() spec_alt1 = spack.concretize.concretize_one("mpileaks@2.2")
spec_alt2 = spack.spec.Spec("mpileaks@2.1").concretized() spec_alt2 = spack.concretize.concretize_one("mpileaks@2.1")
writer_alt1 = writer_cls(spec_alt1, "default", False) writer_alt1 = writer_cls(spec_alt1, "default", False)
writer_alt1.write(overwrite=True) writer_alt1.write(overwrite=True)
writer_alt2 = writer_cls(spec_alt2, "default", False) writer_alt2 = writer_cls(spec_alt2, "default", False)

View File

@ -8,9 +8,9 @@
import archspec.cpu import archspec.cpu
import spack.concretize
import spack.modules.common import spack.modules.common
import spack.modules.tcl import spack.modules.tcl
import spack.spec
mpich_spec_string = "mpich@3.0.4" mpich_spec_string = "mpich@3.0.4"
mpileaks_spec_string = "mpileaks" mpileaks_spec_string = "mpileaks"
@ -393,8 +393,7 @@ def test_setup_environment(self, modulefile_content, module_configuration):
assert len([x for x in content if "setenv FOOBAR" in x]) == 1 assert len([x for x in content if "setenv FOOBAR" in x]) == 1
assert len([x for x in content if "setenv FOOBAR {mpileaks}" in x]) == 1 assert len([x for x in content if "setenv FOOBAR {mpileaks}" in x]) == 1
spec = spack.spec.Spec("mpileaks") spec = spack.concretize.concretize_one("mpileaks")
spec.concretize()
content = modulefile_content(spec["callpath"]) content = modulefile_content(spec["callpath"])
assert len([x for x in content if "setenv FOOBAR" in x]) == 1 assert len([x for x in content if "setenv FOOBAR" in x]) == 1
@ -468,14 +467,12 @@ def test_hide_implicits_with_arg(self, module_configuration):
module_configuration("exclude_implicits") module_configuration("exclude_implicits")
# mpileaks is defined as explicit with explicit argument set on writer # mpileaks is defined as explicit with explicit argument set on writer
mpileaks_spec = spack.spec.Spec("mpileaks") mpileaks_spec = spack.concretize.concretize_one("mpileaks")
mpileaks_spec.concretize()
writer = writer_cls(mpileaks_spec, "default", True) writer = writer_cls(mpileaks_spec, "default", True)
assert not writer.conf.excluded assert not writer.conf.excluded
# callpath is defined as implicit with explicit argument set on writer # callpath is defined as implicit with explicit argument set on writer
callpath_spec = spack.spec.Spec("callpath") callpath_spec = spack.concretize.concretize_one("callpath")
callpath_spec.concretize()
writer = writer_cls(callpath_spec, "default", False) writer = writer_cls(callpath_spec, "default", False)
assert writer.conf.excluded assert writer.conf.excluded
@ -510,7 +507,7 @@ def test_hide_implicits(self, module_configuration, temporary_store):
"""Tests the addition and removal of hide command in modulerc.""" """Tests the addition and removal of hide command in modulerc."""
module_configuration("hide_implicits") module_configuration("hide_implicits")
spec = spack.spec.Spec("mpileaks@2.3").concretized() spec = spack.concretize.concretize_one("mpileaks@2.3")
# mpileaks is defined as implicit, thus hide command should appear in modulerc # mpileaks is defined as implicit, thus hide command should appear in modulerc
writer = writer_cls(spec, "default", False) writer = writer_cls(spec, "default", False)
@ -557,8 +554,8 @@ def test_hide_implicits(self, module_configuration, temporary_store):
# three versions of mpileaks are implicit # three versions of mpileaks are implicit
writer = writer_cls(spec, "default", False) writer = writer_cls(spec, "default", False)
writer.write(overwrite=True) writer.write(overwrite=True)
spec_alt1 = spack.spec.Spec("mpileaks@2.2").concretized() spec_alt1 = spack.concretize.concretize_one("mpileaks@2.2")
spec_alt2 = spack.spec.Spec("mpileaks@2.1").concretized() spec_alt2 = spack.concretize.concretize_one("mpileaks@2.1")
writer_alt1 = writer_cls(spec_alt1, "default", False) writer_alt1 = writer_cls(spec_alt1, "default", False)
writer_alt1.write(overwrite=True) writer_alt1.write(overwrite=True)
writer_alt2 = writer_cls(spec_alt2, "default", False) writer_alt2 = writer_cls(spec_alt2, "default", False)

View File

@ -6,9 +6,9 @@
import pytest import pytest
import spack.concretize
import spack.config import spack.config
import spack.platforms import spack.platforms
import spack.spec
from spack.multimethod import NoSuchMethodError from spack.multimethod import NoSuchMethodError
pytestmark = [ pytestmark = [
@ -28,7 +28,7 @@ def pkg_name(request):
def test_no_version_match(pkg_name): def test_no_version_match(pkg_name):
spec = spack.spec.Spec(pkg_name + "@2.0").concretized() spec = spack.concretize.concretize_one(pkg_name + "@2.0")
with pytest.raises(NoSuchMethodError): with pytest.raises(NoSuchMethodError):
spec.package.no_version_2() spec.package.no_version_2()
@ -74,7 +74,7 @@ def test_multimethod_calls(
with spack.config.override( with spack.config.override(
"compilers", [compiler_factory(spec="apple-clang@9.1.0", operating_system="elcapitan")] "compilers", [compiler_factory(spec="apple-clang@9.1.0", operating_system="elcapitan")]
): ):
s = spack.spec.Spec(pkg_name + constraint_str).concretized() s = spack.concretize.concretize_one(pkg_name + constraint_str)
msg = f"Method {method_name} from {s} is giving a wrong result" msg = f"Method {method_name} from {s} is giving a wrong result"
assert getattr(s.package, method_name)() == expected_result, msg assert getattr(s.package, method_name)() == expected_result, msg
@ -83,10 +83,10 @@ def test_target_match(pkg_name):
platform = spack.platforms.host() platform = spack.platforms.host()
targets = list(platform.targets.values()) targets = list(platform.targets.values())
for target in targets[:-1]: for target in targets[:-1]:
s = spack.spec.Spec(pkg_name + " target=" + target.name).concretized() s = spack.concretize.concretize_one(pkg_name + " target=" + target.name)
assert s.package.different_by_target() == target.name assert s.package.different_by_target() == target.name
s = spack.spec.Spec(pkg_name + " target=" + targets[-1].name).concretized() s = spack.concretize.concretize_one(pkg_name + " target=" + targets[-1].name)
if len(targets) == 1: if len(targets) == 1:
assert s.package.different_by_target() == targets[-1].name assert s.package.different_by_target() == targets[-1].name
else: else:
@ -116,5 +116,5 @@ def test_target_match(pkg_name):
], ],
) )
def test_multimethod_calls_and_inheritance(spec_str, method_name, expected_result): def test_multimethod_calls_and_inheritance(spec_str, method_name, expected_result):
s = spack.spec.Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
assert getattr(s.package, method_name)() == expected_result assert getattr(s.package, method_name)() == expected_result

View File

@ -4,6 +4,7 @@
import pytest import pytest
import spack.concretize
from spack.spec import Spec from spack.spec import Spec
@ -72,14 +73,11 @@ def spec_and_expected(request):
def test_default_variant(config, mock_packages): def test_default_variant(config, mock_packages):
spec = Spec("optional-dep-test-3") spec = spack.concretize.concretize_one("optional-dep-test-3")
spec.concretize()
assert "pkg-a" in spec assert "pkg-a" in spec
spec = Spec("optional-dep-test-3~var") spec = spack.concretize.concretize_one("optional-dep-test-3~var")
spec.concretize()
assert "pkg-a" in spec assert "pkg-a" in spec
spec = Spec("optional-dep-test-3+var") spec = spack.concretize.concretize_one("optional-dep-test-3+var")
spec.concretize()
assert "pkg-b" in spec assert "pkg-b" in spec

View File

@ -17,6 +17,7 @@
import llnl.util.filesystem as fs import llnl.util.filesystem as fs
import spack.compilers import spack.compilers
import spack.concretize
import spack.deptypes as dt import spack.deptypes as dt
import spack.error import spack.error
import spack.install_test import spack.install_test
@ -166,8 +167,7 @@ def setup_install_test(source_paths, test_root):
) )
def test_cache_extra_sources(install_mockery, spec, sources, extras, expect): def test_cache_extra_sources(install_mockery, spec, sources, extras, expect):
"""Test the package's cache extra test sources helper function.""" """Test the package's cache extra test sources helper function."""
s = spack.spec.Spec(spec).concretized() s = spack.concretize.concretize_one(spec)
s.package.spec.concretize()
source_path = s.package.stage.source_path source_path = s.package.stage.source_path
srcs = [fs.join_path(source_path, src) for src in sources] srcs = [fs.join_path(source_path, src) for src in sources]
@ -205,8 +205,7 @@ def test_cache_extra_sources(install_mockery, spec, sources, extras, expect):
def test_cache_extra_sources_fails(install_mockery): def test_cache_extra_sources_fails(install_mockery):
s = spack.spec.Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
s.package.spec.concretize()
with pytest.raises(InstallError) as exc_info: with pytest.raises(InstallError) as exc_info:
spack.install_test.cache_extra_test_sources(s.package, ["/a/b", "no-such-file"]) spack.install_test.cache_extra_test_sources(s.package, ["/a/b", "no-such-file"])

View File

@ -7,6 +7,7 @@
import pytest import pytest
import spack.build_systems.cmake as cmake import spack.build_systems.cmake as cmake
import spack.concretize
import spack.directives import spack.directives
import spack.error import spack.error
import spack.fetch_strategy import spack.fetch_strategy
@ -75,13 +76,13 @@ def test_inheritance_of_directives(self):
assert len(pkg_cls.provided) == 2 assert len(pkg_cls.provided) == 2
# Check that Spec instantiation behaves as we expect # Check that Spec instantiation behaves as we expect
s = Spec("simple-inheritance").concretized() s = spack.concretize.concretize_one("simple-inheritance")
assert "^cmake" in s assert "^cmake" in s
assert "^openblas" in s assert "^openblas" in s
assert "+openblas" in s assert "+openblas" in s
assert "mpi" in s assert "mpi" in s
s = Spec("simple-inheritance~openblas").concretized() s = spack.concretize.concretize_one("simple-inheritance~openblas")
assert "^cmake" in s assert "^cmake" in s
assert "^openblas" not in s assert "^openblas" not in s
assert "~openblas" in s assert "~openblas" in s
@ -89,9 +90,8 @@ def test_inheritance_of_directives(self):
@pytest.mark.regression("11844") @pytest.mark.regression("11844")
def test_inheritance_of_patches(self): def test_inheritance_of_patches(self):
s = Spec("patch-inheritance")
# Will error if inheritor package cannot find inherited patch files # Will error if inheritor package cannot find inherited patch files
s.concretize() _ = spack.concretize.concretize_one("patch-inheritance")
def test_import_class_from_package(self): def test_import_class_from_package(self):
from spack.pkg.builtin.mock.mpich import Mpich # noqa: F401 from spack.pkg.builtin.mock.mpich import Mpich # noqa: F401
@ -115,7 +115,7 @@ def test_import_namespace_container_modules(self):
def test_urls_for_versions(mock_packages, config): def test_urls_for_versions(mock_packages, config):
"""Version directive without a 'url' argument should use default url.""" """Version directive without a 'url' argument should use default url."""
for spec_str in ("url_override@0.9.0", "url_override@1.0.0"): for spec_str in ("url_override@0.9.0", "url_override@1.0.0"):
s = Spec(spec_str).concretized() s = spack.concretize.concretize_one(spec_str)
url = s.package.url_for_version("0.9.0") url = s.package.url_for_version("0.9.0")
assert url == "http://www.anothersite.org/uo-0.9.0.tgz" assert url == "http://www.anothersite.org/uo-0.9.0.tgz"
@ -137,7 +137,7 @@ def test_url_for_version_with_no_urls(mock_packages, config):
def test_custom_cmake_prefix_path(mock_packages, config): def test_custom_cmake_prefix_path(mock_packages, config):
spec = Spec("depends-on-define-cmake-prefix-paths").concretized() spec = spack.concretize.concretize_one("depends-on-define-cmake-prefix-paths")
assert cmake.get_cmake_prefix_path(spec.package) == [ assert cmake.get_cmake_prefix_path(spec.package) == [
spec["define-cmake-prefix-paths"].prefix.test spec["define-cmake-prefix-paths"].prefix.test
@ -145,7 +145,7 @@ def test_custom_cmake_prefix_path(mock_packages, config):
def test_url_for_version_with_only_overrides(mock_packages, config): def test_url_for_version_with_only_overrides(mock_packages, config):
s = Spec("url-only-override").concretized() s = spack.concretize.concretize_one("url-only-override")
# these exist and should just take the URL provided in the package # these exist and should just take the URL provided in the package
assert s.package.url_for_version("1.0.0") == "http://a.example.com/url_override-1.0.0.tar.gz" assert s.package.url_for_version("1.0.0") == "http://a.example.com/url_override-1.0.0.tar.gz"
@ -160,7 +160,7 @@ def test_url_for_version_with_only_overrides(mock_packages, config):
def test_url_for_version_with_only_overrides_with_gaps(mock_packages, config): def test_url_for_version_with_only_overrides_with_gaps(mock_packages, config):
s = Spec("url-only-override-with-gaps").concretized() s = spack.concretize.concretize_one("url-only-override-with-gaps")
# same as for url-only-override -- these are specific # same as for url-only-override -- these are specific
assert s.package.url_for_version("1.0.0") == "http://a.example.com/url_override-1.0.0.tar.gz" assert s.package.url_for_version("1.0.0") == "http://a.example.com/url_override-1.0.0.tar.gz"

View File

@ -20,6 +20,7 @@
import spack.binary_distribution as bindist import spack.binary_distribution as bindist
import spack.cmd.buildcache as buildcache import spack.cmd.buildcache as buildcache
import spack.concretize
import spack.config import spack.config
import spack.error import spack.error
import spack.fetch_strategy import spack.fetch_strategy
@ -32,7 +33,6 @@
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.paths import mock_gpg_keys_path from spack.paths import mock_gpg_keys_path
from spack.relocate import macho_find_paths, relocate_links, relocate_text from spack.relocate import macho_find_paths, relocate_links, relocate_text
from spack.spec import Spec
pytestmark = pytest.mark.not_on_windows("does not run on windows") pytestmark = pytest.mark.not_on_windows("does not run on windows")
@ -40,7 +40,7 @@
@pytest.mark.usefixtures("install_mockery", "mock_gnupghome") @pytest.mark.usefixtures("install_mockery", "mock_gnupghome")
def test_buildcache(mock_archive, tmp_path, monkeypatch, mutable_config): def test_buildcache(mock_archive, tmp_path, monkeypatch, mutable_config):
# Install a test package # Install a test package
spec = Spec("trivial-install-test-package").concretized() spec = spack.concretize.concretize_one("trivial-install-test-package")
monkeypatch.setattr(spec.package, "fetcher", URLFetchStrategy(url=mock_archive.url)) monkeypatch.setattr(spec.package, "fetcher", URLFetchStrategy(url=mock_archive.url))
PackageInstaller([spec.package], explicit=True).install() PackageInstaller([spec.package], explicit=True).install()
pkghash = "/" + str(spec.dag_hash(7)) pkghash = "/" + str(spec.dag_hash(7))

View File

@ -12,6 +12,7 @@
from llnl.util.filesystem import mkdirp, touch, working_dir from llnl.util.filesystem import mkdirp, touch, working_dir
import spack.concretize
import spack.error import spack.error
import spack.fetch_strategy import spack.fetch_strategy
import spack.patch import spack.patch
@ -91,7 +92,7 @@ def mock_patch_stage(tmpdir_factory, monkeypatch):
def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256, config): def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256, config):
# Make a patch object # Make a patch object
url = url_util.path_to_file_url(filename) url = url_util.path_to_file_url(filename)
s = Spec("patch").concretized() s = spack.concretize.concretize_one("patch")
# make a stage # make a stage
with Stage(url) as stage: # TODO: url isn't used; maybe refactor Stage with Stage(url) as stage: # TODO: url isn't used; maybe refactor Stage
@ -145,8 +146,7 @@ def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256, config):
def test_patch_in_spec(mock_packages, config): def test_patch_in_spec(mock_packages, config):
"""Test whether patches in a package appear in the spec.""" """Test whether patches in a package appear in the spec."""
spec = Spec("patch") spec = spack.concretize.concretize_one("patch")
spec.concretize()
assert "patches" in list(spec.variants.keys()) assert "patches" in list(spec.variants.keys())
# Here the order is bar, foo, baz. Note that MV variants order # Here the order is bar, foo, baz. Note that MV variants order
@ -164,18 +164,15 @@ def test_patch_mixed_versions_subset_constraint(mock_packages, config):
a patch applied to a version range of x.y.z versions is not applied to a patch applied to a version range of x.y.z versions is not applied to
an x.y version. an x.y version.
""" """
spec1 = Spec("patch@1.0.1") spec1 = spack.concretize.concretize_one("patch@1.0.1")
spec1.concretize()
assert biz_sha256 in spec1.variants["patches"].value assert biz_sha256 in spec1.variants["patches"].value
spec2 = Spec("patch@=1.0") spec2 = spack.concretize.concretize_one("patch@=1.0")
spec2.concretize()
assert biz_sha256 not in spec2.variants["patches"].value assert biz_sha256 not in spec2.variants["patches"].value
def test_patch_order(mock_packages, config): def test_patch_order(mock_packages, config):
spec = Spec("dep-diamond-patch-top") spec = spack.concretize.concretize_one("dep-diamond-patch-top")
spec.concretize()
mid2_sha256 = ( mid2_sha256 = (
"mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" "mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
@ -233,8 +230,7 @@ def test_nested_directives(mock_packages):
@pytest.mark.not_on_windows("Test requires Autotools") @pytest.mark.not_on_windows("Test requires Autotools")
def test_patched_dependency(mock_packages, install_mockery, mock_fetch): def test_patched_dependency(mock_packages, install_mockery, mock_fetch):
"""Test whether patched dependencies work.""" """Test whether patched dependencies work."""
spec = Spec("patch-a-dependency") spec = spack.concretize.concretize_one("patch-a-dependency")
spec.concretize()
assert "patches" in list(spec["libelf"].variants.keys()) assert "patches" in list(spec["libelf"].variants.keys())
# make sure the patch makes it into the dependency spec # make sure the patch makes it into the dependency spec
@ -274,8 +270,7 @@ def test_patch_failure_develop_spec_exits_gracefully(
): ):
"""ensure that a failing patch does not trigger exceptions for develop specs""" """ensure that a failing patch does not trigger exceptions for develop specs"""
spec = Spec(f"patch-a-dependency ^libelf dev_path={tmpdir}") spec = spack.concretize.concretize_one(f"patch-a-dependency ^libelf dev_path={tmpdir}")
spec.concretize()
libelf = spec["libelf"] libelf = spec["libelf"]
assert "patches" in list(libelf.variants.keys()) assert "patches" in list(libelf.variants.keys())
pkg = libelf.package pkg = libelf.package
@ -291,8 +286,7 @@ def test_patch_failure_restages(mock_packages, install_mockery, mock_fetch):
ensure that a failing patch does not trigger exceptions ensure that a failing patch does not trigger exceptions
for non-develop specs and the source gets restaged for non-develop specs and the source gets restaged
""" """
spec = Spec("patch-a-dependency") spec = spack.concretize.concretize_one("patch-a-dependency")
spec.concretize()
pkg = spec["libelf"].package pkg = spec["libelf"].package
with pkg.stage: with pkg.stage:
bad_patch_indicator = trigger_bad_patch(pkg) bad_patch_indicator = trigger_bad_patch(pkg)
@ -303,8 +297,7 @@ def test_patch_failure_restages(mock_packages, install_mockery, mock_fetch):
def test_multiple_patched_dependencies(mock_packages, config): def test_multiple_patched_dependencies(mock_packages, config):
"""Test whether multiple patched dependencies work.""" """Test whether multiple patched dependencies work."""
spec = Spec("patch-several-dependencies") spec = spack.concretize.concretize_one("patch-several-dependencies")
spec.concretize()
# basic patch on libelf # basic patch on libelf
assert "patches" in list(spec["libelf"].variants.keys()) assert "patches" in list(spec["libelf"].variants.keys())
@ -319,8 +312,7 @@ def test_multiple_patched_dependencies(mock_packages, config):
def test_conditional_patched_dependencies(mock_packages, config): def test_conditional_patched_dependencies(mock_packages, config):
"""Test whether conditional patched dependencies work.""" """Test whether conditional patched dependencies work."""
spec = Spec("patch-several-dependencies @1.0") spec = spack.concretize.concretize_one("patch-several-dependencies @1.0")
spec.concretize()
# basic patch on libelf # basic patch on libelf
assert "patches" in list(spec["libelf"].variants.keys()) assert "patches" in list(spec["libelf"].variants.keys())
@ -396,8 +388,9 @@ def get_patch(spec, ending):
def test_conditional_patched_deps_with_conditions(mock_packages, config): def test_conditional_patched_deps_with_conditions(mock_packages, config):
"""Test whether conditional patched dependencies with conditions work.""" """Test whether conditional patched dependencies with conditions work."""
spec = Spec("patch-several-dependencies @1.0 ^libdwarf@20111030") spec = spack.concretize.concretize_one(
spec.concretize() Spec("patch-several-dependencies @1.0 ^libdwarf@20111030")
)
libelf = spec["libelf"] libelf = spec["libelf"]
libdwarf = spec["libdwarf"] libdwarf = spec["libdwarf"]
@ -412,8 +405,9 @@ def test_write_and_read_sub_dags_with_patched_deps(mock_packages, config):
"""Test whether patched dependencies are still correct after writing and """Test whether patched dependencies are still correct after writing and
reading a sub-DAG of a concretized Spec. reading a sub-DAG of a concretized Spec.
""" """
spec = Spec("patch-several-dependencies @1.0 ^libdwarf@20111030") spec = spack.concretize.concretize_one(
spec.concretize() Spec("patch-several-dependencies @1.0 ^libdwarf@20111030")
)
# write to YAML and read back in -- new specs will *only* contain # write to YAML and read back in -- new specs will *only* contain
# their sub-DAGs, and won't contain the dependent that patched them # their sub-DAGs, and won't contain the dependent that patched them
@ -474,7 +468,7 @@ def test_equality():
def test_sha256_setter(mock_patch_stage, config): def test_sha256_setter(mock_patch_stage, config):
path = os.path.join(data_path, "foo.patch") path = os.path.join(data_path, "foo.patch")
s = Spec("patch").concretized() s = spack.concretize.concretize_one("patch")
patch = spack.patch.FilePatch(s.package, path, level=1, working_dir=".") patch = spack.patch.FilePatch(s.package, path, level=1, working_dir=".")
patch.sha256 = "abc" patch.sha256 = "abc"

View File

@ -8,11 +8,11 @@
import pytest import pytest
import spack.concretize
import spack.deptypes as dt import spack.deptypes as dt
import spack.rewiring import spack.rewiring
import spack.store import spack.store
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.spec import Spec
from spack.test.relocate import text_in_bin from spack.test.relocate import text_in_bin
if sys.platform == "darwin": if sys.platform == "darwin":
@ -37,8 +37,8 @@ def check_spliced_spec_prefixes(spliced_spec):
@pytest.mark.parametrize("transitive", [True, False]) @pytest.mark.parametrize("transitive", [True, False])
def test_rewire_db(mock_fetch, install_mockery, transitive): def test_rewire_db(mock_fetch, install_mockery, transitive):
"""Tests basic rewiring without binary executables.""" """Tests basic rewiring without binary executables."""
spec = Spec("splice-t^splice-h~foo").concretized() spec = spack.concretize.concretize_one("splice-t^splice-h~foo")
dep = Spec("splice-h+foo").concretized() dep = spack.concretize.concretize_one("splice-h+foo")
PackageInstaller([spec.package, dep.package], explicit=True).install() PackageInstaller([spec.package, dep.package], explicit=True).install()
spliced_spec = spec.splice(dep, transitive=transitive) spliced_spec = spec.splice(dep, transitive=transitive)
assert spec.dag_hash() != spliced_spec.dag_hash() assert spec.dag_hash() != spliced_spec.dag_hash()
@ -61,8 +61,8 @@ def test_rewire_db(mock_fetch, install_mockery, transitive):
@pytest.mark.parametrize("transitive", [True, False]) @pytest.mark.parametrize("transitive", [True, False])
def test_rewire_bin(mock_fetch, install_mockery, transitive): def test_rewire_bin(mock_fetch, install_mockery, transitive):
"""Tests basic rewiring with binary executables.""" """Tests basic rewiring with binary executables."""
spec = Spec("quux").concretized() spec = spack.concretize.concretize_one("quux")
dep = Spec("garply cflags=-g").concretized() dep = spack.concretize.concretize_one("garply cflags=-g")
PackageInstaller([spec.package, dep.package], explicit=True).install() PackageInstaller([spec.package, dep.package], explicit=True).install()
spliced_spec = spec.splice(dep, transitive=transitive) spliced_spec = spec.splice(dep, transitive=transitive)
@ -90,8 +90,8 @@ def test_rewire_bin(mock_fetch, install_mockery, transitive):
def test_rewire_writes_new_metadata(mock_fetch, install_mockery): def test_rewire_writes_new_metadata(mock_fetch, install_mockery):
"""Tests that new metadata was written during a rewire. """Tests that new metadata was written during a rewire.
Accuracy of metadata is left to other tests.""" Accuracy of metadata is left to other tests."""
spec = Spec("quux").concretized() spec = spack.concretize.concretize_one("quux")
dep = Spec("garply cflags=-g").concretized() dep = spack.concretize.concretize_one("garply cflags=-g")
PackageInstaller([spec.package, dep.package], explicit=True).install() PackageInstaller([spec.package, dep.package], explicit=True).install()
spliced_spec = spec.splice(dep, transitive=True) spliced_spec = spec.splice(dep, transitive=True)
spack.rewiring.rewire(spliced_spec) spack.rewiring.rewire(spliced_spec)
@ -134,8 +134,8 @@ def test_rewire_writes_new_metadata(mock_fetch, install_mockery):
@pytest.mark.parametrize("transitive", [True, False]) @pytest.mark.parametrize("transitive", [True, False])
def test_uninstall_rewired_spec(mock_fetch, install_mockery, transitive): def test_uninstall_rewired_spec(mock_fetch, install_mockery, transitive):
"""Test that rewired packages can be uninstalled as normal.""" """Test that rewired packages can be uninstalled as normal."""
spec = Spec("quux").concretized() spec = spack.concretize.concretize_one("quux")
dep = Spec("garply cflags=-g").concretized() dep = spack.concretize.concretize_one("garply cflags=-g")
PackageInstaller([spec.package, dep.package], explicit=True).install() PackageInstaller([spec.package, dep.package], explicit=True).install()
spliced_spec = spec.splice(dep, transitive=transitive) spliced_spec = spec.splice(dep, transitive=transitive)
spack.rewiring.rewire(spliced_spec) spack.rewiring.rewire(spliced_spec)
@ -148,8 +148,8 @@ def test_uninstall_rewired_spec(mock_fetch, install_mockery, transitive):
def test_rewire_not_installed_fails(mock_fetch, install_mockery): def test_rewire_not_installed_fails(mock_fetch, install_mockery):
"""Tests error when an attempt is made to rewire a package that was not """Tests error when an attempt is made to rewire a package that was not
previously installed.""" previously installed."""
spec = Spec("quux").concretized() spec = spack.concretize.concretize_one("quux")
dep = Spec("garply cflags=-g").concretized() dep = spack.concretize.concretize_one("garply cflags=-g")
spliced_spec = spec.splice(dep, False) spliced_spec = spec.splice(dep, False)
with pytest.raises( with pytest.raises(
spack.rewiring.PackageNotInstalledError, spack.rewiring.PackageNotInstalledError,
@ -163,8 +163,8 @@ def test_rewire_virtual(mock_fetch, install_mockery):
dep = "splice-a" dep = "splice-a"
alt_dep = "splice-h" alt_dep = "splice-h"
spec = Spec(f"splice-vt^{dep}").concretized() spec = spack.concretize.concretize_one(f"splice-vt^{dep}")
alt_spec = Spec(alt_dep).concretized() alt_spec = spack.concretize.concretize_one(alt_dep)
PackageInstaller([spec.package, alt_spec.package]).install() PackageInstaller([spec.package, alt_spec.package]).install()

View File

@ -6,6 +6,7 @@
""" """
import pytest import pytest
import spack.concretize
import spack.deptypes as dt import spack.deptypes as dt
import spack.error import spack.error
import spack.repo import spack.repo
@ -74,7 +75,7 @@ def test_test_deptype(tmpdir):
builder.add_package("w", dependencies=[("x", "test", None), ("y", None, None)]) builder.add_package("w", dependencies=[("x", "test", None), ("y", None, None)])
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
spec = Spec("w").concretized(tests=("w",)) spec = spack.concretize.concretize_one("w", tests=("w",))
assert "x" in spec assert "x" in spec
assert "z" not in spec assert "z" not in spec
@ -106,8 +107,7 @@ def test_installed_deps(monkeypatch, mock_packages):
# BUT d is only a build dependency of C, so it won't constrain # BUT d is only a build dependency of C, so it won't constrain
# link/run dependents of C when C is depended on as an existing # link/run dependents of C when C is depended on as an existing
# (concrete) installation. # (concrete) installation.
c_spec = Spec(c) c_spec = spack.concretize.concretize_one(c)
c_spec.concretize()
assert c_spec[d].version == spack.version.Version("2") assert c_spec[d].version == spack.version.Version("2")
installed_names = [s.name for s in c_spec.traverse()] installed_names = [s.name for s in c_spec.traverse()]
@ -122,7 +122,7 @@ def _mock_installed(self):
# *if* we're doing a fresh installation. # *if* we're doing a fresh installation.
a_spec = Spec(a) a_spec = Spec(a)
a_spec._add_dependency(c_spec, depflag=dt.BUILD | dt.LINK, virtuals=()) a_spec._add_dependency(c_spec, depflag=dt.BUILD | dt.LINK, virtuals=())
a_spec.concretize() a_spec = spack.concretize.concretize_one(a_spec)
assert spack.version.Version("2") == a_spec[c][d].version assert spack.version.Version("2") == a_spec[c][d].version
assert spack.version.Version("2") == a_spec[e].version assert spack.version.Version("2") == a_spec[e].version
assert spack.version.Version("3") == a_spec[b][d].version assert spack.version.Version("3") == a_spec[b][d].version
@ -140,12 +140,12 @@ def test_specify_preinstalled_dep(tmpdir, monkeypatch):
builder.add_package("pkg-a", dependencies=[("pkg-b", None, None)]) builder.add_package("pkg-a", dependencies=[("pkg-b", None, None)])
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
b_spec = Spec("pkg-b").concretized() b_spec = spack.concretize.concretize_one("pkg-b")
monkeypatch.setattr(Spec, "installed", property(lambda x: x.name != "pkg-a")) monkeypatch.setattr(Spec, "installed", property(lambda x: x.name != "pkg-a"))
a_spec = Spec("pkg-a") a_spec = Spec("pkg-a")
a_spec._add_dependency(b_spec, depflag=dt.BUILD | dt.LINK, virtuals=()) a_spec._add_dependency(b_spec, depflag=dt.BUILD | dt.LINK, virtuals=())
a_spec.concretize() a_spec = spack.concretize.concretize_one(a_spec)
assert {x.name for x in a_spec.traverse()} == {"pkg-a", "pkg-b", "pkg-c"} assert {x.name for x in a_spec.traverse()} == {"pkg-a", "pkg-b", "pkg-c"}
@ -167,7 +167,7 @@ def test_conditional_dep_with_user_constraints(tmpdir, spec_str, expr_str, expec
builder.add_package("x", dependencies=[("y", None, "x@2:")]) builder.add_package("x", dependencies=[("y", None, "x@2:")])
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
spec = Spec(spec_str).concretized() spec = spack.concretize.concretize_one(spec_str)
result = expr_str in spec result = expr_str in spec
assert result is expected, "{0} in {1}".format(expr_str, spec) assert result is expected, "{0} in {1}".format(expr_str, spec)
@ -181,10 +181,10 @@ def test_conflicting_package_constraints(self, set_dependency):
spec = Spec("mpileaks ^mpich ^callpath ^dyninst ^libelf ^libdwarf") spec = Spec("mpileaks ^mpich ^callpath ^dyninst ^libelf ^libdwarf")
with pytest.raises(spack.error.UnsatisfiableSpecError): with pytest.raises(spack.error.UnsatisfiableSpecError):
spec.concretize() spack.concretize.concretize_one(spec)
def test_preorder_node_traversal(self): def test_preorder_node_traversal(self):
dag = Spec("mpileaks ^zmpi").concretized() dag = spack.concretize.concretize_one("mpileaks ^zmpi")
names = ["mpileaks", "callpath", "dyninst", "libdwarf", "libelf", "zmpi", "fake"] names = ["mpileaks", "callpath", "dyninst", "libdwarf", "libelf", "zmpi", "fake"]
pairs = list(zip([0, 1, 2, 3, 4, 2, 3], names)) pairs = list(zip([0, 1, 2, 3, 4, 2, 3], names))
@ -196,7 +196,7 @@ def test_preorder_node_traversal(self):
assert [(x, y.name) for x, y in traversal] == pairs assert [(x, y.name) for x, y in traversal] == pairs
def test_preorder_edge_traversal(self): def test_preorder_edge_traversal(self):
dag = Spec("mpileaks ^zmpi").concretized() dag = spack.concretize.concretize_one("mpileaks ^zmpi")
names = [ names = [
"mpileaks", "mpileaks",
@ -218,7 +218,7 @@ def test_preorder_edge_traversal(self):
assert [(x, y.name) for x, y in traversal] == pairs assert [(x, y.name) for x, y in traversal] == pairs
def test_preorder_path_traversal(self): def test_preorder_path_traversal(self):
dag = Spec("mpileaks ^zmpi").concretized() dag = spack.concretize.concretize_one("mpileaks ^zmpi")
names = [ names = [
"mpileaks", "mpileaks",
@ -241,7 +241,7 @@ def test_preorder_path_traversal(self):
assert [(x, y.name) for x, y in traversal] == pairs assert [(x, y.name) for x, y in traversal] == pairs
def test_postorder_node_traversal(self): def test_postorder_node_traversal(self):
dag = Spec("mpileaks ^zmpi").concretized() dag = spack.concretize.concretize_one("mpileaks ^zmpi")
names = ["libelf", "libdwarf", "dyninst", "fake", "zmpi", "callpath", "mpileaks"] names = ["libelf", "libdwarf", "dyninst", "fake", "zmpi", "callpath", "mpileaks"]
pairs = list(zip([4, 3, 2, 3, 2, 1, 0], names)) pairs = list(zip([4, 3, 2, 3, 2, 1, 0], names))
@ -253,7 +253,7 @@ def test_postorder_node_traversal(self):
assert [(x, y.name) for x, y in traversal] == pairs assert [(x, y.name) for x, y in traversal] == pairs
def test_postorder_edge_traversal(self): def test_postorder_edge_traversal(self):
dag = Spec("mpileaks ^zmpi").concretized() dag = spack.concretize.concretize_one("mpileaks ^zmpi")
names = [ names = [
"libelf", "libelf",
@ -275,7 +275,7 @@ def test_postorder_edge_traversal(self):
assert [(x, y.name) for x, y in traversal] == pairs assert [(x, y.name) for x, y in traversal] == pairs
def test_postorder_path_traversal(self): def test_postorder_path_traversal(self):
dag = Spec("mpileaks ^zmpi").concretized() dag = spack.concretize.concretize_one("mpileaks ^zmpi")
names = [ names = [
"libelf", "libelf",
@ -310,8 +310,8 @@ def test_dependents_and_dependencies_are_correct(self):
} }
) )
check_links(spec) check_links(spec)
spec.concretize() concrete = spack.concretize.concretize_one(spec)
check_links(spec) check_links(concrete)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"constraint_str,spec_str", "constraint_str,spec_str",
@ -328,7 +328,7 @@ def test_unsatisfiable_cases(self, set_dependency, constraint_str, spec_str):
""" """
set_dependency("mpileaks", constraint_str) set_dependency("mpileaks", constraint_str)
with pytest.raises(spack.error.UnsatisfiableSpecError): with pytest.raises(spack.error.UnsatisfiableSpecError):
Spec(spec_str).concretize() spack.concretize.concretize_one(spec_str)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"spec_str", ["libelf ^mpich", "libelf ^libdwarf", "mpich ^dyninst ^libelf"] "spec_str", ["libelf ^mpich", "libelf ^libdwarf", "mpich ^dyninst ^libelf"]
@ -336,7 +336,7 @@ def test_unsatisfiable_cases(self, set_dependency, constraint_str, spec_str):
def test_invalid_dep(self, spec_str): def test_invalid_dep(self, spec_str):
spec = Spec(spec_str) spec = Spec(spec_str)
with pytest.raises(spack.error.SpecError): with pytest.raises(spack.error.SpecError):
spec.concretize() spack.concretize.concretize_one(spec)
def test_equal(self): def test_equal(self):
# Different spec structures to test for equality # Different spec structures to test for equality
@ -398,8 +398,7 @@ def test_copy_simple(self):
assert not orig_ids.intersection(copy_ids) assert not orig_ids.intersection(copy_ids)
def test_copy_concretized(self): def test_copy_concretized(self):
orig = Spec("mpileaks") orig = spack.concretize.concretize_one("mpileaks")
orig.concretize()
copy = orig.copy() copy = orig.copy()
check_links(copy) check_links(copy)
@ -417,7 +416,7 @@ def test_copy_through_spec_build_interface(self):
"""Check that copying dependencies using id(node) as a fast identifier of the """Check that copying dependencies using id(node) as a fast identifier of the
node works when the spec is wrapped in a SpecBuildInterface object. node works when the spec is wrapped in a SpecBuildInterface object.
""" """
s = Spec("mpileaks").concretized() s = spack.concretize.concretize_one("mpileaks")
c0 = s.copy() c0 = s.copy()
assert c0 == s assert c0 == s
@ -500,7 +499,7 @@ def test_copy_through_spec_build_interface(self):
], ],
) )
def test_deptype_traversal(self, spec_str, deptypes, expected): def test_deptype_traversal(self, spec_str, deptypes, expected):
dag = Spec(spec_str).concretized() dag = spack.concretize.concretize_one(spec_str)
traversal = dag.traverse(deptype=deptypes) traversal = dag.traverse(deptype=deptypes)
assert [x.name for x in traversal] == expected assert [x.name for x in traversal] == expected
@ -620,20 +619,18 @@ def check_diamond_deptypes(self, spec):
def test_concretize_deptypes(self): def test_concretize_deptypes(self):
"""Ensure that dependency types are preserved after concretization.""" """Ensure that dependency types are preserved after concretization."""
s = Spec("dt-diamond") s = spack.concretize.concretize_one("dt-diamond")
s.concretize()
self.check_diamond_deptypes(s) self.check_diamond_deptypes(s)
def test_copy_deptypes(self): def test_copy_deptypes(self):
"""Ensure that dependency types are preserved by spec copy.""" """Ensure that dependency types are preserved by spec copy."""
s1 = Spec("dt-diamond").concretized() s1 = spack.concretize.concretize_one("dt-diamond")
self.check_diamond_deptypes(s1) self.check_diamond_deptypes(s1)
s2 = s1.copy() s2 = s1.copy()
self.check_diamond_deptypes(s2) self.check_diamond_deptypes(s2)
def test_getitem_query(self): def test_getitem_query(self):
s = Spec("mpileaks") s = spack.concretize.concretize_one("mpileaks")
s.concretize()
# Check a query to a non-virtual package # Check a query to a non-virtual package
a = s["callpath"] a = s["callpath"]
@ -663,8 +660,7 @@ def test_getitem_query(self):
assert query.isvirtual assert query.isvirtual
def test_getitem_exceptional_paths(self): def test_getitem_exceptional_paths(self):
s = Spec("mpileaks") s = spack.concretize.concretize_one("mpileaks")
s.concretize()
# Needed to get a proxy object # Needed to get a proxy object
q = s["mpileaks"] q = s["mpileaks"]
@ -735,7 +731,7 @@ def test_invalid_literal_spec(self):
def test_spec_tree_respect_deptypes(self): def test_spec_tree_respect_deptypes(self):
# Version-test-root uses version-test-pkg as a build dependency # Version-test-root uses version-test-pkg as a build dependency
s = Spec("version-test-root").concretized() s = spack.concretize.concretize_one("version-test-root")
out = s.tree(deptypes="all") out = s.tree(deptypes="all")
assert "version-test-pkg" in out assert "version-test-pkg" in out
out = s.tree(deptypes=("link", "run")) out = s.tree(deptypes=("link", "run"))
@ -819,9 +815,9 @@ def test_synthetic_construction_of_split_dependencies_from_same_package(mock_pac
# #
# To demonstrate that a spec can now hold two direct # To demonstrate that a spec can now hold two direct
# dependencies from the same package # dependencies from the same package
root = Spec("pkg-b").concretized() root = spack.concretize.concretize_one("pkg-b")
link_run_spec = Spec("pkg-c@=1.0").concretized() link_run_spec = spack.concretize.concretize_one("pkg-c@=1.0")
build_spec = Spec("pkg-c@=2.0").concretized() build_spec = spack.concretize.concretize_one("pkg-c@=2.0")
root.add_dependency_edge(link_run_spec, depflag=dt.LINK, virtuals=()) root.add_dependency_edge(link_run_spec, depflag=dt.LINK, virtuals=())
root.add_dependency_edge(link_run_spec, depflag=dt.RUN, virtuals=()) root.add_dependency_edge(link_run_spec, depflag=dt.RUN, virtuals=())
@ -848,8 +844,8 @@ def test_synthetic_construction_bootstrapping(mock_packages, config):
# | build # | build
# pkg-b@1.0 # pkg-b@1.0
# #
root = Spec("pkg-b@=2.0").concretized() root = spack.concretize.concretize_one("pkg-b@=2.0")
bootstrap = Spec("pkg-b@=1.0").concretized() bootstrap = spack.concretize.concretize_one("pkg-b@=1.0")
root.add_dependency_edge(bootstrap, depflag=dt.BUILD, virtuals=()) root.add_dependency_edge(bootstrap, depflag=dt.BUILD, virtuals=())
@ -866,8 +862,8 @@ def test_addition_of_different_deptypes_in_multiple_calls(mock_packages, config)
# pkg-b@1.0 # pkg-b@1.0
# #
# with three calls and check we always have a single edge # with three calls and check we always have a single edge
root = Spec("pkg-b@=2.0").concretized() root = spack.concretize.concretize_one("pkg-b@=2.0")
bootstrap = Spec("pkg-b@=1.0").concretized() bootstrap = spack.concretize.concretize_one("pkg-b@=1.0")
for current_depflag in (dt.BUILD, dt.LINK, dt.RUN): for current_depflag in (dt.BUILD, dt.LINK, dt.RUN):
root.add_dependency_edge(bootstrap, depflag=current_depflag, virtuals=()) root.add_dependency_edge(bootstrap, depflag=current_depflag, virtuals=())
@ -894,9 +890,9 @@ def test_addition_of_different_deptypes_in_multiple_calls(mock_packages, config)
def test_adding_same_deptype_with_the_same_name_raises( def test_adding_same_deptype_with_the_same_name_raises(
mock_packages, config, c1_depflag, c2_depflag mock_packages, config, c1_depflag, c2_depflag
): ):
p = Spec("pkg-b@=2.0").concretized() p = spack.concretize.concretize_one("pkg-b@=2.0")
c1 = Spec("pkg-b@=1.0").concretized() c1 = spack.concretize.concretize_one("pkg-b@=1.0")
c2 = Spec("pkg-b@=2.0").concretized() c2 = spack.concretize.concretize_one("pkg-b@=2.0")
p.add_dependency_edge(c1, depflag=c1_depflag, virtuals=()) p.add_dependency_edge(c1, depflag=c1_depflag, virtuals=())
with pytest.raises(spack.error.SpackError): with pytest.raises(spack.error.SpackError):

View File

@ -5,6 +5,7 @@
import pytest import pytest
import spack.concretize
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
from spack.spec import Spec from spack.spec import Spec
from spack.spec_list import SpecList from spack.spec_list import SpecList
@ -198,8 +199,8 @@ def test_spec_list_matrix_exclude(self, mock_packages):
def test_spec_list_exclude_with_abstract_hashes(self, mock_packages, install_mockery): def test_spec_list_exclude_with_abstract_hashes(self, mock_packages, install_mockery):
# Put mpich in the database so it can be referred to by hash. # Put mpich in the database so it can be referred to by hash.
mpich_1 = Spec("mpich+debug").concretized() mpich_1 = spack.concretize.concretize_one("mpich+debug")
mpich_2 = Spec("mpich~debug").concretized() mpich_2 = spack.concretize.concretize_one("mpich~debug")
PackageInstaller([mpich_1.package, mpich_2.package], explicit=True, fake=True).install() PackageInstaller([mpich_1.package, mpich_2.package], explicit=True, fake=True).install()
# Create matrix and exclude +debug, which excludes the first mpich after its abstract hash # Create matrix and exclude +debug, which excludes the first mpich after its abstract hash

View File

@ -6,6 +6,7 @@
import pytest import pytest
import spack.concretize
import spack.deptypes as dt import spack.deptypes as dt
import spack.directives import spack.directives
import spack.error import spack.error
@ -589,8 +590,7 @@ def test_satisfies_single_valued_variant(self):
https://github.com/spack/spack/pull/2386#issuecomment-282147639 https://github.com/spack/spack/pull/2386#issuecomment-282147639
is handled correctly. is handled correctly.
""" """
a = Spec("pkg-a foobar=bar") a = spack.concretize.concretize_one("pkg-a foobar=bar")
a.concretize()
assert a.satisfies("foobar=bar") assert a.satisfies("foobar=bar")
assert a.satisfies("foobar=*") assert a.satisfies("foobar=*")
@ -609,21 +609,18 @@ def test_satisfies_single_valued_variant(self):
assert "^pkg-b" in a assert "^pkg-b" in a
def test_unsatisfied_single_valued_variant(self): def test_unsatisfied_single_valued_variant(self):
a = Spec("pkg-a foobar=baz") a = spack.concretize.concretize_one("pkg-a foobar=baz")
a.concretize()
assert "^pkg-b" not in a assert "^pkg-b" not in a
mv = Spec("multivalue-variant") mv = spack.concretize.concretize_one("multivalue-variant")
mv.concretize()
assert "pkg-a@1.0" not in mv assert "pkg-a@1.0" not in mv
def test_indirect_unsatisfied_single_valued_variant(self): def test_indirect_unsatisfied_single_valued_variant(self):
spec = Spec("singlevalue-variant-dependent") spec = spack.concretize.concretize_one("singlevalue-variant-dependent")
spec.concretize()
assert "pkg-a@1.0" not in spec assert "pkg-a@1.0" not in spec
def test_satisfied_namespace(self): def test_satisfied_namespace(self):
spec = Spec("zlib").concretized() spec = spack.concretize.concretize_one("zlib")
assert spec.satisfies("namespace=builtin.mock") assert spec.satisfies("namespace=builtin.mock")
assert not spec.satisfies("namespace=builtin") assert not spec.satisfies("namespace=builtin")
@ -683,7 +680,7 @@ def test_unsatisfiable_multi_value_variant(self, default_mock_concretization):
# ...but will fail during concretization if there are # ...but will fail during concretization if there are
# values in the variant that are not allowed # values in the variant that are not allowed
with pytest.raises(InvalidVariantValueError): with pytest.raises(InvalidVariantValueError):
a.concretize() spack.concretize.concretize_one(a)
# This time we'll try to set a single-valued variant # This time we'll try to set a single-valued variant
a = Spec('multivalue-variant fee="bar"') a = Spec('multivalue-variant fee="bar"')
@ -700,11 +697,10 @@ def test_unsatisfiable_multi_value_variant(self, default_mock_concretization):
# ...but will fail during concretization if there are # ...but will fail during concretization if there are
# multiple values set # multiple values set
with pytest.raises(MultipleValuesInExclusiveVariantError): with pytest.raises(MultipleValuesInExclusiveVariantError):
a.concretize() spack.concretize.concretize_one(a)
def test_copy_satisfies_transitive(self): def test_copy_satisfies_transitive(self):
spec = Spec("dttop") spec = spack.concretize.concretize_one("dttop")
spec.concretize()
copy = spec.copy() copy = spec.copy()
for s in spec.traverse(): for s in spec.traverse():
assert s.satisfies(copy[s.name]) assert s.satisfies(copy[s.name])
@ -727,7 +723,7 @@ def test_intersects_virtual_providers(self):
def test_intersectable_concrete_specs_must_have_the_same_hash(self): def test_intersectable_concrete_specs_must_have_the_same_hash(self):
"""Ensure that concrete specs are matched *exactly* by hash.""" """Ensure that concrete specs are matched *exactly* by hash."""
s1 = Spec("mpileaks").concretized() s1 = spack.concretize.concretize_one("mpileaks")
s2 = s1.copy() s2 = s1.copy()
assert s1.satisfies(s2) assert s1.satisfies(s2)
@ -767,17 +763,10 @@ def test_dep_index(self, default_mock_concretization):
@pytest.mark.usefixtures("config") @pytest.mark.usefixtures("config")
def test_virtual_index(self): def test_virtual_index(self):
s = Spec("callpath") s = spack.concretize.concretize_one("callpath")
s.concretize() s_mpich = spack.concretize.concretize_one("callpath ^mpich")
s_mpich2 = spack.concretize.concretize_one("callpath ^mpich2")
s_mpich = Spec("callpath ^mpich") s_zmpi = spack.concretize.concretize_one("callpath ^zmpi")
s_mpich.concretize()
s_mpich2 = Spec("callpath ^mpich2")
s_mpich2.concretize()
s_zmpi = Spec("callpath ^zmpi")
s_zmpi.concretize()
assert s["mpi"].name != "mpi" assert s["mpi"].name != "mpi"
assert s_mpich["mpi"].name == "mpich" assert s_mpich["mpi"].name == "mpich"
@ -1047,7 +1036,7 @@ def test_abstract_spec_prefix_error(self):
spec.prefix spec.prefix
def test_forwarding_of_architecture_attributes(self): def test_forwarding_of_architecture_attributes(self):
spec = Spec("libelf target=x86_64").concretized() spec = spack.concretize.concretize_one("libelf target=x86_64")
# Check that we can still access each member through # Check that we can still access each member through
# the architecture attribute # the architecture attribute
@ -1372,7 +1361,7 @@ def test_target_constraints(self, spec, constraint, expected_result):
def test_error_message_unknown_variant(self): def test_error_message_unknown_variant(self):
s = Spec("mpileaks +unknown") s = Spec("mpileaks +unknown")
with pytest.raises(UnknownVariantError): with pytest.raises(UnknownVariantError):
s.concretize() spack.concretize.concretize_one(s)
@pytest.mark.regression("18527") @pytest.mark.regression("18527")
def test_satisfies_dependencies_ordered(self): def test_satisfies_dependencies_ordered(self):
@ -1399,8 +1388,7 @@ def test_splice_swap_names_mismatch_virtuals(self, default_mock_concretization,
def test_spec_override(self): def test_spec_override(self):
init_spec = Spec("pkg-a foo=baz foobar=baz cflags=-O3 cxxflags=-O1") init_spec = Spec("pkg-a foo=baz foobar=baz cflags=-O3 cxxflags=-O1")
change_spec = Spec("pkg-a foo=fee cflags=-O2") change_spec = Spec("pkg-a foo=fee cflags=-O2")
new_spec = Spec.override(init_spec, change_spec) new_spec = spack.concretize.concretize_one(Spec.override(init_spec, change_spec))
new_spec.concretize()
assert "foo=fee" in new_spec assert "foo=fee" in new_spec
# This check fails without concretizing: apparently if both specs are # This check fails without concretizing: apparently if both specs are
# abstract, then the spec will always be considered to satisfy # abstract, then the spec will always be considered to satisfy
@ -1419,8 +1407,7 @@ def test_spec_override_with_nonexisting_variant(self):
def test_spec_override_with_variant_not_in_init_spec(self): def test_spec_override_with_variant_not_in_init_spec(self):
init_spec = Spec("pkg-a foo=baz foobar=baz cflags=-O3 cxxflags=-O1") init_spec = Spec("pkg-a foo=baz foobar=baz cflags=-O3 cxxflags=-O1")
change_spec = Spec("pkg-a +bvv ~lorem_ipsum") change_spec = Spec("pkg-a +bvv ~lorem_ipsum")
new_spec = Spec.override(init_spec, change_spec) new_spec = spack.concretize.concretize_one(Spec.override(init_spec, change_spec))
new_spec.concretize()
assert "+bvv" in new_spec assert "+bvv" in new_spec
assert "~lorem_ipsum" in new_spec assert "~lorem_ipsum" in new_spec
@ -1513,7 +1500,7 @@ def test_virtual_deps_bindings(self, default_mock_concretization, spec_str, spec
) )
def test_unsatisfiable_virtual_deps_bindings(self, spec_str): def test_unsatisfiable_virtual_deps_bindings(self, spec_str):
with pytest.raises(spack.solver.asp.UnsatisfiableSpecError): with pytest.raises(spack.solver.asp.UnsatisfiableSpecError):
Spec(spec_str).concretized() spack.concretize.concretize_one(spec_str)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -1611,7 +1598,7 @@ def test_spec_format_path_posix(spec_str, format_str, expected, mock_git_test_pa
def test_is_extension_after_round_trip_to_dict(config, mock_packages, spec_str): def test_is_extension_after_round_trip_to_dict(config, mock_packages, spec_str):
# x is constructed directly from string, y from a # x is constructed directly from string, y from a
# round-trip to dict representation # round-trip to dict representation
x = Spec(spec_str).concretized() x = spack.concretize.concretize_one(spec_str)
y = Spec.from_dict(x.to_dict()) y = Spec.from_dict(x.to_dict())
# Using 'y' since the round-trip make us lose build dependencies # Using 'y' since the round-trip make us lose build dependencies
@ -1712,7 +1699,7 @@ def test_call_dag_hash_on_old_dag_hash_spec(mock_packages, default_mock_concreti
def test_spec_trim(mock_packages, config): def test_spec_trim(mock_packages, config):
top = Spec("dt-diamond").concretized() top = spack.concretize.concretize_one("dt-diamond")
top.trim("dt-diamond-left") top.trim("dt-diamond-left")
remaining = set(x.name for x in top.traverse()) remaining = set(x.name for x in top.traverse())
assert set(["dt-diamond", "dt-diamond-right", "dt-diamond-bottom"]) == remaining assert set(["dt-diamond", "dt-diamond-right", "dt-diamond-bottom"]) == remaining
@ -1725,7 +1712,7 @@ def test_spec_trim(mock_packages, config):
@pytest.mark.regression("30861") @pytest.mark.regression("30861")
def test_concretize_partial_old_dag_hash_spec(mock_packages, config): def test_concretize_partial_old_dag_hash_spec(mock_packages, config):
# create an "old" spec with no package hash # create an "old" spec with no package hash
bottom = Spec("dt-diamond-bottom").concretized() bottom = spack.concretize.concretize_one("dt-diamond-bottom")
delattr(bottom, "_package_hash") delattr(bottom, "_package_hash")
dummy_hash = "zd4m26eis2wwbvtyfiliar27wkcv3ehk" dummy_hash = "zd4m26eis2wwbvtyfiliar27wkcv3ehk"
@ -1736,7 +1723,7 @@ def test_concretize_partial_old_dag_hash_spec(mock_packages, config):
top.add_dependency_edge(bottom, depflag=0, virtuals=()) top.add_dependency_edge(bottom, depflag=0, virtuals=())
# concretize with the already-concrete dependency # concretize with the already-concrete dependency
top.concretize() top = spack.concretize.concretize_one(top)
for spec in top.traverse(): for spec in top.traverse():
assert spec.concrete assert spec.concrete
@ -1954,7 +1941,7 @@ def test_edge_equality_does_not_depend_on_virtual_order():
def test_old_format_strings_trigger_error(default_mock_concretization): def test_old_format_strings_trigger_error(default_mock_concretization):
s = Spec("pkg-a").concretized() s = spack.concretize.concretize_one("pkg-a")
with pytest.raises(SpecFormatStringError): with pytest.raises(SpecFormatStringError):
s.format("${PACKAGE}-${VERSION}-${HASH}") s.format("${PACKAGE}-${VERSION}-${HASH}")

View File

@ -10,6 +10,7 @@
import spack.binary_distribution import spack.binary_distribution
import spack.cmd import spack.cmd
import spack.concretize
import spack.platforms.test import spack.platforms.test
import spack.repo import spack.repo
import spack.spec import spack.spec
@ -776,7 +777,7 @@ def test_spec_by_hash_tokens(text, tokens):
@pytest.mark.db @pytest.mark.db
def test_spec_by_hash(database, monkeypatch, config): def test_spec_by_hash(database, monkeypatch, config):
mpileaks = database.query_one("mpileaks ^zmpi") mpileaks = database.query_one("mpileaks ^zmpi")
b = spack.spec.Spec("pkg-b").concretized() b = spack.concretize.concretize_one("pkg-b")
monkeypatch.setattr(spack.binary_distribution, "update_cache_and_get_specs", lambda: [b]) monkeypatch.setattr(spack.binary_distribution, "update_cache_and_get_specs", lambda: [b])
hash_str = f"/{mpileaks.dag_hash()}" hash_str = f"/{mpileaks.dag_hash()}"
@ -873,7 +874,7 @@ def test_ambiguous_hash(mutable_database):
In the past this ambiguity error would happen during parse time.""" In the past this ambiguity error would happen during parse time."""
# This is a very sketchy as manually setting hashes easily breaks invariants # This is a very sketchy as manually setting hashes easily breaks invariants
x1 = spack.spec.Spec("pkg-a").concretized() x1 = spack.concretize.concretize_one("pkg-a")
x2 = x1.copy() x2 = x1.copy()
x1._hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" x1._hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
x1._process_hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" x1._process_hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
@ -947,8 +948,8 @@ def test_nonexistent_hash(database, config):
], ],
) )
def test_disambiguate_hash_by_spec(spec1, spec2, constraint, mock_packages, monkeypatch, config): def test_disambiguate_hash_by_spec(spec1, spec2, constraint, mock_packages, monkeypatch, config):
spec1_concrete = spack.spec.Spec(spec1).concretized() spec1_concrete = spack.concretize.concretize_one(spec1)
spec2_concrete = spack.spec.Spec(spec2).concretized() spec2_concrete = spack.concretize.concretize_one(spec2)
spec1_concrete._hash = "spec1" spec1_concrete._hash = "spec1"
spec2_concrete._hash = "spec2" spec2_concrete._hash = "spec2"
@ -1139,7 +1140,7 @@ def test_parse_filename_missing_slash_as_spec(specfile_for, tmpdir, filename):
# Check that if we concretize this spec, we get a good error # Check that if we concretize this spec, we get a good error
# message that mentions we might've meant a file. # message that mentions we might've meant a file.
with pytest.raises(spack.repo.UnknownEntityError) as exc_info: with pytest.raises(spack.repo.UnknownEntityError) as exc_info:
spec.concretize() spack.concretize.concretize_one(spec)
assert exc_info.value.long_message assert exc_info.value.long_message
assert ( assert (
"Did you mean to specify a filename with './libelf.yaml'?" in exc_info.value.long_message "Did you mean to specify a filename with './libelf.yaml'?" in exc_info.value.long_message
@ -1147,7 +1148,7 @@ def test_parse_filename_missing_slash_as_spec(specfile_for, tmpdir, filename):
# make sure that only happens when the spec ends in yaml # make sure that only happens when the spec ends in yaml
with pytest.raises(spack.repo.UnknownPackageError) as exc_info: with pytest.raises(spack.repo.UnknownPackageError) as exc_info:
SpecParser("builtin.mock.doesnotexist").next_spec().concretize() spack.concretize.concretize_one(SpecParser("builtin.mock.doesnotexist").next_spec())
assert not exc_info.value.long_message or ( assert not exc_info.value.long_message or (
"Did you mean to specify a filename with" not in exc_info.value.long_message "Did you mean to specify a filename with" not in exc_info.value.long_message
) )

View File

@ -20,6 +20,7 @@
import pytest import pytest
import ruamel.yaml import ruamel.yaml
import spack.concretize
import spack.hash_types as ht import spack.hash_types as ht
import spack.paths import spack.paths
import spack.repo import spack.repo
@ -107,8 +108,7 @@ def test_roundtrip_concrete_specs(abstract_spec, default_mock_concretization):
def test_yaml_subdag(config, mock_packages): def test_yaml_subdag(config, mock_packages):
spec = Spec("mpileaks^mpich+debug") spec = spack.concretize.concretize_one("mpileaks^mpich+debug")
spec.concretize()
yaml_spec = Spec.from_yaml(spec.to_yaml()) yaml_spec = Spec.from_yaml(spec.to_yaml())
json_spec = Spec.from_json(spec.to_json()) json_spec = Spec.from_json(spec.to_json())
@ -153,8 +153,7 @@ def test_ordered_read_not_required_for_consistent_dag_hash(config, mock_packages
""" """
specs = ["mpileaks ^zmpi", "dttop", "dtuse"] specs = ["mpileaks ^zmpi", "dttop", "dtuse"]
for spec in specs: for spec in specs:
spec = Spec(spec) spec = spack.concretize.concretize_one(spec)
spec.concretize()
# #
# Dict & corresponding YAML & JSON from the original spec. # Dict & corresponding YAML & JSON from the original spec.
@ -214,11 +213,15 @@ def test_ordered_read_not_required_for_consistent_dag_hash(config, mock_packages
assert spec.dag_hash() == round_trip_reversed_json_spec.dag_hash() assert spec.dag_hash() == round_trip_reversed_json_spec.dag_hash()
# dag_hash is equal after round-trip by dag_hash # dag_hash is equal after round-trip by dag_hash
spec.concretize() spec = spack.concretize.concretize_one(spec)
round_trip_yaml_spec.concretize() round_trip_yaml_spec = spack.concretize.concretize_one(round_trip_yaml_spec)
round_trip_json_spec.concretize() round_trip_json_spec = spack.concretize.concretize_one(round_trip_json_spec)
round_trip_reversed_yaml_spec.concretize() round_trip_reversed_yaml_spec = spack.concretize.concretize_one(
round_trip_reversed_json_spec.concretize() round_trip_reversed_yaml_spec
)
round_trip_reversed_json_spec = spack.concretize.concretize_one(
round_trip_reversed_json_spec
)
assert spec.dag_hash() == round_trip_yaml_spec.dag_hash() assert spec.dag_hash() == round_trip_yaml_spec.dag_hash()
assert spec.dag_hash() == round_trip_json_spec.dag_hash() assert spec.dag_hash() == round_trip_json_spec.dag_hash()
assert spec.dag_hash() == round_trip_reversed_yaml_spec.dag_hash() assert spec.dag_hash() == round_trip_reversed_yaml_spec.dag_hash()
@ -322,7 +325,7 @@ def test_save_dependency_spec_jsons_subset(tmpdir, config):
builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)]) builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)])
with spack.repo.use_repositories(builder.root): with spack.repo.use_repositories(builder.root):
spec_a = Spec("pkg-a").concretized() spec_a = spack.concretize.concretize_one("pkg-a")
b_spec = spec_a["pkg-b"] b_spec = spec_a["pkg-b"]
c_spec = spec_a["pkg-c"] c_spec = spec_a["pkg-c"]
@ -389,7 +392,7 @@ def test_legacy_yaml(tmpdir, install_mockery, mock_packages):
build_hash: iaapywazxgetn6gfv2cfba353qzzqvhy build_hash: iaapywazxgetn6gfv2cfba353qzzqvhy
""" """
spec = Spec.from_yaml(yaml) spec = Spec.from_yaml(yaml)
concrete_spec = spec.concretized() concrete_spec = spack.concretize.concretize_one(spec)
assert concrete_spec.eq_dag(spec) assert concrete_spec.eq_dag(spec)

View File

@ -8,9 +8,9 @@
from llnl.util.filesystem import mkdirp, touch, working_dir from llnl.util.filesystem import mkdirp, touch, working_dir
import spack.concretize
import spack.config import spack.config
from spack.fetch_strategy import SvnFetchStrategy from spack.fetch_strategy import SvnFetchStrategy
from spack.spec import Spec
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import which from spack.util.executable import which
from spack.version import Version from spack.version import Version
@ -40,7 +40,7 @@ def test_fetch(type_of_test, secure, mock_svn_repository, config, mutable_mock_r
h = mock_svn_repository.hash h = mock_svn_repository.hash
# Construct the package under test # Construct the package under test
s = Spec("svn-test").concretized() s = spack.concretize.concretize_one("svn-test")
monkeypatch.setitem(s.package.versions, Version("svn"), t.args) monkeypatch.setitem(s.package.versions, Version("svn"), t.args)
# Enter the stage directory and check some properties # Enter the stage directory and check some properties

View File

@ -9,6 +9,7 @@
from llnl.util.filesystem import join_path, mkdirp, touch from llnl.util.filesystem import join_path, mkdirp, touch
import spack.concretize
import spack.config import spack.config
import spack.install_test import spack.install_test
import spack.spec import spack.spec
@ -39,7 +40,7 @@ def ensure_results(filename, expected, present=True):
def test_test_log_name(mock_packages, config): def test_test_log_name(mock_packages, config):
"""Ensure test log path is reasonable.""" """Ensure test log path is reasonable."""
spec = spack.spec.Spec("libdwarf").concretized() spec = spack.concretize.concretize_one("libdwarf")
test_name = "test_name" test_name = "test_name"
@ -52,7 +53,7 @@ def test_test_log_name(mock_packages, config):
def test_test_ensure_stage(mock_test_stage, mock_packages): def test_test_ensure_stage(mock_test_stage, mock_packages):
"""Make sure test stage directory is properly set up.""" """Make sure test stage directory is properly set up."""
spec = spack.spec.Spec("libdwarf").concretized() spec = spack.concretize.concretize_one("libdwarf")
test_name = "test_name" test_name = "test_name"
@ -65,7 +66,7 @@ def test_test_ensure_stage(mock_test_stage, mock_packages):
def test_write_test_result(mock_packages, mock_test_stage): def test_write_test_result(mock_packages, mock_test_stage):
"""Ensure test results written to a results file.""" """Ensure test results written to a results file."""
spec = spack.spec.Spec("libdwarf").concretized() spec = spack.concretize.concretize_one("libdwarf")
result = "TEST" result = "TEST"
test_name = "write-test" test_name = "write-test"
@ -85,7 +86,7 @@ def test_write_test_result(mock_packages, mock_test_stage):
def test_test_not_installed(mock_packages, install_mockery, mock_test_stage): def test_test_not_installed(mock_packages, install_mockery, mock_test_stage):
"""Attempt to perform stand-alone test for not_installed package.""" """Attempt to perform stand-alone test for not_installed package."""
spec = spack.spec.Spec("trivial-smoke-test").concretized() spec = spack.concretize.concretize_one("trivial-smoke-test")
test_suite = spack.install_test.TestSuite([spec]) test_suite = spack.install_test.TestSuite([spec])
test_suite() test_suite()
@ -102,7 +103,7 @@ def test_test_external(
mock_packages, install_mockery, mock_test_stage, monkeypatch, arguments, status, msg mock_packages, install_mockery, mock_test_stage, monkeypatch, arguments, status, msg
): ):
name = "trivial-smoke-test" name = "trivial-smoke-test"
spec = spack.spec.Spec(name).concretized() spec = spack.concretize.concretize_one(name)
spec.external_path = "/path/to/external/{0}".format(name) spec.external_path = "/path/to/external/{0}".format(name)
monkeypatch.setattr(spack.spec.Spec, "installed", _true) monkeypatch.setattr(spack.spec.Spec, "installed", _true)
@ -123,7 +124,7 @@ def ensure_current_cache_fail(test_suite):
with pytest.raises(spack.install_test.TestSuiteSpecError): with pytest.raises(spack.install_test.TestSuiteSpecError):
_ = test_suite.current_test_data_dir _ = test_suite.current_test_data_dir
spec = spack.spec.Spec("libelf").concretized() spec = spack.concretize.concretize_one("libelf")
test_suite = spack.install_test.TestSuite([spec], "test-cache") test_suite = spack.install_test.TestSuite([spec], "test-cache")
# Check no current specs yield failure # Check no current specs yield failure
@ -141,7 +142,7 @@ def ensure_current_cache_fail(test_suite):
def test_test_spec_run_once(mock_packages, install_mockery, mock_test_stage): def test_test_spec_run_once(mock_packages, install_mockery, mock_test_stage):
spec = spack.spec.Spec("libelf").concretized() spec = spack.concretize.concretize_one("libelf")
test_suite = spack.install_test.TestSuite([spec], "test-dups") test_suite = spack.install_test.TestSuite([spec], "test-dups")
(test_suite.specs[0]).package.test_suite = test_suite (test_suite.specs[0]).package.test_suite = test_suite
@ -151,7 +152,7 @@ def test_test_spec_run_once(mock_packages, install_mockery, mock_test_stage):
@pytest.mark.not_on_windows("Cannot find echo executable") @pytest.mark.not_on_windows("Cannot find echo executable")
def test_test_spec_passes(mock_packages, install_mockery, mock_test_stage, monkeypatch): def test_test_spec_passes(mock_packages, install_mockery, mock_test_stage, monkeypatch):
spec = spack.spec.Spec("simple-standalone-test").concretized() spec = spack.concretize.concretize_one("simple-standalone-test")
monkeypatch.setattr(spack.spec.Spec, "installed", _true) monkeypatch.setattr(spack.spec.Spec, "installed", _true)
test_suite = spack.install_test.TestSuite([spec]) test_suite = spack.install_test.TestSuite([spec])
test_suite() test_suite()
@ -177,7 +178,7 @@ def test_get_test_suite_too_many(mock_packages, mock_test_stage):
name = "duplicate-alias" name = "duplicate-alias"
def add_suite(package): def add_suite(package):
spec = spack.spec.Spec(package).concretized() spec = spack.concretize.concretize_one(package)
suite = spack.install_test.TestSuite([spec], name) suite = spack.install_test.TestSuite([spec], name)
suite.ensure_stage() suite.ensure_stage()
spack.install_test.write_test_suite_file(suite) spack.install_test.write_test_suite_file(suite)
@ -199,7 +200,7 @@ def add_suite(package):
) )
def test_test_function_names(mock_packages, install_mockery, virtuals, expected): def test_test_function_names(mock_packages, install_mockery, virtuals, expected):
"""Confirm test_function_names works as expected with/without virtuals.""" """Confirm test_function_names works as expected with/without virtuals."""
spec = spack.spec.Spec("mpich").concretized() spec = spack.concretize.concretize_one("mpich")
tests = spack.install_test.test_function_names(spec.package, add_virtuals=virtuals) tests = spack.install_test.test_function_names(spec.package, add_virtuals=virtuals)
assert sorted(tests) == sorted(expected) assert sorted(tests) == sorted(expected)
@ -212,7 +213,7 @@ def test_test_functions_fails():
def test_test_functions_pkgless(mock_packages, install_mockery, ensure_debug, capsys): def test_test_functions_pkgless(mock_packages, install_mockery, ensure_debug, capsys):
"""Confirm works for package providing a package-less virtual.""" """Confirm works for package providing a package-less virtual."""
spec = spack.spec.Spec("simple-standalone-test").concretized() spec = spack.concretize.concretize_one("simple-standalone-test")
fns = spack.install_test.test_functions(spec.package, add_virtuals=True) fns = spack.install_test.test_functions(spec.package, add_virtuals=True)
out = capsys.readouterr() out = capsys.readouterr()
assert len(fns) == 2, "Expected two test functions" assert len(fns) == 2, "Expected two test functions"
@ -295,7 +296,7 @@ def test_process_test_parts(mock_packages):
def test_test_part_fail(tmpdir, install_mockery, mock_fetch, mock_test_stage): def test_test_part_fail(tmpdir, install_mockery, mock_fetch, mock_test_stage):
"""Confirm test_part with a ProcessError results in FAILED status.""" """Confirm test_part with a ProcessError results in FAILED status."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
pkg.tester.test_log_file = str(tmpdir.join("test-log.txt")) pkg.tester.test_log_file = str(tmpdir.join("test-log.txt"))
touch(pkg.tester.test_log_file) touch(pkg.tester.test_log_file)
@ -311,7 +312,7 @@ def test_test_part_fail(tmpdir, install_mockery, mock_fetch, mock_test_stage):
def test_test_part_pass(install_mockery, mock_fetch, mock_test_stage): def test_test_part_pass(install_mockery, mock_fetch, mock_test_stage):
"""Confirm test_part that succeeds results in PASSED status.""" """Confirm test_part that succeeds results in PASSED status."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
name = "test_echo" name = "test_echo"
@ -330,7 +331,7 @@ def test_test_part_pass(install_mockery, mock_fetch, mock_test_stage):
def test_test_part_skip(install_mockery, mock_fetch, mock_test_stage): def test_test_part_skip(install_mockery, mock_fetch, mock_test_stage):
"""Confirm test_part that raises SkipTest results in test status SKIPPED.""" """Confirm test_part that raises SkipTest results in test status SKIPPED."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
name = "test_skip" name = "test_skip"
@ -344,7 +345,7 @@ def test_test_part_skip(install_mockery, mock_fetch, mock_test_stage):
def test_test_part_missing_exe_fail_fast(tmpdir, install_mockery, mock_fetch, mock_test_stage): def test_test_part_missing_exe_fail_fast(tmpdir, install_mockery, mock_fetch, mock_test_stage):
"""Confirm test_part with fail fast enabled raises exception.""" """Confirm test_part with fail fast enabled raises exception."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
pkg.tester.test_log_file = str(tmpdir.join("test-log.txt")) pkg.tester.test_log_file = str(tmpdir.join("test-log.txt"))
touch(pkg.tester.test_log_file) touch(pkg.tester.test_log_file)
@ -365,7 +366,7 @@ def test_test_part_missing_exe_fail_fast(tmpdir, install_mockery, mock_fetch, mo
def test_test_part_missing_exe(tmpdir, install_mockery, mock_fetch, mock_test_stage): def test_test_part_missing_exe(tmpdir, install_mockery, mock_fetch, mock_test_stage):
"""Confirm test_part with missing executable fails.""" """Confirm test_part with missing executable fails."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
pkg.tester.test_log_file = str(tmpdir.join("test-log.txt")) pkg.tester.test_log_file = str(tmpdir.join("test-log.txt"))
touch(pkg.tester.test_log_file) touch(pkg.tester.test_log_file)
@ -401,7 +402,7 @@ def test_embedded_test_part_status(
): ):
"""Check to ensure the status of the enclosing test part reflects summary of embedded parts.""" """Check to ensure the status of the enclosing test part reflects summary of embedded parts."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
base_name = "test_example" base_name = "test_example"
part_name = f"{pkg.__class__.__name__}::{base_name}" part_name = f"{pkg.__class__.__name__}::{base_name}"
@ -428,7 +429,7 @@ def test_write_tested_status(
tmpdir, install_mockery, mock_fetch, mock_test_stage, statuses, expected tmpdir, install_mockery, mock_fetch, mock_test_stage, statuses, expected
): ):
"""Check to ensure the status of the enclosing test part reflects summary of embedded parts.""" """Check to ensure the status of the enclosing test part reflects summary of embedded parts."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
for i, status in enumerate(statuses): for i, status in enumerate(statuses):
pkg.tester.test_parts[f"test_{i}"] = status pkg.tester.test_parts[f"test_{i}"] = status
@ -444,7 +445,7 @@ def test_write_tested_status(
@pytest.mark.regression("37840") @pytest.mark.regression("37840")
def test_write_tested_status_no_repeats(tmpdir, install_mockery, mock_fetch, mock_test_stage): def test_write_tested_status_no_repeats(tmpdir, install_mockery, mock_fetch, mock_test_stage):
"""Emulate re-running the same stand-alone tests a second time.""" """Emulate re-running the same stand-alone tests a second time."""
s = spack.spec.Spec("trivial-smoke-test").concretized() s = spack.concretize.concretize_one("trivial-smoke-test")
pkg = s.package pkg = s.package
statuses = [TestStatus.PASSED, TestStatus.PASSED] statuses = [TestStatus.PASSED, TestStatus.PASSED]
for i, status in enumerate(statuses): for i, status in enumerate(statuses):

View File

@ -13,6 +13,7 @@
import llnl.util.tty as tty import llnl.util.tty as tty
from llnl.util.filesystem import is_exe, working_dir from llnl.util.filesystem import is_exe, working_dir
import spack.concretize
import spack.config import spack.config
import spack.error import spack.error
import spack.fetch_strategy as fs import spack.fetch_strategy as fs
@ -21,7 +22,6 @@
import spack.util.executable import spack.util.executable
import spack.util.web as web_util import spack.util.web as web_util
import spack.version import spack.version
from spack.spec import Spec
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import which from spack.util.executable import which
@ -192,7 +192,7 @@ def test_from_list_url(mock_packages, config, spec, url, digest, _fetch_method):
have checksums in the package. have checksums in the package.
""" """
with spack.config.override("config:url_fetch_method", _fetch_method): with spack.config.override("config:url_fetch_method", _fetch_method):
s = Spec(spec).concretized() s = spack.concretize.concretize_one(spec)
fetch_strategy = fs.from_list_url(s.package) fetch_strategy = fs.from_list_url(s.package)
assert isinstance(fetch_strategy, fs.URLFetchStrategy) assert isinstance(fetch_strategy, fs.URLFetchStrategy)
assert os.path.basename(fetch_strategy.url) == url assert os.path.basename(fetch_strategy.url) == url
@ -218,7 +218,7 @@ def test_new_version_from_list_url(
): ):
"""Test non-specific URLs from the url-list-test package.""" """Test non-specific URLs from the url-list-test package."""
with spack.config.override("config:url_fetch_method", _fetch_method): with spack.config.override("config:url_fetch_method", _fetch_method):
s = Spec(f"url-list-test @{requested_version}").concretized() s = spack.concretize.concretize_one(f"url-list-test @{requested_version}")
fetch_strategy = fs.from_list_url(s.package) fetch_strategy = fs.from_list_url(s.package)
assert isinstance(fetch_strategy, fs.URLFetchStrategy) assert isinstance(fetch_strategy, fs.URLFetchStrategy)
@ -232,7 +232,7 @@ def test_new_version_from_list_url(
def test_nosource_from_list_url(mock_packages, config): def test_nosource_from_list_url(mock_packages, config):
"""This test confirms BundlePackages do not have list url.""" """This test confirms BundlePackages do not have list url."""
s = Spec("nosource").concretized() s = spack.concretize.concretize_one("nosource")
fetch_strategy = fs.from_list_url(s.package) fetch_strategy = fs.from_list_url(s.package)
assert fetch_strategy is None assert fetch_strategy is None

View File

@ -7,6 +7,7 @@
import pytest import pytest
import spack.concretize
import spack.directives import spack.directives
import spack.directives_meta import spack.directives_meta
import spack.paths import spack.paths
@ -91,8 +92,8 @@ def test_all_same_but_install(mock_packages, config):
def test_content_hash_all_same_but_patch_contents(mock_packages, config): def test_content_hash_all_same_but_patch_contents(mock_packages, config):
spec1 = Spec("hash-test1@1.1").concretized() spec1 = spack.concretize.concretize_one("hash-test1@1.1")
spec2 = Spec("hash-test2@1.1").concretized() spec2 = spack.concretize.concretize_one("hash-test2@1.1")
compare_hash_sans_name(False, spec1, spec2) compare_hash_sans_name(False, spec1, spec2)
@ -117,8 +118,8 @@ def test_content_hash_not_concretized(mock_packages, config):
def test_content_hash_different_variants(mock_packages, config): def test_content_hash_different_variants(mock_packages, config):
spec1 = Spec("hash-test1@1.2 +variantx").concretized() spec1 = spack.concretize.concretize_one("hash-test1@1.2 +variantx")
spec2 = Spec("hash-test2@1.2 ~variantx").concretized() spec2 = spack.concretize.concretize_one("hash-test2@1.2 ~variantx")
compare_hash_sans_name(True, spec1, spec2) compare_hash_sans_name(True, spec1, spec2)
@ -132,19 +133,19 @@ def test_content_hash_cannot_get_details_from_ast(mock_packages, config):
differ where Spack includes a phase on account of AST-examination differ where Spack includes a phase on account of AST-examination
failure. failure.
""" """
spec3 = Spec("hash-test1@1.7").concretized() spec3 = spack.concretize.concretize_one("hash-test1@1.7")
spec4 = Spec("hash-test3@1.7").concretized() spec4 = spack.concretize.concretize_one("hash-test3@1.7")
compare_hash_sans_name(False, spec3, spec4) compare_hash_sans_name(False, spec3, spec4)
def test_content_hash_all_same_but_archive_hash(mock_packages, config): def test_content_hash_all_same_but_archive_hash(mock_packages, config):
spec1 = Spec("hash-test1@1.3").concretized() spec1 = spack.concretize.concretize_one("hash-test1@1.3")
spec2 = Spec("hash-test2@1.3").concretized() spec2 = spack.concretize.concretize_one("hash-test2@1.3")
compare_hash_sans_name(False, spec1, spec2) compare_hash_sans_name(False, spec1, spec2)
def test_content_hash_parse_dynamic_function_call(mock_packages, config): def test_content_hash_parse_dynamic_function_call(mock_packages, config):
spec = Spec("hash-test4").concretized() spec = spack.concretize.concretize_one("hash-test4")
spec.package.content_hash() spec.package.content_hash()

View File

@ -5,6 +5,7 @@
import pytest import pytest
import spack.concretize
import spack.error import spack.error
import spack.repo import spack.repo
import spack.spec import spack.spec
@ -686,12 +687,11 @@ def test_str(self) -> None:
def test_concrete(self, mock_packages, config) -> None: def test_concrete(self, mock_packages, config) -> None:
spec = Spec("pkg-a") spec = Spec("pkg-a")
vm = VariantMap(spec) assert not VariantMap(spec).concrete
assert not vm.concrete
# concrete if associated spec is concrete # concrete if associated spec is concrete
spec.concretize() spec = spack.concretize.concretize_one(spec)
assert vm.concrete assert VariantMap(spec).concrete
# concrete if all variants are present (even if spec not concrete) # concrete if all variants are present (even if spec not concrete)
spec._mark_concrete(False) spec._mark_concrete(False)
@ -910,7 +910,7 @@ def test_concretize_variant_default_with_multiple_defs(
pkg = spack.repo.PATH.get_pkg_class(pkg_name) pkg = spack.repo.PATH.get_pkg_class(pkg_name)
pkg_defs = [vdef for _, vdef in pkg.variant_definitions("v")] pkg_defs = [vdef for _, vdef in pkg.variant_definitions("v")]
spec = spack.spec.Spec(f"{pkg_name}{spec}").concretized() spec = spack.concretize.concretize_one(f"{pkg_name}{spec}")
assert spec.satisfies(satisfies) assert spec.satisfies(satisfies)
assert spec.package.get_variant("v") is pkg_defs[def_id] assert spec.package.get_variant("v") is pkg_defs[def_id]

View File

@ -13,6 +13,7 @@
from llnl.util.filesystem import working_dir from llnl.util.filesystem import working_dir
import spack.concretize
import spack.package_base import spack.package_base
import spack.spec import spack.spec
import spack.version import spack.version
@ -707,7 +708,9 @@ def test_git_hash_comparisons(
spack.package_base.PackageBase, "git", pathlib.Path(repo_path).as_uri(), raising=False spack.package_base.PackageBase, "git", pathlib.Path(repo_path).as_uri(), raising=False
) )
spec = spack.spec.Spec(f"git-test-commit@{commits[commit_idx]}").concretized() spec = spack.concretize.concretize_one(
spack.spec.Spec(f"git-test-commit@{commits[commit_idx]}")
)
for item in expected_satisfies: for item in expected_satisfies:
assert spec.satisfies(item) assert spec.satisfies(item)
@ -723,15 +726,13 @@ def test_git_ref_comparisons(mock_git_version_info, install_mockery, mock_packag
) )
# Spec based on tag v1.0 # Spec based on tag v1.0
spec_tag = spack.spec.Spec("git-test-commit@git.v1.0") spec_tag = spack.concretize.concretize_one("git-test-commit@git.v1.0")
spec_tag.concretize()
assert spec_tag.satisfies("@1.0") assert spec_tag.satisfies("@1.0")
assert not spec_tag.satisfies("@1.1:") assert not spec_tag.satisfies("@1.1:")
assert str(spec_tag.version) == "git.v1.0=1.0" assert str(spec_tag.version) == "git.v1.0=1.0"
# Spec based on branch 1.x # Spec based on branch 1.x
spec_branch = spack.spec.Spec("git-test-commit@git.1.x") spec_branch = spack.concretize.concretize_one("git-test-commit@git.1.x")
spec_branch.concretize()
assert spec_branch.satisfies("@1.2") assert spec_branch.satisfies("@1.2")
assert spec_branch.satisfies("@1.1:1.3") assert spec_branch.satisfies("@1.1:1.3")
assert str(spec_branch.version) == "git.1.x=1.2" assert str(spec_branch.version) == "git.1.x=1.2"
@ -1030,7 +1031,7 @@ def test_git_version_repo_attached_after_serialization(
monkeypatch.setattr( monkeypatch.setattr(
spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False
) )
spec = spack.spec.Spec(f"git-test-commit@{commits[-2]}").concretized() spec = spack.concretize.concretize_one(f"git-test-commit@{commits[-2]}")
# Before serialization, the repo is attached # Before serialization, the repo is attached
assert spec.satisfies("@1.0") assert spec.satisfies("@1.0")
@ -1050,7 +1051,7 @@ def test_resolved_git_version_is_shown_in_str(
spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False
) )
commit = commits[-3] commit = commits[-3]
spec = spack.spec.Spec(f"git-test-commit@{commit}").concretized() spec = spack.concretize.concretize_one(f"git-test-commit@{commit}")
assert spec.version.satisfies(ver("1.0")) assert spec.version.satisfies(ver("1.0"))
assert str(spec.version) == f"{commit}=1.0-git.1" assert str(spec.version) == f"{commit}=1.0-git.1"

View File

@ -6,6 +6,7 @@
import pytest import pytest
import spack.concretize
from spack.directory_layout import DirectoryLayout from spack.directory_layout import DirectoryLayout
from spack.filesystem_view import SimpleFilesystemView, YamlFilesystemView from spack.filesystem_view import SimpleFilesystemView, YamlFilesystemView
from spack.installer import PackageInstaller from spack.installer import PackageInstaller
@ -16,7 +17,7 @@ def test_remove_extensions_ordered(install_mockery, mock_fetch, tmpdir):
view_dir = str(tmpdir.join("view")) view_dir = str(tmpdir.join("view"))
layout = DirectoryLayout(view_dir) layout = DirectoryLayout(view_dir)
view = YamlFilesystemView(view_dir, layout) view = YamlFilesystemView(view_dir, layout)
e2 = Spec("extension2").concretized() e2 = spack.concretize.concretize_one("extension2")
PackageInstaller([e2.package], explicit=True).install() PackageInstaller([e2.package], explicit=True).install()
view.add_specs(e2) view.add_specs(e2)