From 4e9fe1fc5d740d5c7b631164ba96c24d9b795e01 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 6 Dec 2024 09:58:36 -0800 Subject: [PATCH] concretization: move single-spec concretization logic to spack.concretize This resolves a circular import issue between spack.spec and spack.concretize. It requires removing the `Spec.concretize` and `Spec.concretized` methods and updating all call-sites to use `spack.concretize.concretized` instead. This will help with potential future efforts to separate AbstractSpec and ConcreteSpec classes. New import relationship is `spack.concretize` imports from `spack.spec`, but not the other way around. --- lib/spack/spack/bootstrap/core.py | 7 +- lib/spack/spack/cmd/__init__.py | 6 +- lib/spack/spack/cmd/bootstrap.py | 3 +- lib/spack/spack/cmd/buildcache.py | 6 +- lib/spack/spack/cmd/deprecate.py | 3 +- lib/spack/spack/cmd/dev_build.py | 3 +- lib/spack/spack/cmd/install.py | 3 +- lib/spack/spack/cmd/make_installer.py | 4 +- lib/spack/spack/cmd/mirror.py | 2 +- lib/spack/spack/concretize.py | 41 +- lib/spack/spack/spec.py | 59 +-- lib/spack/spack/test/abi_splicing.py | 45 +- lib/spack/spack/test/architecture.py | 2 +- lib/spack/spack/test/bindist.py | 26 +- lib/spack/spack/test/build_distribution.py | 3 +- lib/spack/spack/test/build_environment.py | 30 +- lib/spack/spack/test/build_systems.py | 20 +- lib/spack/spack/test/builder.py | 15 +- lib/spack/spack/test/buildrequest.py | 9 +- lib/spack/spack/test/buildtask.py | 9 +- lib/spack/spack/test/ci.py | 7 +- lib/spack/spack/test/cmd/bootstrap.py | 4 +- lib/spack/spack/test/cmd/buildcache.py | 17 +- lib/spack/spack/test/cmd/checksum.py | 3 +- lib/spack/spack/test/cmd/ci.py | 14 +- lib/spack/spack/test/cmd/clean.py | 4 +- lib/spack/spack/test/cmd/config.py | 4 +- lib/spack/spack/test/cmd/deprecate.py | 19 +- lib/spack/spack/test/cmd/dev_build.py | 54 ++- lib/spack/spack/test/cmd/develop.py | 9 +- lib/spack/spack/test/cmd/diff.py | 13 +- lib/spack/spack/test/cmd/env.py | 37 +- lib/spack/spack/test/cmd/extensions.py | 7 +- lib/spack/spack/test/cmd/find.py | 12 +- lib/spack/spack/test/cmd/gc.py | 20 +- lib/spack/spack/test/cmd/install.py | 55 +-- lib/spack/spack/test/cmd/load.py | 7 +- lib/spack/spack/test/cmd/location.py | 3 +- lib/spack/spack/test/cmd/logs.py | 5 +- lib/spack/spack/test/cmd/mirror.py | 14 +- lib/spack/spack/test/cmd/module.py | 12 +- lib/spack/spack/test/cmd/tags.py | 3 +- lib/spack/spack/test/cmd/test.py | 7 +- lib/spack/spack/test/cmd/undevelop.py | 5 +- lib/spack/spack/test/cmd/verify.py | 3 +- lib/spack/spack/test/cmd/view.py | 3 +- .../test/concretization/compiler_runtimes.py | 7 +- lib/spack/spack/test/concretization/core.py | 422 +++++++++--------- lib/spack/spack/test/concretization/errors.py | 3 +- .../spack/test/concretization/flag_mixing.py | 23 +- .../spack/test/concretization/preferences.py | 50 +-- .../spack/test/concretization/requirements.py | 127 +++--- lib/spack/spack/test/config_values.py | 5 +- lib/spack/spack/test/conftest.py | 7 +- lib/spack/spack/test/cvs_fetch.py | 3 +- lib/spack/spack/test/database.py | 45 +- lib/spack/spack/test/directives.py | 7 +- lib/spack/spack/test/directory_layout.py | 13 +- lib/spack/spack/test/flag_handlers.py | 27 +- lib/spack/spack/test/git_fetch.py | 6 +- lib/spack/spack/test/graph.py | 3 +- lib/spack/spack/test/hg_fetch.py | 3 +- lib/spack/spack/test/install.py | 73 ++- lib/spack/spack/test/installer.py | 66 ++- lib/spack/spack/test/mirror.py | 11 +- lib/spack/spack/test/modules/common.py | 7 +- lib/spack/spack/test/modules/conftest.py | 5 +- lib/spack/spack/test/modules/lmod.py | 9 +- lib/spack/spack/test/modules/tcl.py | 16 +- lib/spack/spack/test/multimethod.py | 11 +- lib/spack/spack/test/optional_deps.py | 10 +- lib/spack/spack/test/package_class.py | 7 +- lib/spack/spack/test/packages.py | 16 +- lib/spack/spack/test/packaging.py | 3 +- lib/spack/spack/test/patch.py | 38 +- lib/spack/spack/test/rewiring.py | 25 +- lib/spack/spack/test/spec_dag.py | 76 ++-- lib/spack/spack/test/spec_list.py | 5 +- lib/spack/spack/test/spec_semantics.py | 61 +-- lib/spack/spack/test/spec_syntax.py | 13 +- lib/spack/spack/test/spec_yaml.py | 21 +- lib/spack/spack/test/svn_fetch.py | 3 +- lib/spack/spack/test/test_suite.py | 39 +- lib/spack/spack/test/url_fetch.py | 7 +- lib/spack/spack/test/util/package_hash.py | 19 +- lib/spack/spack/test/variant.py | 5 +- lib/spack/spack/test/versions.py | 13 +- lib/spack/spack/test/views.py | 3 +- 88 files changed, 987 insertions(+), 963 deletions(-) diff --git a/lib/spack/spack/bootstrap/core.py b/lib/spack/spack/bootstrap/core.py index d396aaac687..c199230da1b 100644 --- a/lib/spack/spack/bootstrap/core.py +++ b/lib/spack/spack/bootstrap/core.py @@ -35,6 +35,7 @@ from llnl.util.lang import GroupedExceptionHandler import spack.binary_distribution +import spack.concretize import spack.config import spack.detection import spack.mirrors.mirror @@ -271,10 +272,10 @@ def try_import(self, module: str, abstract_spec_str: str) -> bool: bootstrapper = ClingoBootstrapConcretizer(configuration=spack.config.CONFIG) concrete_spec = bootstrapper.concretize() else: - concrete_spec = spack.spec.Spec( + abstract_spec = spack.spec.Spec( abstract_spec_str + " ^" + spec_for_current_python() ) - concrete_spec.concretize() + concrete_spec = spack.concretize.concretized(abstract_spec) msg = "[BOOTSTRAP MODULE {0}] Try installing '{1}' from sources" tty.debug(msg.format(module, abstract_spec_str)) @@ -300,7 +301,7 @@ def try_search_path(self, executables: Tuple[str], abstract_spec_str: str) -> bo # might reduce compilation time by a fair amount _add_externals_if_missing() - concrete_spec = spack.spec.Spec(abstract_spec_str).concretized() + concrete_spec = spack.concretize.concretized(spack.spec.Spec(abstract_spec_str)) msg = "[BOOTSTRAP] Try installing '{0}' from sources" tty.debug(msg.format(abstract_spec_str)) with spack.config.override(self.mirror_scope): diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py index 4b64a2529ac..5b27add98ba 100644 --- a/lib/spack/spack/cmd/__init__.py +++ b/lib/spack/spack/cmd/__init__.py @@ -199,7 +199,7 @@ def _concretize_spec_pairs(to_concretize, tests=False): # Special case for concretizing a single spec if len(to_concretize) == 1: abstract, concrete = to_concretize[0] - return [concrete or abstract.concretized()] + return [concrete or spack.concretize.concretized(abstract)] # Special case if every spec is either concrete or has an abstract hash if all( @@ -251,9 +251,9 @@ def matching_spec_from_env(spec): """ env = ev.active_environment() if env: - return env.matching_spec(spec) or spec.concretized() + return env.matching_spec(spec) or spack.concretize.concretized(spec) else: - return spec.concretized() + return spack.concretize.concretized(spec) def matching_specs_from_env(specs): diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py index 97feea89f29..acefcd492f4 100644 --- a/lib/spack/spack/cmd/bootstrap.py +++ b/lib/spack/spack/cmd/bootstrap.py @@ -15,6 +15,7 @@ import spack.bootstrap import spack.bootstrap.config import spack.bootstrap.core +import spack.concretize import spack.config import spack.mirrors.utils import spack.spec @@ -398,7 +399,7 @@ def _mirror(args): llnl.util.tty.msg(msg.format(spec_str, mirror_dir)) # Suppress tty from the call below for terser messages llnl.util.tty.set_msg_enabled(False) - spec = spack.spec.Spec(spec_str).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(spec_str)) for node in spec.traverse(): spack.mirrors.utils.create(mirror_dir, [node]) llnl.util.tty.set_msg_enabled(True) diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py index 40e2393204b..6932c86d85b 100644 --- a/lib/spack/spack/cmd/buildcache.py +++ b/lib/spack/spack/cmd/buildcache.py @@ -17,6 +17,7 @@ import spack.binary_distribution as bindist import spack.cmd +import spack.concretize import spack.config import spack.deptypes as dt import spack.environment as ev @@ -555,8 +556,7 @@ def check_fn(args: argparse.Namespace): tty.msg("No specs provided, exiting.") return - for spec in specs: - spec.concretize() + specs = [spack.concretize.concretized(s) for s in specs] # Next see if there are any configured binary mirrors configured_mirrors = spack.config.get("mirrors", scope=args.scope) @@ -624,7 +624,7 @@ def save_specfile_fn(args): root = specs[0] if not root.concrete: - root.concretize() + root = spack.concretize.concretized(root) save_dependency_specfiles( root, args.specfile_dir, dependencies=spack.cmd.parse_specs(args.specs) diff --git a/lib/spack/spack/cmd/deprecate.py b/lib/spack/spack/cmd/deprecate.py index f7ecc39312f..e38ecf1e43a 100644 --- a/lib/spack/spack/cmd/deprecate.py +++ b/lib/spack/spack/cmd/deprecate.py @@ -19,6 +19,7 @@ from llnl.util.symlink import symlink import spack.cmd +import spack.concretize import spack.environment as ev import spack.installer import spack.store @@ -104,7 +105,7 @@ def deprecate(parser, args): ) if args.install: - deprecator = specs[1].concretized() + deprecator = spack.concretize.concretized(specs[1]) else: deprecator = spack.cmd.disambiguate_spec(specs[1], env, local=True) diff --git a/lib/spack/spack/cmd/dev_build.py b/lib/spack/spack/cmd/dev_build.py index 696c16f4dcd..17dc6baa088 100644 --- a/lib/spack/spack/cmd/dev_build.py +++ b/lib/spack/spack/cmd/dev_build.py @@ -11,6 +11,7 @@ import spack.build_environment import spack.cmd import spack.cmd.common.arguments +import spack.concretize import spack.config import spack.repo from spack.cmd.common import arguments @@ -115,7 +116,7 @@ def dev_build(self, args): # Forces the build to run out of the source directory. spec.constrain("dev_path=%s" % source_path) - spec.concretize() + spec = spack.concretize.concretized(spec) if spec.installed: tty.error("Already installed in %s" % spec.prefix) diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 5040032f2bc..088d8482876 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -14,6 +14,7 @@ from llnl.util import lang, tty import spack.cmd +import spack.concretize import spack.config import spack.environment as ev import spack.paths @@ -451,7 +452,7 @@ def concrete_specs_from_file(args): else: s = spack.spec.Spec.from_json(f) - concretized = s.concretized() + concretized = spack.concretize.concretized(s) if concretized.dag_hash() != s.dag_hash(): msg = 'skipped invalid file "{0}". ' msg += "The file does not contain a concrete spec." diff --git a/lib/spack/spack/cmd/make_installer.py b/lib/spack/spack/cmd/make_installer.py index dbca577118b..ff4b44c74d9 100644 --- a/lib/spack/spack/cmd/make_installer.py +++ b/lib/spack/spack/cmd/make_installer.py @@ -8,6 +8,7 @@ from llnl.path import convert_to_posix_path +import spack.concretize import spack.paths import spack.util.executable from spack.spec import Spec @@ -66,8 +67,7 @@ def make_installer(parser, args): """ if sys.platform == "win32": output_dir = args.output_dir - cmake_spec = Spec("cmake") - cmake_spec.concretize() + cmake_spec = spack.concretize.concretized(Spec("cmake")) cmake_path = os.path.join(cmake_spec.prefix, "bin", "cmake.exe") cpack_path = os.path.join(cmake_spec.prefix, "bin", "cpack.exe") spack_source = args.spack_source diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py index d2891b1276c..309a82423c1 100644 --- a/lib/spack/spack/cmd/mirror.py +++ b/lib/spack/spack/cmd/mirror.py @@ -493,7 +493,7 @@ def extend_with_additional_versions(specs, num_versions): mirror_specs = spack.mirrors.utils.get_all_versions(specs) else: 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.concretized(x) for x in mirror_specs] return mirror_specs diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 65ad755e7ea..3a374658e0c 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -190,10 +190,49 @@ def _concretize_task(packed_arguments: Tuple[int, str, TestsType]) -> Tuple[int, index, spec_str, tests = packed_arguments with tty.SuppressOutput(msg_enabled=False): start = time.time() - spec = Spec(spec_str).concretized(tests=tests) + spec = concretized(Spec(spec_str), tests=tests) return index, spec, time.time() - start +def concretized(spec: Spec, tests: Union[bool, Iterable[str]] = 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. + """ + spec.replace_hash() + + for node in spec.traverse(): + if not node.name: + raise spack.error.SpecError( + f"Spec {node} has no name; cannot concretize an anonymous spec" + ) + + if spec._concrete: + return spec.copy() + + allow_deprecated = spack.config.get("config:deprecated", False) + solver = spack.solver.asp.Solver() + 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 = 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] + return concretized + + class UnavailableCompilerVersionError(spack.error.SpackError): """Raised when there is no available compiler that satisfies a compiler spec.""" diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 1c5f96ee721..952069cb001 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -59,7 +59,7 @@ import re import socket import warnings -from typing import Any, Callable, Dict, Iterable, List, Match, Optional, Set, Tuple, Union +from typing import Any, Callable, Dict, List, Match, Optional, Set, Tuple, Union import archspec.cpu @@ -73,7 +73,6 @@ import spack import spack.compiler import spack.compilers -import spack.config import spack.deptypes as dt import spack.error import spack.hash_types as ht @@ -82,7 +81,6 @@ import spack.platforms import spack.provider_index import spack.repo -import spack.solver import spack.store import spack.traverse as traverse import spack.util.executable @@ -2830,46 +2828,6 @@ def ensure_no_deprecated(root): msg += " For each package listed, choose another spec\n" raise SpecDeprecatedError(msg) - def concretize(self, tests: Union[bool, Iterable[str]] = False) -> None: - """Concretize the current 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. - """ - import spack.solver.asp - - self.replace_hash() - - 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): """Mark just this spec (not dependencies) concrete.""" if (not value) and self.concrete and self.installed: @@ -2958,21 +2916,6 @@ def _finalize_concretization(self): for spec in self.traverse(): spec._cached_hash(ht.dag_hash) - def concretized(self, tests: Union[bool, Iterable[str]] = False) -> "spack.spec.Spec": - """This is a non-destructive version of concretize(). - - First clones, then returns a concrete version of this package - without modifying this package. - - Args: - 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"): """Return a dictionary that points to all the dependencies in this spec. diff --git a/lib/spack/spack/test/abi_splicing.py b/lib/spack/spack/test/abi_splicing.py index d6476477975..238617dd241 100644 --- a/lib/spack/spack/test/abi_splicing.py +++ b/lib/spack/spack/test/abi_splicing.py @@ -8,6 +8,7 @@ import pytest +import spack.concretize import spack.config import spack.deptypes as dt import spack.solver.asp @@ -22,7 +23,7 @@ def __init__(self, specs: List[str]) -> None: self.concr_specs = [] def __enter__(self): - self.concr_specs = [Spec(s).concretized() for s in self.req_specs] + self.concr_specs = [spack.concretize.concretized(Spec(s)) for s in self.req_specs] for s in self.concr_specs: PackageInstaller([s.package], fake=True, explicit=True).install() @@ -63,13 +64,13 @@ def _has_build_dependency(spec: Spec, name: str): def test_simple_reuse(splicing_setup): with CacheManager(["splice-z@1.0.0+compat"]): spack.config.set("packages", _make_specs_non_buildable(["splice-z"])) - assert Spec("splice-z").concretized().satisfies(Spec("splice-z")) + assert spack.concretize.concretized(Spec("splice-z")).satisfies(Spec("splice-z")) def test_simple_dep_reuse(splicing_setup): with CacheManager(["splice-z@1.0.0+compat"]): spack.config.set("packages", _make_specs_non_buildable(["splice-z"])) - assert Spec("splice-h@1").concretized().satisfies(Spec("splice-h@1")) + assert spack.concretize.concretized(Spec("splice-h@1")).satisfies(Spec("splice-h@1")) def test_splice_installed_hash(splicing_setup): @@ -82,9 +83,9 @@ def test_splice_installed_hash(splicing_setup): spack.config.set("packages", packages_config) goal_spec = Spec("splice-t@1 ^splice-h@1.0.2+compat ^splice-z@1.0.0") with pytest.raises(Exception): - goal_spec.concretized() + spack.concretize.concretized(goal_spec) _enable_splicing() - assert goal_spec.concretized().satisfies(goal_spec) + assert spack.concretize.concretized(goal_spec).satisfies(goal_spec) def test_splice_build_splice_node(splicing_setup): @@ -92,9 +93,9 @@ def test_splice_build_splice_node(splicing_setup): 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") with pytest.raises(Exception): - goal_spec.concretized() + spack.concretize.concretized(goal_spec) _enable_splicing() - assert goal_spec.concretized().satisfies(goal_spec) + assert spack.concretize.concretized(goal_spec).satisfies(goal_spec) def test_double_splice(splicing_setup): @@ -108,9 +109,9 @@ def test_double_splice(splicing_setup): 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") with pytest.raises(Exception): - goal_spec.concretized() + spack.concretize.concretized(goal_spec) _enable_splicing() - assert goal_spec.concretized().satisfies(goal_spec) + assert spack.concretize.concretized(goal_spec).satisfies(goal_spec) # The next two tests are mirrors of one another @@ -127,10 +128,10 @@ def test_virtual_multi_splices_in(splicing_setup): spack.config.set("packages", _make_specs_non_buildable(["depends-on-virtual-with-abi"])) for gs in goal_specs: with pytest.raises(Exception): - Spec(gs).concretized() + spack.concretize.concretized(Spec(gs)) _enable_splicing() for gs in goal_specs: - assert Spec(gs).concretized().satisfies(gs) + assert spack.concretize.concretized(Spec(gs)).satisfies(gs) def test_virtual_multi_can_be_spliced(splicing_setup): @@ -144,12 +145,12 @@ def test_virtual_multi_can_be_spliced(splicing_setup): ] with CacheManager(cache): spack.config.set("packages", _make_specs_non_buildable(["depends-on-virtual-with-abi"])) - with pytest.raises(Exception): - for gs in goal_specs: - Spec(gs).concretized() + for gs in goal_specs: + with pytest.raises(Exception): + spack.concretize.concretized(Spec(gs)) _enable_splicing() for gs in goal_specs: - assert Spec(gs).concretized().satisfies(gs) + assert spack.concretize.concretized(Spec(gs)).satisfies(gs) def test_manyvariant_star_matching_variant_splice(splicing_setup): @@ -167,10 +168,10 @@ def test_manyvariant_star_matching_variant_splice(splicing_setup): spack.config.set("packages", freeze_build_config) for goal in goal_specs: with pytest.raises(Exception): - goal.concretized() + spack.concretize.concretized(goal) _enable_splicing() for goal in goal_specs: - assert goal.concretized().satisfies(goal) + assert spack.concretize.concretized(goal).satisfies(goal) def test_manyvariant_limited_matching(splicing_setup): @@ -189,10 +190,10 @@ def test_manyvariant_limited_matching(splicing_setup): spack.config.set("packages", freeze_build_config) for s in goal_specs: with pytest.raises(Exception): - s.concretized() + spack.concretize.concretized(s) _enable_splicing() for s in goal_specs: - assert s.concretized().satisfies(s) + assert spack.concretize.concretized(s).satisfies(s) def test_external_splice_same_name(splicing_setup): @@ -211,7 +212,7 @@ def test_external_splice_same_name(splicing_setup): spack.config.set("packages", packages_yaml) _enable_splicing() for s in goal_specs: - assert s.concretized().satisfies(s) + assert spack.concretize.concretized(s).satisfies(s) def test_spliced_build_deps_only_in_build_spec(splicing_setup): @@ -220,7 +221,7 @@ def test_spliced_build_deps_only_in_build_spec(splicing_setup): with CacheManager(cache): _enable_splicing() - concr_goal = goal_spec.concretized() + concr_goal = spack.concretize.concretized(goal_spec) build_spec = concr_goal._build_spec # Spec has been spliced assert build_spec is not None @@ -238,7 +239,7 @@ def test_spliced_transitive_dependency(splicing_setup): with CacheManager(cache): spack.config.set("packages", _make_specs_non_buildable(["splice-depends-on-t"])) _enable_splicing() - concr_goal = goal_spec.concretized() + concr_goal = spack.concretize.concretized(goal_spec) # Spec has been spliced assert concr_goal._build_spec is not None assert concr_goal["splice-t"]._build_spec is not None diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py index a029aa4790f..7919589fa82 100644 --- a/lib/spack/spack/test/architecture.py +++ b/lib/spack/spack/test/architecture.py @@ -134,5 +134,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}" ) with spack.concretize.disable_compiler_existence_check(): - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.target == spec["pkg-b"].target == result diff --git a/lib/spack/spack/test/bindist.py b/lib/spack/spack/test/bindist.py index d8383ca0fed..d6e73f300b5 100644 --- a/lib/spack/spack/test/bindist.py +++ b/lib/spack/spack/test/bindist.py @@ -28,6 +28,7 @@ import spack.binary_distribution as bindist import spack.caches import spack.compilers +import spack.concretize import spack.config import spack.fetch_strategy import spack.hooks.sbang as sbang @@ -213,8 +214,9 @@ def test_default_rpaths_create_install_default_layout(temporary_mirror_dir): Test the creation and installation of buildcaches with default rpaths into the default directory layout scheme. """ - gspec, cspec = Spec("garply").concretized(), Spec("corge").concretized() - sy_spec = Spec("symly").concretized() + gspec = spack.concretize.concretized(Spec("garply")) + cspec = spack.concretize.concretized(Spec("corge")) + sy_spec = spack.concretize.concretized(Spec("symly")) # Install 'corge' without using a cache install_cmd("--no-cache", cspec.name) @@ -261,9 +263,9 @@ def test_default_rpaths_install_nondefault_layout(temporary_mirror_dir): Test the creation and installation of buildcaches with default rpaths into the non-default directory layout scheme. """ - cspec = Spec("corge").concretized() + cspec = spack.concretize.concretized(Spec("corge")) # This guy tests for symlink relocation - sy_spec = Spec("symly").concretized() + sy_spec = spack.concretize.concretized(Spec("symly")) # Install some packages with dependent packages # test install in non-default install path scheme @@ -284,7 +286,8 @@ def test_relative_rpaths_install_default_layout(temporary_mirror_dir): Test the creation and installation of buildcaches with relative rpaths into the default directory layout scheme. """ - gspec, cspec = Spec("garply").concretized(), Spec("corge").concretized() + gspec = spack.concretize.concretized(Spec("garply")) + cspec = spack.concretize.concretized(Spec("corge")) # Install buildcache created with relativized rpaths buildcache_cmd("install", "-uf", cspec.name) @@ -313,7 +316,7 @@ def test_relative_rpaths_install_nondefault(temporary_mirror_dir): Test the installation of buildcaches with relativized rpaths into the non-default directory layout scheme. """ - cspec = Spec("corge").concretized() + cspec = spack.concretize.concretized(Spec("corge")) # Test install in non-default install path scheme and relative path buildcache_cmd("install", "-uf", cspec.name) @@ -366,7 +369,8 @@ def test_built_spec_cache(temporary_mirror_dir): that cache from a buildcache index.""" buildcache_cmd("list", "-a", "-l") - gspec, cspec = Spec("garply").concretized(), Spec("corge").concretized() + gspec = spack.concretize.concretized(Spec("garply")) + cspec = spack.concretize.concretized(Spec("corge")) for s in [gspec, cspec]: results = bindist.get_mirrors_for_spec(s) @@ -389,7 +393,7 @@ def test_spec_needs_rebuild(monkeypatch, tmpdir): mirror_dir = tmpdir.join("mirror_dir") mirror_url = url_util.path_to_file_url(mirror_dir.strpath) - s = Spec("libdwarf").concretized() + s = spack.concretize.concretized(Spec("libdwarf")) # Install a package install_cmd(s.name) @@ -418,7 +422,7 @@ def test_generate_index_missing(monkeypatch, tmpdir, mutable_config): mirror_url = url_util.path_to_file_url(mirror_dir.strpath) spack.config.set("mirrors", {"test": mirror_url}) - s = Spec("libdwarf").concretized() + s = spack.concretize.concretized(Spec("libdwarf")) # Install a package install_cmd("--no-cache", s.name) @@ -508,7 +512,7 @@ def test_update_sbang(tmpdir, temporary_mirror): """ spec_str = "old-sbang" # Concretize a package with some old-fashioned sbang lines. - old_spec = Spec(spec_str).concretized() + old_spec = spack.concretize.concretized(Spec(spec_str)) old_spec_hash_str = "/{0}".format(old_spec.dag_hash()) # Need a fake mirror with *function* scope. @@ -529,7 +533,7 @@ def test_update_sbang(tmpdir, temporary_mirror): # Switch the store to the new install tree locations newtree_dir = tmpdir.join("newtree") with spack.store.use_store(str(newtree_dir)): - new_spec = Spec("old-sbang").concretized() + new_spec = spack.concretize.concretized(Spec("old-sbang")) assert new_spec.dag_hash() == old_spec.dag_hash() # Install package from buildcache diff --git a/lib/spack/spack/test/build_distribution.py b/lib/spack/spack/test/build_distribution.py index f2976da8ae9..4c12d9e34a5 100644 --- a/lib/spack/spack/test/build_distribution.py +++ b/lib/spack/spack/test/build_distribution.py @@ -9,6 +9,7 @@ import pytest import spack.binary_distribution as bd +import spack.concretize import spack.mirrors.mirror import spack.spec from spack.installer import PackageInstaller @@ -17,7 +18,7 @@ def test_build_tarball_overwrite(install_mockery, mock_fetch, monkeypatch, tmp_path): - spec = spack.spec.Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) PackageInstaller([spec.package], fake=True).install() specs = [spec] diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py index dd42d5cb458..41b969a0c5a 100644 --- a/lib/spack/spack/test/build_environment.py +++ b/lib/spack/spack/test/build_environment.py @@ -17,6 +17,7 @@ import spack.build_environment import spack.compiler import spack.compilers +import spack.concretize import spack.config import spack.deptypes as dt import spack.package_base @@ -164,8 +165,7 @@ def test_static_to_shared_library(build_environment): @pytest.mark.regression("8345") @pytest.mark.usefixtures("config", "mock_packages") def test_cc_not_changed_by_modules(monkeypatch, working_env): - s = spack.spec.Spec("cmake") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("cmake")) pkg = s.package def _set_wrong_cc(x): @@ -185,7 +185,7 @@ def test_setup_dependent_package_inherited_modules( working_env, mock_packages, install_mockery, mock_fetch ): # This will raise on regression - s = spack.spec.Spec("cmake-client-inheritor").concretized() + s = spack.concretize.concretized(spack.spec.Spec("cmake-client-inheritor")) PackageInstaller([s.package]).install() @@ -278,7 +278,7 @@ def platform_pathsep(pathlist): return convert_to_platform_path(pathlist) # Monkeypatch a pkg.compiler.environment with the required modifications - pkg = spack.spec.Spec("cmake").concretized().package + pkg = spack.concretize.concretized(spack.spec.Spec("cmake")).package monkeypatch.setattr(pkg.compiler, "environment", modifications) # Trigger the modifications spack.build_environment.setup_package(pkg, False) @@ -302,7 +302,7 @@ def custom_env(pkg, env): env.prepend_path("PATH", test_path) env.append_flags("ENV_CUSTOM_CC_FLAGS", "--custom-env-flag1") - pkg = spack.spec.Spec("cmake").concretized().package + pkg = spack.concretize.concretized(spack.spec.Spec("cmake")).package monkeypatch.setattr(pkg.compiler, "setup_custom_environment", custom_env) spack.build_environment.setup_package(pkg, False) @@ -323,7 +323,7 @@ def test_external_config_env(mock_packages, mutable_config, working_env): } spack.config.set("packages:cmake", cmake_config) - cmake_client = spack.spec.Spec("cmake-client").concretized() + cmake_client = spack.concretize.concretized(spack.spec.Spec("cmake-client")) spack.build_environment.setup_package(cmake_client.package, False) assert os.environ["TEST_ENV_VAR_SET"] == "yes it's set" @@ -331,8 +331,7 @@ def test_external_config_env(mock_packages, mutable_config, working_env): @pytest.mark.regression("9107") def test_spack_paths_before_module_paths(config, mock_packages, monkeypatch, working_env): - s = spack.spec.Spec("cmake") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("cmake")) pkg = s.package module_path = os.path.join("path", "to", "module") @@ -353,8 +352,7 @@ def _set_wrong_cc(x): def test_package_inheritance_module_setup(config, mock_packages, working_env): - s = spack.spec.Spec("multimodule-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("multimodule-inheritance")) pkg = s.package spack.build_environment.setup_package(pkg, False) @@ -388,8 +386,7 @@ def test_wrapper_variables( not in cuda_include_dirs ) - root = spack.spec.Spec("dt-diamond") - root.concretize() + root = spack.concretize.concretized(spack.spec.Spec("dt-diamond")) for s in root.traverse(): s.prefix = "/{0}-prefix/".format(s.name) @@ -454,7 +451,7 @@ def test_external_prefixes_last(mutable_config, mock_packages, working_env, monk """ ) spack.config.set("packages", cfg_data) - top = spack.spec.Spec("dt-diamond").concretized() + top = spack.concretize.concretized(spack.spec.Spec("dt-diamond")) def _trust_me_its_a_dir(path): return True @@ -501,8 +498,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): # Pick a random package to be able to set compiler's variables - s = spack.spec.Spec("cmake") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("cmake")) pkg = s.package env = EnvironmentModifications() @@ -534,7 +530,7 @@ def setup_dependent_package(module, dependent_spec): assert dependent_module.ninja is not None dependent_spec.package.test_attr = True - externaltool = spack.spec.Spec("externaltest").concretized() + externaltool = spack.concretize.concretized(spack.spec.Spec("externaltest")) monkeypatch.setattr( externaltool["externaltool"].package, "setup_dependent_package", setup_dependent_package ) @@ -729,7 +725,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 define them instead as a property on the package instance. """ - root = spack.spec.Spec("mpileaks").concretized() + root = spack.concretize.concretized(spack.spec.Spec("mpileaks")) 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. diff --git a/lib/spack/spack/test/build_systems.py b/lib/spack/spack/test/build_systems.py index 47173b7dfc7..257e33e70b4 100644 --- a/lib/spack/spack/test/build_systems.py +++ b/lib/spack/spack/test/build_systems.py @@ -16,6 +16,7 @@ import spack.build_systems.autotools import spack.build_systems.cmake import spack.builder +import spack.concretize import spack.environment import spack.error import spack.paths @@ -145,7 +146,7 @@ def test_none_is_allowed(self, default_mock_concretization): def test_libtool_archive_files_are_deleted_by_default(self, mutable_database): # Install a package that creates a mock libtool archive - s = Spec("libtool-deletion").concretized() + s = spack.concretize.concretized(Spec("libtool-deletion")) PackageInstaller([s.package], explicit=True).install() # Assert the libtool archive is not there and we have @@ -160,7 +161,7 @@ def test_libtool_archive_files_might_be_installed_on_demand( ): # Install a package that creates a mock libtool archive, # patch its package to preserve the installation - s = Spec("libtool-deletion").concretized() + s = spack.concretize.concretized(Spec("libtool-deletion")) monkeypatch.setattr( type(spack.builder.create(s.package)), "install_libtool_archives", True ) @@ -174,7 +175,9 @@ def test_autotools_gnuconfig_replacement(self, mutable_database): Tests whether only broken config.sub and config.guess are replaced with files from working alternatives from the gnuconfig package. """ - s = Spec("autotools-config-replacement +patch_config_files +gnuconfig").concretized() + s = spack.concretize.concretized( + Spec("autotools-config-replacement +patch_config_files +gnuconfig") + ) PackageInstaller([s.package]).install() with open(os.path.join(s.prefix.broken, "config.sub")) as f: @@ -193,7 +196,9 @@ def test_autotools_gnuconfig_replacement_disabled(self, mutable_database): """ Tests whether disabling patch_config_files """ - s = Spec("autotools-config-replacement ~patch_config_files +gnuconfig").concretized() + s = spack.concretize.concretized( + Spec("autotools-config-replacement ~patch_config_files +gnuconfig") + ) PackageInstaller([s.package]).install() with open(os.path.join(s.prefix.broken, "config.sub")) as f: @@ -218,8 +223,9 @@ def test_autotools_gnuconfig_replacement_no_gnuconfig(self, mutable_database, mo enabled, but gnuconfig is not listed as a direct build dependency. """ monkeypatch.setattr(spack.platforms.test.Test, "default", "x86_64") - s = Spec("autotools-config-replacement +patch_config_files ~gnuconfig") - s.concretize() + s = spack.concretize.concretized( + Spec("autotools-config-replacement +patch_config_files ~gnuconfig") + ) msg = "Cannot patch config files: missing dependencies: gnuconfig" with pytest.raises(ChildError, match=msg): @@ -299,7 +305,7 @@ def test_define(self, default_mock_concretization): assert define("SINGLE", "red") == "-DSINGLE:STRING=red" def test_define_from_variant(self): - s = Spec("cmake-client multi=up,right ~truthy single=red").concretized() + s = spack.concretize.concretized(Spec("cmake-client multi=up,right ~truthy single=red")) arg = s.package.define_from_variant("MULTI") assert arg == "-DMULTI:STRING=right;up" diff --git a/lib/spack/spack/test/builder.py b/lib/spack/spack/test/builder.py index ab611dbaec6..2576d6d998e 100644 --- a/lib/spack/spack/test/builder.py +++ b/lib/spack/spack/test/builder.py @@ -9,6 +9,7 @@ from llnl.util.filesystem import touch import spack.builder +import spack.concretize import spack.paths import spack.repo import spack.spec @@ -79,7 +80,7 @@ def builder_test_repository(): @pytest.mark.disable_clean_stage_check def test_callbacks_and_installation_procedure(spec_str, expected_values, working_env): """Test the correct execution of callbacks and installation procedures for packages.""" - s = spack.spec.Spec(spec_str).concretized() + s = spack.concretize.concretized(spack.spec.Spec(spec_str)) builder = spack.builder.create(s.package) for phase_fn in builder: phase_fn.execute() @@ -102,7 +103,7 @@ def test_callbacks_and_installation_procedure(spec_str, expected_values, working ], ) def test_old_style_compatibility_with_super(spec_str, method_name, expected): - s = spack.spec.Spec(spec_str).concretized() + s = spack.concretize.concretized(spack.spec.Spec(spec_str)) builder = spack.builder.create(s.package) value = getattr(builder, method_name)() assert value == expected @@ -113,7 +114,7 @@ def test_old_style_compatibility_with_super(spec_str, method_name, expected): @pytest.mark.usefixtures("builder_test_repository", "config", "working_env") @pytest.mark.disable_clean_stage_check def test_build_time_tests_are_executed_from_default_builder(): - s = spack.spec.Spec("old-style-autotools").concretized() + s = spack.concretize.concretized(spack.spec.Spec("old-style-autotools")) builder = spack.builder.create(s.package) builder.pkg.run_tests = True for phase_fn in builder: @@ -127,7 +128,7 @@ def test_build_time_tests_are_executed_from_default_builder(): @pytest.mark.usefixtures("builder_test_repository", "config", "working_env") def test_monkey_patching_wrapped_pkg(): """Confirm 'run_tests' is accessible through wrappers.""" - s = spack.spec.Spec("old-style-autotools").concretized() + s = spack.concretize.concretized(spack.spec.Spec("old-style-autotools")) builder = spack.builder.create(s.package) assert s.package.run_tests is False assert builder.pkg.run_tests is False @@ -142,7 +143,7 @@ def test_monkey_patching_wrapped_pkg(): @pytest.mark.usefixtures("builder_test_repository", "config", "working_env") def test_monkey_patching_test_log_file(): """Confirm 'test_log_file' is accessible through wrappers.""" - s = spack.spec.Spec("old-style-autotools").concretized() + s = spack.concretize.concretized(spack.spec.Spec("old-style-autotools")) builder = spack.builder.create(s.package) s.package.tester.test_log_file = "/some/file" @@ -155,7 +156,7 @@ def test_monkey_patching_test_log_file(): @pytest.mark.not_on_windows("Does not run on windows") def test_install_time_test_callback(tmpdir, config, mock_packages, mock_stage): """Confirm able to run stand-alone test as a post-install callback.""" - s = spack.spec.Spec("py-test-callback").concretized() + s = spack.concretize.concretized(spack.spec.Spec("py-test-callback")) builder = spack.builder.create(s.package) builder.pkg.run_tests = True s.package.tester.test_log_file = tmpdir.join("install_test.log") @@ -175,7 +176,7 @@ def test_mixins_with_builders(working_env): """Tests that run_after and run_before callbacks are accumulated correctly, when mixins are used with builders. """ - s = spack.spec.Spec("builder-and-mixins").concretized() + s = spack.concretize.concretized(spack.spec.Spec("builder-and-mixins")) builder = spack.builder.create(s.package) # Check that callbacks added by the mixin are in the list diff --git a/lib/spack/spack/test/buildrequest.py b/lib/spack/spack/test/buildrequest.py index e5bf9d3d6ee..3155a015b21 100644 --- a/lib/spack/spack/test/buildrequest.py +++ b/lib/spack/spack/test/buildrequest.py @@ -5,6 +5,7 @@ import pytest +import spack.concretize import spack.deptypes as dt import spack.installer as inst import spack.repo @@ -22,8 +23,7 @@ def test_build_request_errors(install_mockery): def test_build_request_basics(install_mockery): - spec = spack.spec.Spec("dependent-install") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("dependent-install")) assert spec.concrete # Ensure key properties match expectations @@ -40,8 +40,7 @@ def test_build_request_basics(install_mockery): def test_build_request_strings(install_mockery): """Tests of BuildRequest repr and str for coverage purposes.""" # Using a package with one dependency - spec = spack.spec.Spec("dependent-install") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("dependent-install")) assert spec.concrete # Ensure key properties match expectations @@ -73,7 +72,7 @@ def test_build_request_deptypes( package_deptypes, dependencies_deptypes, ): - s = spack.spec.Spec("dependent-install").concretized() + s = spack.concretize.concretized(spack.spec.Spec("dependent-install")) build_request = inst.BuildRequest( s.package, diff --git a/lib/spack/spack/test/buildtask.py b/lib/spack/spack/test/buildtask.py index 3e90c9ad7e3..7c2bcb026ab 100644 --- a/lib/spack/spack/test/buildtask.py +++ b/lib/spack/spack/test/buildtask.py @@ -5,6 +5,7 @@ import pytest +import spack.concretize import spack.error import spack.installer as inst import spack.repo @@ -25,7 +26,7 @@ def test_build_task_errors(install_mockery): inst.BuildTask(pkg_cls(spec), None) # Using a concretized package now means the request argument is checked. - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.concrete with pytest.raises(TypeError, match="is not a valid build request"): @@ -48,8 +49,7 @@ def test_build_task_errors(install_mockery): def test_build_task_basics(install_mockery): - spec = spack.spec.Spec("dependent-install") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("dependent-install")) assert spec.concrete # Ensure key properties match expectations @@ -70,8 +70,7 @@ def test_build_task_basics(install_mockery): def test_build_task_strings(install_mockery): """Tests of build_task repr and str for coverage purposes.""" # Using a package with one dependency - spec = spack.spec.Spec("dependent-install") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("dependent-install")) assert spec.concrete # Ensure key properties match expectations diff --git a/lib/spack/spack/test/ci.py b/lib/spack/spack/test/ci.py index 0c9a10814a2..748e37e8e33 100644 --- a/lib/spack/spack/test/ci.py +++ b/lib/spack/spack/test/ci.py @@ -10,6 +10,7 @@ import llnl.util.filesystem as fs import spack.ci as ci +import spack.concretize import spack.environment as ev import spack.error import spack.paths as spack_paths @@ -326,7 +327,7 @@ def test_ci_run_standalone_tests_not_installed_junit( log_file = tmp_path / "junit.xml" args = { "log_file": str(log_file), - "job_spec": spack.spec.Spec("printing-package").concretized(), + "job_spec": spack.concretize.concretized(spack.spec.Spec("printing-package")), "repro_dir": str(repro_dir), "fail_fast": True, } @@ -345,7 +346,7 @@ def test_ci_run_standalone_tests_not_installed_cdash( log_file = tmp_path / "junit.xml" args = { "log_file": str(log_file), - "job_spec": spack.spec.Spec("printing-package").concretized(), + "job_spec": spack.concretize.concretized(spack.spec.Spec("printing-package")), "repro_dir": str(repro_dir), } @@ -378,7 +379,7 @@ def test_ci_run_standalone_tests_not_installed_cdash( def test_ci_skipped_report(tmpdir, mock_packages, config): """Test explicit skipping of report as well as CI's 'package' arg.""" pkg = "trivial-smoke-test" - spec = spack.spec.Spec(pkg).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(pkg)) ci_cdash = { "url": "file://fake", "build-group": "fake-group", diff --git a/lib/spack/spack/test/cmd/bootstrap.py b/lib/spack/spack/test/cmd/bootstrap.py index a4448253031..00dd6b978f4 100644 --- a/lib/spack/spack/test/cmd/bootstrap.py +++ b/lib/spack/spack/test/cmd/bootstrap.py @@ -11,11 +11,11 @@ import spack.bootstrap import spack.bootstrap.core +import spack.concretize import spack.config import spack.environment as ev import spack.main import spack.mirrors.utils -import spack.spec _bootstrap = spack.main.SpackCommand("bootstrap") @@ -184,7 +184,7 @@ def test_bootstrap_mirror_metadata(mutable_config, linux_os, monkeypatch, tmpdir """ old_create = spack.mirrors.utils.create 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, "concretized", lambda p: p) # Create the mirror in a temporary folder compilers = [ diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py index 22b63e1e2a7..2f4b972bc43 100644 --- a/lib/spack/spack/test/cmd/buildcache.py +++ b/lib/spack/spack/test/cmd/buildcache.py @@ -13,6 +13,7 @@ import spack.binary_distribution import spack.cmd.buildcache +import spack.concretize import spack.environment as ev import spack.error import spack.main @@ -82,7 +83,7 @@ def tests_buildcache_create(install_mockery, mock_fetch, monkeypatch, tmpdir): buildcache("push", "--unsigned", str(tmpdir), pkg) - spec = Spec(pkg).concretized() + spec = spack.concretize.concretized(Spec(pkg)) tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack") tarball = spack.binary_distribution.tarball_name(spec, ".spec.json") assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path)) @@ -102,7 +103,7 @@ def tests_buildcache_create_env( buildcache("push", "--unsigned", str(tmpdir)) - spec = Spec(pkg).concretized() + spec = spack.concretize.concretized(Spec(pkg)) tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack") tarball = spack.binary_distribution.tarball_name(spec, ".spec.json") assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path)) @@ -146,7 +147,7 @@ def test_update_key_index( gpg("create", "Test Signing Key", "nobody@nowhere.com") - s = Spec("libdwarf").concretized() + s = spack.concretize.concretized(Spec("libdwarf")) # Install a package install(s.name) @@ -176,7 +177,7 @@ def test_buildcache_autopush(tmp_path, install_mockery, mock_fetch): mirror("add", "--unsigned", "mirror", mirror_dir.as_uri()) mirror("add", "--autopush", "--unsigned", "mirror-autopush", mirror_autopush_dir.as_uri()) - s = Spec("libdwarf").concretized() + s = spack.concretize.concretized(Spec("libdwarf")) # Install and generate build cache index PackageInstaller([s.package], explicit=True).install() @@ -220,7 +221,7 @@ def verify_mirror_contents(): assert False # Install a package and put it in the buildcache - s = Spec(out_env_pkg).concretized() + s = spack.concretize.concretized(Spec(out_env_pkg)) install(s.name) buildcache("push", "-u", "-f", src_mirror_url, s.name) @@ -330,7 +331,7 @@ def test_buildcache_create_install( buildcache("push", "--unsigned", str(tmpdir), pkg) - spec = Spec(pkg).concretized() + spec = spack.concretize.concretized(Spec(pkg)) tarball_path = spack.binary_distribution.tarball_path_name(spec, ".spack") tarball = spack.binary_distribution.tarball_name(spec, ".spec.json") assert os.path.exists(os.path.join(str(tmpdir), "build_cache", tarball_path)) @@ -451,7 +452,7 @@ def test_push_and_install_with_mirror_marked_unsigned_does_not_require_extra_fla def test_skip_no_redistribute(mock_packages, config): - specs = list(Spec("no-redistribute-dependent").concretized().traverse()) + specs = list(spack.concretize.concretized(Spec("no-redistribute-dependent")).traverse()) filtered = spack.cmd.buildcache._skip_no_redistribute_for_public(specs) assert not any(s.name == "no-redistribute" for s in filtered) assert any(s.name == "no-redistribute-dependent" for s in filtered) @@ -491,7 +492,7 @@ def test_push_without_build_deps(tmp_path, temporary_store, mock_packages, mutab mirror("add", "--unsigned", "my-mirror", str(tmp_path)) - s = spack.spec.Spec("dtrun3").concretized() + s = spack.concretize.concretized(spack.spec.Spec("dtrun3")) PackageInstaller([s.package], explicit=True, fake=True).install() s["dtbuild3"].package.do_uninstall() diff --git a/lib/spack/spack/test/cmd/checksum.py b/lib/spack/spack/test/cmd/checksum.py index 6c20caff887..6cfbda88c98 100644 --- a/lib/spack/spack/test/cmd/checksum.py +++ b/lib/spack/spack/test/cmd/checksum.py @@ -8,6 +8,7 @@ import pytest import spack.cmd.checksum +import spack.concretize import spack.error import spack.package_base import spack.repo @@ -309,7 +310,7 @@ def test_checksum_url(mock_packages, config): def test_checksum_verification_fails(default_mock_concretization, capsys, can_fetch_versions): - spec = spack.spec.Spec("zlib").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("zlib")) pkg = spec.package versions = list(pkg.versions.keys()) version_hashes = {versions[0]: "abadhash", Version("0.1"): "123456789"} diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index bc50ca683f7..5dbbc3cdcc3 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -19,6 +19,7 @@ import spack.ci as ci import spack.cmd import spack.cmd.ci +import spack.concretize import spack.environment as ev import spack.hash_types as ht import spack.main @@ -145,7 +146,7 @@ def test_specs_staging(config, tmpdir): builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)]) with repo.use_repositories(builder.root): - spec_a = Spec("pkg-a").concretized() + spec_a = spack.concretize.concretized(Spec("pkg-a")) spec_a_label = ci._spec_ci_label(spec_a) spec_b_label = ci._spec_ci_label(spec_a["pkg-b"]) @@ -1108,7 +1109,7 @@ def test_ci_rebuild_index( with working_dir(tmp_path): env_cmd("create", "test", "./spack.yaml") with ev.read("test"): - concrete_spec = Spec("callpath").concretized() + concrete_spec = spack.concretize.concretized(Spec("callpath")) with open(tmp_path / "spec.json", "w") as f: f.write(concrete_spec.to_json(hash=ht.dag_hash)) @@ -1229,12 +1230,10 @@ def test_ci_generate_read_broken_specs_url( ci_base_environment, ): """Verify that `broken-specs-url` works as intended""" - spec_a = Spec("pkg-a") - spec_a.concretize() + spec_a = spack.concretize.concretized(Spec("pkg-a")) a_dag_hash = spec_a.dag_hash() - spec_flattendeps = Spec("flatten-deps") - spec_flattendeps.concretize() + spec_flattendeps = spack.concretize.concretized(Spec("flatten-deps")) flattendeps_dag_hash = spec_flattendeps.dag_hash() broken_specs_url = tmp_path.as_uri() @@ -1585,8 +1584,7 @@ def dynamic_mapping_setup(tmpdir): """ ) - spec_a = Spec("pkg-a") - spec_a.concretize() + spec_a = spack.concretize.concretized(Spec("pkg-a")) return ci.get_job_name(spec_a) diff --git a/lib/spack/spack/test/cmd/clean.py b/lib/spack/spack/test/cmd/clean.py index 8b671e495ee..38bc38b9c19 100644 --- a/lib/spack/spack/test/cmd/clean.py +++ b/lib/spack/spack/test/cmd/clean.py @@ -11,10 +11,10 @@ import spack.caches import spack.cmd.clean +import spack.concretize import spack.environment as ev import spack.main import spack.package_base -import spack.spec import spack.stage import spack.store @@ -78,7 +78,7 @@ def test_env_aware_clean(mock_stage, install_mockery, mutable_mock_env_path, mon def fail(*args, **kwargs): raise Exception("This should not have been called") - monkeypatch.setattr(spack.spec.Spec, "concretize", fail) + monkeypatch.setattr(spack.concretize, "concretized", fail) with e: clean("mpileaks") diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py index 93d7c70483a..73c0d248bc1 100644 --- a/lib/spack/spack/test/cmd/config.py +++ b/lib/spack/spack/test/cmd/config.py @@ -9,6 +9,7 @@ import llnl.util.filesystem as fs +import spack.concretize import spack.config import spack.database import spack.environment as ev @@ -594,8 +595,7 @@ def test_config_prefer_upstream( 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"]: - dep = spack.spec.Spec(spec) - dep.concretize() + dep = spack.concretize.concretized(spack.spec.Spec(spec)) prepared_db.add(dep) downstream_db_root = str(tmpdir_factory.mktemp("mock_downstream_db_root")) diff --git a/lib/spack/spack/test/cmd/deprecate.py b/lib/spack/spack/test/cmd/deprecate.py index 89e07bd04bb..dba66a1d0ac 100644 --- a/lib/spack/spack/test/cmd/deprecate.py +++ b/lib/spack/spack/test/cmd/deprecate.py @@ -5,6 +5,7 @@ import pytest +import spack.concretize import spack.spec import spack.store from spack.enums import InstallRecordStatus @@ -67,8 +68,8 @@ def test_deprecate_deps(mock_packages, mock_archive, mock_fetch, install_mockery install("libdwarf@20130729 ^libelf@0.8.13") install("libdwarf@20130207 ^libelf@0.8.10") - new_spec = spack.spec.Spec("libdwarf@20130729^libelf@0.8.13").concretized() - old_spec = spack.spec.Spec("libdwarf@20130207^libelf@0.8.10").concretized() + new_spec = spack.concretize.concretized(spack.spec.Spec("libdwarf@20130729^libelf@0.8.13")) + old_spec = spack.concretize.concretized(spack.spec.Spec("libdwarf@20130207^libelf@0.8.10")) all_installed = spack.store.STORE.db.query() @@ -108,12 +109,12 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, i install("libelf@0.8.12") install("libelf@0.8.10") - deprecated_spec = spack.spec.Spec("libelf@0.8.10").concretized() + deprecated_spec = spack.concretize.concretized(spack.spec.Spec("libelf@0.8.10")) deprecate("-y", "libelf@0.8.10", "libelf@0.8.12") deprecator = spack.store.STORE.db.deprecator(deprecated_spec) - assert deprecator == spack.spec.Spec("libelf@0.8.12").concretized() + assert deprecator == spack.concretize.concretized(spack.spec.Spec("libelf@0.8.12")) deprecate("-y", "libelf@0.8.10", "libelf@0.8.13") @@ -123,7 +124,7 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, i assert len(all_available) == 3 deprecator = spack.store.STORE.db.deprecator(deprecated_spec) - assert deprecator == spack.spec.Spec("libelf@0.8.13").concretized() + assert deprecator == spack.concretize.concretized(spack.spec.Spec("libelf@0.8.13")) def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_mockery): @@ -133,9 +134,9 @@ def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_m install("libelf@0.8.12") install("libelf@0.8.10") - first_deprecated_spec = spack.spec.Spec("libelf@0.8.10").concretized() - second_deprecated_spec = spack.spec.Spec("libelf@0.8.12").concretized() - final_deprecator = spack.spec.Spec("libelf@0.8.13").concretized() + first_deprecated_spec = spack.concretize.concretized(spack.spec.Spec("libelf@0.8.10")) + second_deprecated_spec = spack.concretize.concretized(spack.spec.Spec("libelf@0.8.12")) + final_deprecator = spack.concretize.concretized(spack.spec.Spec("libelf@0.8.13")) deprecate("-y", "libelf@0.8.10", "libelf@0.8.12") @@ -165,7 +166,7 @@ def test_concretize_deprecated(mock_packages, mock_archive, mock_fetch, install_ spec = spack.spec.Spec("libelf@0.8.10") with pytest.raises(spack.spec.SpecDeprecatedError): - spec.concretize() + spack.concretize.concretized(spec) @pytest.mark.usefixtures("mock_packages", "mock_archive", "mock_fetch", "install_mockery") diff --git a/lib/spack/spack/test/cmd/dev_build.py b/lib/spack/spack/test/cmd/dev_build.py index c335ea0ccfd..002c5d28aa1 100644 --- a/lib/spack/spack/test/cmd/dev_build.py +++ b/lib/spack/spack/test/cmd/dev_build.py @@ -9,6 +9,7 @@ import llnl.util.filesystem as fs +import spack.concretize import spack.environment as ev import spack.error import spack.repo @@ -24,7 +25,9 @@ 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.concretized( + spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}") + ) assert "dev_path" in spec.variants @@ -42,7 +45,9 @@ def test_dev_build_basics(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.concretized( + spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}") + ) with tmpdir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -58,7 +63,9 @@ def test_dev_build_before(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.concretized( + spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}") + ) with tmpdir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -76,7 +83,9 @@ def test_dev_build_until(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 - spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}").concretized() + spec = spack.concretize.concretized( + spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}") + ) with tmpdir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -94,7 +103,9 @@ def test_dev_build_until_last_phase(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.concretized( + spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={tmpdir}") + ) with tmpdir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -130,8 +141,9 @@ def test_dev_build_drop_in(tmpdir, mock_packages, monkeypatch, 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.concretize() + spec = spack.concretize.concretized( + spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir) + ) with tmpdir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -173,8 +185,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.""" # setup dev-build-test-install package for dev build build_dir = tmpdir.mkdir("build") - spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir) - spec.concretize() + spec = spack.concretize.concretized( + spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir) + ) with build_dir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -209,8 +222,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).""" # setup dev-build-test-install package for dev build build_dir = tmpdir.mkdir("build") - spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={build_dir}") - spec.concretize() + spec = spack.concretize.concretized( + 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 monkeypatch.setenv("CUSTOM_BUILD_PATH", build_dir) @@ -247,8 +261,9 @@ def test_dev_build_env_version_mismatch(tmpdir, install_mockery, mutable_mock_en """Test Spack constraints concretization by develop specs.""" # setup dev-build-test-install package for dev build build_dir = tmpdir.mkdir("build") - spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir) - spec.concretize() + spec = spack.concretize.concretized( + spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % tmpdir) + ) with build_dir.as_cwd(): with open(spec.package.filename, "w") as f: @@ -328,8 +343,8 @@ def test_dev_build_multiple(tmpdir, install_mockery, mutable_mock_env_path, mock with ev.read("test"): # Do concretization inside environment for dev info # These specs are the source of truth to compare against the installs - leaf_spec.concretize() - root_spec.concretize() + leaf_spec = spack.concretize.concretized(leaf_spec) + root_spec = spack.concretize.concretized(root_spec) # Do install install() @@ -375,8 +390,8 @@ def test_dev_build_env_dependency(tmpdir, install_mockery, mock_fetch, mutable_m # concretize in the environment to get the dev build info # equivalent to setting dev_build and dev_path variants # on all specs above - spec.concretize() - dep_spec.concretize() + spec = spack.concretize.concretized(spec) + dep_spec = spack.concretize.concretized(dep_spec) install() # Ensure that both specs installed properly @@ -400,8 +415,9 @@ def test_dev_build_rebuild_on_source_changes( """ # setup dev-build-test-install package for dev build build_dir = tmpdir.mkdir("build") - spec = spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir) - spec.concretize() + spec = spack.concretize.concretized( + spack.spec.Spec("dev-build-test-install@0.0.0 dev_path=%s" % build_dir) + ) def reset_string(): with build_dir.as_cwd(): diff --git a/lib/spack/spack/test/cmd/develop.py b/lib/spack/spack/test/cmd/develop.py index c0cbb003ec1..e0ee1b00044 100644 --- a/lib/spack/spack/test/cmd/develop.py +++ b/lib/spack/spack/test/cmd/develop.py @@ -9,6 +9,7 @@ import llnl.util.filesystem as fs +import spack.concretize import spack.config import spack.environment as ev import spack.package_base @@ -139,7 +140,8 @@ def check_path(stage, dest): self.check_develop(e, spack.spec.Spec("mpich@=1.0"), path) # Check modifications actually worked - assert spack.spec.Spec("mpich@1.0").concretized().satisfies("dev_path=%s" % abspath) + result = spack.concretize.concretized(spack.spec.Spec("mpich@1.0")) + assert result.satisfies("dev_path=%s" % abspath) def test_develop_canonicalize_path_no_args(self, monkeypatch): env("create", "test") @@ -166,7 +168,8 @@ def check_path(stage, dest): self.check_develop(e, spack.spec.Spec("mpich@=1.0"), path) # Check modifications actually worked - assert spack.spec.Spec("mpich@1.0").concretized().satisfies("dev_path=%s" % abspath) + result = spack.concretize.concretized(spack.spec.Spec("mpich@1.0")) + assert result.satisfies("dev_path=%s" % abspath) def _git_commit_list(git_repo_dir): @@ -191,7 +194,7 @@ def test_develop_full_git_repo( spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False ) - spec = spack.spec.Spec("git-test-commit@1.2").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("git-test-commit@1.2")) try: spec.package.do_stage() commits = _git_commit_list(spec.package.stage[0].source_path) diff --git a/lib/spack/spack/test/cmd/diff.py b/lib/spack/spack/test/cmd/diff.py index 125a6462535..b3d6854a791 100644 --- a/lib/spack/spack/test/cmd/diff.py +++ b/lib/spack/spack/test/cmd/diff.py @@ -6,6 +6,7 @@ import pytest import spack.cmd.diff +import spack.concretize import spack.main import spack.repo import spack.spec @@ -134,8 +135,8 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage): def test_diff_ignore(test_repo): - specA = spack.spec.Spec("p1+usev1").concretized() - specB = spack.spec.Spec("p1~usev1").concretized() + specA = spack.concretize.concretized(spack.spec.Spec("p1+usev1")) + specB = spack.concretize.concretized(spack.spec.Spec("p1~usev1")) c1 = spack.cmd.diff.compare_specs(specA, specB, to_string=False) @@ -155,8 +156,8 @@ def find(function_list, name, args): # Check ignoring changes on multiple packages - specA = spack.spec.Spec("p1+usev1 ^p3+p3var").concretized() - specA = spack.spec.Spec("p1~usev1 ^p3~p3var").concretized() + specA = spack.concretize.concretized(spack.spec.Spec("p1+usev1 ^p3+p3var")) + specA = spack.concretize.concretized(spack.spec.Spec("p1~usev1 ^p3~p3var")) c3 = spack.cmd.diff.compare_specs(specA, specB, to_string=False) assert find(c3["a_not_b"], "variant_value", ["p3", "p3var"]) @@ -169,8 +170,8 @@ def find(function_list, name, args): def test_diff_cmd(install_mockery, mock_fetch, mock_archive, mock_packages): """Test that we can install two packages and diff them""" - specA = spack.spec.Spec("mpileaks").concretized() - specB = spack.spec.Spec("mpileaks+debug").concretized() + specA = spack.concretize.concretized(spack.spec.Spec("mpileaks")) + specB = spack.concretize.concretized(spack.spec.Spec("mpileaks+debug")) # Specs should be the same as themselves c = spack.cmd.diff.compare_specs(specA, specA, to_string=True) diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index 099e6306ac5..62a27f3124b 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -19,6 +19,7 @@ from llnl.util.symlink import readlink import spack.cmd.env +import spack.concretize import spack.config import spack.environment as ev import spack.environment.depfile as depfile @@ -914,7 +915,7 @@ def test_lockfile_spliced_specs(environment_from_manifest, install_mockery): """Test that an environment can round-trip a spliced spec.""" # Create a local install for zmpi to splice in # Default concretization is not using zmpi - zmpi = spack.spec.Spec("zmpi").concretized() + zmpi = spack.concretize.concretized(spack.spec.Spec("zmpi")) PackageInstaller([zmpi.package], fake=True).install() e1 = environment_from_manifest( @@ -1277,39 +1278,43 @@ def test_config_change_existing(mutable_mock_env_path, tmp_path, mock_packages, with e: # List of requirements, flip a variant config("change", "packages:mpich:require:~debug") - test_spec = spack.spec.Spec("mpich").concretized() + test_spec = spack.concretize.concretized(spack.spec.Spec("mpich")) assert test_spec.satisfies("@3.0.2~debug") # List of requirements, change the version (in a different scope) config("change", "packages:mpich:require:@3.0.3") - test_spec = spack.spec.Spec("mpich").concretized() + test_spec = spack.concretize.concretized(spack.spec.Spec("mpich")) assert test_spec.satisfies("@3.0.3") # "require:" as a single string, also try specifying # a spec string that requires enclosing in quotes as # part of the config path config("change", 'packages:libelf:require:"@0.8.12:"') - spack.spec.Spec("libelf@0.8.12").concretized() + spack.concretize.concretized(spack.spec.Spec("libelf@0.8.12")) # No need for assert, if there wasn't a failure, we # changed the requirement successfully. # Use change to add a requirement for a package that # has no requirements defined config("change", "packages:fftw:require:+mpi") - test_spec = spack.spec.Spec("fftw").concretized() + test_spec = spack.concretize.concretized(spack.spec.Spec("fftw")) assert test_spec.satisfies("+mpi") config("change", "packages:fftw:require:~mpi") - test_spec = spack.spec.Spec("fftw").concretized() + test_spec = spack.concretize.concretized(spack.spec.Spec("fftw")) assert test_spec.satisfies("~mpi") config("change", "packages:fftw:require:@1.0") - test_spec = spack.spec.Spec("fftw").concretized() + test_spec = spack.concretize.concretized(spack.spec.Spec("fftw")) assert test_spec.satisfies("@1.0~mpi") # Use "--match-spec" to change one spec in a "one_of" # list config("change", "packages:bowtie:require:@1.2.2", "--match-spec", "@1.2.0") - spack.spec.Spec("bowtie@1.3.0").concretize() - spack.spec.Spec("bowtie@1.2.2").concretized() + # confirm that we can concretize to either value + spack.concretize.concretized(spack.spec.Spec("bowtie@1.3.0")) + spack.concretize.concretized(spack.spec.Spec("bowtie@1.2.2")) + # confirm that we cannot concretize to the old value + with pytest.raises(spack.solver.asp.UnsatisfiableSpecError): + spack.concretize.concretized(spack.spec.Spec("bowtie@1.2.0")) def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutable_config): @@ -1324,8 +1329,8 @@ def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutab with ev.Environment(tmp_path): config("change", "packages:mpich:require:~debug") with pytest.raises(spack.solver.asp.UnsatisfiableSpecError): - spack.spec.Spec("mpich+debug").concretized() - spack.spec.Spec("mpich~debug").concretized() + spack.concretize.concretized(spack.spec.Spec("mpich+debug")) + spack.concretize.concretized(spack.spec.Spec("mpich~debug")) # 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 @@ -1339,7 +1344,7 @@ def test_config_change_new(mutable_mock_env_path, tmp_path, mock_packages, mutab """ ) with ev.Environment(tmp_path): - assert spack.spec.Spec("mpich").concretized().satisfies("@3.0.3") + assert spack.concretize.concretized(spack.spec.Spec("mpich")).satisfies("@3.0.3") with pytest.raises(spack.error.ConfigError, match="not a list"): config("change", "packages:mpich:require:~debug") @@ -1647,7 +1652,7 @@ def test_stage(mock_stage, mock_fetch, install_mockery): root = str(mock_stage) def check_stage(spec): - spec = Spec(spec).concretized() + spec = spack.concretize.concretized(Spec(spec)) for dep in spec.traverse(): stage_name = "{0}{1}-{2}-{3}".format( stage_prefix, dep.name, dep.version, dep.dag_hash() @@ -1750,7 +1755,7 @@ def test_indirect_build_dep(tmp_path): with spack.repo.use_repositories(builder.root): x_spec = Spec("x") - x_concretized = x_spec.concretized() + x_concretized = spack.concretize.concretized(x_spec) _env_create("test", with_view=False) e = ev.read("test") @@ -1783,10 +1788,10 @@ def test_store_different_build_deps(tmp_path): with spack.repo.use_repositories(builder.root): y_spec = Spec("y ^z@3") - y_concretized = y_spec.concretized() + y_concretized = spack.concretize.concretized(y_spec) x_spec = Spec("x ^z@2") - x_concretized = x_spec.concretized() + x_concretized = spack.concretize.concretized(x_spec) # 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 diff --git a/lib/spack/spack/test/cmd/extensions.py b/lib/spack/spack/test/cmd/extensions.py index 082628cc34c..5fa8e14a484 100644 --- a/lib/spack/spack/test/cmd/extensions.py +++ b/lib/spack/spack/test/cmd/extensions.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize from spack.installer import PackageInstaller from spack.main import SpackCommand, SpackCommandError from spack.spec import Spec @@ -15,7 +16,9 @@ @pytest.fixture def python_database(mock_packages, mutable_database): - specs = [Spec(s).concretized() for s in ["python", "py-extension1", "py-extension2"]] + specs = [ + spack.concretize.concretized(Spec(s)) for s in ["python", "py-extension1", "py-extension2"] + ] PackageInstaller([s.package for s in specs], explicit=True, fake=True).install() yield @@ -23,7 +26,7 @@ def python_database(mock_packages, mutable_database): @pytest.mark.not_on_windows("All Fetchers Failed") @pytest.mark.db def test_extensions(mock_packages, python_database, capsys): - ext2 = Spec("py-extension2").concretized() + ext2 = spack.concretize.concretized(Spec("py-extension2")) def check_output(ni): with capsys.disabled(): diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py index 656ddac442e..407c642f2b0 100644 --- a/lib/spack/spack/test/cmd/find.py +++ b/lib/spack/spack/test/cmd/find.py @@ -13,6 +13,7 @@ import spack.cmd as cmd import spack.cmd.find +import spack.concretize import spack.environment as ev import spack.repo import spack.store @@ -202,7 +203,8 @@ def test_find_json_deps(database): @pytest.mark.db def test_display_json(database, capsys): specs = [ - Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] + spack.concretize.concretized(Spec(s)) + for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] ] cmd.display_specs_as_json(specs) @@ -217,7 +219,8 @@ def test_display_json(database, capsys): @pytest.mark.db def test_display_json_deps(database, capsys): specs = [ - Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] + spack.concretize.concretized(Spec(s)) + for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] ] cmd.display_specs_as_json(specs, deps=True) @@ -276,7 +279,7 @@ def test_find_format_deps(database, config): def test_find_format_deps_paths(database, config): output = find("-dp", "--format", "{name}-{version}", "mpileaks", "^zmpi") - spec = Spec("mpileaks ^zmpi").concretized() + spec = spack.concretize.concretized(Spec("mpileaks ^zmpi")) prefixes = [s.prefix for s in spec.traverse()] assert ( @@ -301,7 +304,8 @@ def test_find_very_long(database, config): output = find("-L", "--no-groups", "mpileaks") specs = [ - Spec(s).concretized() for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] + spack.concretize.concretized(Spec(s)) + for s in ["mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2"] ] assert set(output.strip().split("\n")) == set( diff --git a/lib/spack/spack/test/cmd/gc.py b/lib/spack/spack/test/cmd/gc.py index d997be59b2a..4c2aad1873d 100644 --- a/lib/spack/spack/test/cmd/gc.py +++ b/lib/spack/spack/test/cmd/gc.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize import spack.deptypes as dt import spack.environment as ev import spack.main @@ -26,8 +27,7 @@ def test_gc_without_build_dependency(mutable_database): @pytest.mark.db def test_gc_with_build_dependency(mutable_database): - s = spack.spec.Spec("simple-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) PackageInstaller([s.package], explicit=True, fake=True).install() assert "There are no unused specs." in gc("-yb") @@ -37,8 +37,8 @@ def test_gc_with_build_dependency(mutable_database): @pytest.mark.db def test_gc_with_constraints(mutable_database): - s_cmake1 = spack.spec.Spec("simple-inheritance ^cmake@3.4.3").concretized() - s_cmake2 = spack.spec.Spec("simple-inheritance ^cmake@3.23.1").concretized() + s_cmake1 = spack.concretize.concretized(spack.spec.Spec("simple-inheritance ^cmake@3.4.3")) + s_cmake2 = spack.concretize.concretized(spack.spec.Spec("simple-inheritance ^cmake@3.23.1")) PackageInstaller([s_cmake1.package], explicit=True, fake=True).install() PackageInstaller([s_cmake2.package], explicit=True, fake=True).install() @@ -53,8 +53,7 @@ def test_gc_with_constraints(mutable_database): @pytest.mark.db def test_gc_with_environment(mutable_database, mutable_mock_env_path): - s = spack.spec.Spec("simple-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) PackageInstaller([s.package], explicit=True, fake=True).install() e = ev.create("test_gc") @@ -69,8 +68,7 @@ def test_gc_with_environment(mutable_database, mutable_mock_env_path): @pytest.mark.db def test_gc_with_build_dependency_in_environment(mutable_database, mutable_mock_env_path): - s = spack.spec.Spec("simple-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) PackageInstaller([s.package], explicit=True, fake=True).install() e = ev.create("test_gc") @@ -121,8 +119,7 @@ def test_gc_except_any_environments(mutable_database, mutable_mock_env_path): @pytest.mark.db def test_gc_except_specific_environments(mutable_database, mutable_mock_env_path): - s = spack.spec.Spec("simple-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) PackageInstaller([s.package], explicit=True, fake=True).install() assert mutable_database.query_local("zmpi") @@ -148,8 +145,7 @@ def test_gc_except_nonexisting_dir_env(mutable_database, mutable_mock_env_path, @pytest.mark.db def test_gc_except_specific_dir_env(mutable_database, mutable_mock_env_path, tmpdir): - s = spack.spec.Spec("simple-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) PackageInstaller([s.package], explicit=True, fake=True).install() assert mutable_database.query_local("zmpi") diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 445f376b1b4..0e9fc0801e8 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -20,6 +20,7 @@ import spack.build_environment import spack.cmd.common.arguments import spack.cmd.install +import spack.concretize import spack.config import spack.environment as ev import spack.error @@ -135,7 +136,7 @@ def test_package_output(tmpdir, capsys, install_mockery, mock_fetch): # 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 # when nested AND in pytest - spec = Spec("printing-package").concretized() + spec = spack.concretize.concretized(Spec("printing-package")) pkg = spec.package PackageInstaller([pkg], explicit=True, verbose=True).install() @@ -175,7 +176,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): """Verify that source has been copied into place.""" install("--source", "--keep-stage", "trivial-install-test-package") - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) src = os.path.join(spec.prefix.share, "trivial-install-test-package", "src") assert filecmp.cmp( os.path.join(mock_archive.path, "configure"), os.path.join(src, "configure") @@ -183,8 +184,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): - spec = Spec("libdwarf") - spec.concretize() + spec = spack.concretize.concretized(Spec("libdwarf")) install("libdwarf") assert os.path.isfile(spec.package.install_env_path) @@ -205,8 +205,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): # Try to install a spec and then to reinstall it. - spec = Spec("libdwarf") - spec.concretize() + spec = spack.concretize.concretized(Spec("libdwarf")) install("libdwarf") @@ -239,8 +238,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): # Try to install a spec and then to reinstall it. - spec = Spec("libdwarf") - spec.concretize() + spec = spack.concretize.concretized(Spec("libdwarf")) assert not os.path.exists(spec.prefix) @@ -261,7 +259,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) # Use the earliest commit in the respository - spec = Spec(f"git-test-commit@{commits[-1]}").concretized() + spec = spack.concretize.concretized(Spec(f"git-test-commit@{commits[-1]}")) PackageInstaller([spec.package], explicit=True).install() # Ensure first commit file contents were written @@ -274,13 +272,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): # Try to install a spec and then to reinstall it. - libdwarf = Spec("libdwarf") - libdwarf.concretize() + libdwarf = spack.concretize.concretized(Spec("libdwarf")) install("libdwarf") - cmake = Spec("cmake") - cmake.concretize() + cmake = spack.concretize.concretized(Spec("cmake")) install("cmake") @@ -356,7 +352,7 @@ def test_install_invalid_spec(invalid_spec): ) def test_install_from_file(spec, concretize, error_code, tmpdir): if concretize: - spec.concretize() + spec = spack.concretize.concretized(spec) specfile = tmpdir.join("spec.yaml") @@ -486,8 +482,7 @@ def test_install_mix_cli_and_files(clispecs, filespecs, tmpdir): for spec in filespecs: filepath = tmpdir.join(spec + ".yaml") args = ["-f", str(filepath)] + args - s = Spec(spec) - s.concretize() + s = spack.concretize.concretized(Spec(spec)) with filepath.open("w") as f: s.to_yaml(f) @@ -496,8 +491,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): - s = Spec("archive-files") - s.concretize() + s = spack.concretize.concretized(Spec("archive-files")) install("archive-files") @@ -616,8 +610,7 @@ def test_cdash_install_from_spec_json( with capfd.disabled(), tmpdir.as_cwd(): spec_json_path = str(tmpdir.join("spec.json")) - pkg_spec = Spec("pkg-a") - pkg_spec.concretize() + pkg_spec = spack.concretize.concretized(Spec("pkg-a")) with open(spec_json_path, "w") as fd: fd.write(pkg_spec.to_json(hash=ht.dag_hash)) @@ -693,8 +686,8 @@ def test_cache_only_fails(tmpdir, mock_fetch, install_mockery, capfd): def test_install_only_dependencies(tmpdir, mock_fetch, install_mockery): - dep = Spec("dependency-install").concretized() - root = Spec("dependent-install").concretized() + dep = spack.concretize.concretized(Spec("dependency-install")) + root = spack.concretize.concretized(Spec("dependent-install")) install("--only", "dependencies", "dependent-install") @@ -715,8 +708,8 @@ def test_install_only_package(tmpdir, mock_fetch, install_mockery, capfd): def test_install_deps_then_package(tmpdir, mock_fetch, install_mockery): - dep = Spec("dependency-install").concretized() - root = Spec("dependent-install").concretized() + dep = spack.concretize.concretized(Spec("dependency-install")) + root = spack.concretize.concretized(Spec("dependent-install")) install("--only", "dependencies", "dependent-install") assert os.path.exists(dep.prefix) @@ -734,8 +727,8 @@ def test_install_only_dependencies_in_env( env("create", "test") with ev.read("test"): - dep = Spec("dependency-install").concretized() - root = Spec("dependent-install").concretized() + dep = spack.concretize.concretized(Spec("dependency-install")) + root = spack.concretize.concretized(Spec("dependent-install")) install("-v", "--only", "dependencies", "--add", "dependent-install") @@ -751,8 +744,8 @@ def test_install_only_dependencies_of_all_in_env( with ev.read("test"): roots = [ - Spec("dependent-install@1.0").concretized(), - Spec("dependent-install@2.0").concretized(), + spack.concretize.concretized(Spec("dependent-install@1.0")), + spack.concretize.concretized(Spec("dependent-install@2.0")), ] add("dependent-install@1.0") @@ -901,7 +894,7 @@ def test_cdash_configure_warning(tmpdir, mock_fetch, install_mockery, capfd): # Ensure that even on non-x86_64 architectures, there are no # dependencies installed - spec = Spec("configure-warning").concretized() + spec = spack.concretize.concretized(Spec("configure-warning")) spec.clear_dependencies() specfile = "./spec.json" with open(specfile, "w") as f: @@ -947,7 +940,7 @@ def test_install_env_with_tests_all( ): env("create", "test") with ev.read("test"): - test_dep = Spec("test-dependency").concretized() + test_dep = spack.concretize.concretized(Spec("test-dependency")) add("depb") install("--test", "all") assert os.path.exists(test_dep.prefix) @@ -959,7 +952,7 @@ def test_install_env_with_tests_root( ): env("create", "test") with ev.read("test"): - test_dep = Spec("test-dependency").concretized() + test_dep = spack.concretize.concretized(Spec("test-dependency")) add("depb") install("--test", "root") assert not os.path.exists(test_dep.prefix) diff --git a/lib/spack/spack/test/cmd/load.py b/lib/spack/spack/test/cmd/load.py index 1c36bcc86ab..1732a35da3e 100644 --- a/lib/spack/spack/test/cmd/load.py +++ b/lib/spack/spack/test/cmd/load.py @@ -8,6 +8,7 @@ import pytest +import spack.concretize import spack.spec import spack.user_environment as uenv from spack.main import SpackCommand @@ -50,7 +51,7 @@ def test_load_shell(shell, set_command): """Test that `spack load` applies prefix inspections of its required runtime deps in topo-order""" install("mpileaks") - mpileaks_spec = spack.spec.Spec("mpileaks").concretized() + mpileaks_spec = spack.concretize.concretized(spack.spec.Spec("mpileaks")) # Ensure our reference variable is clean. os.environ["CMAKE_PREFIX_PATH"] = "/hello" + os.pathsep + "/world" @@ -167,7 +168,7 @@ def test_unload( """Tests that any variables set in the user environment are undone by the unload command""" install("mpileaks") - mpileaks_spec = spack.spec.Spec("mpileaks").concretized() + mpileaks_spec = spack.concretize.concretized(spack.spec.Spec("mpileaks")) # Set so unload has something to do os.environ["FOOBAR"] = "mpileaks" @@ -188,7 +189,7 @@ def test_unload_fails_no_shell( ): """Test that spack unload prints an error message without a shell.""" install("mpileaks") - mpileaks_spec = spack.spec.Spec("mpileaks").concretized() + mpileaks_spec = spack.concretize.concretized(spack.spec.Spec("mpileaks")) os.environ[uenv.spack_loaded_hashes_var] = mpileaks_spec.dag_hash() out = unload("mpileaks", fail_on_error=False) diff --git a/lib/spack/spack/test/cmd/location.py b/lib/spack/spack/test/cmd/location.py index 25fa02a6b08..2c2e7355696 100644 --- a/lib/spack/spack/test/cmd/location.py +++ b/lib/spack/spack/test/cmd/location.py @@ -9,6 +9,7 @@ from llnl.util.filesystem import mkdirp +import spack.concretize import spack.environment as ev import spack.paths import spack.spec @@ -26,7 +27,7 @@ @pytest.fixture def mock_spec(): # Make it look like the source was actually expanded. - s = spack.spec.Spec("externaltest").concretized() + s = spack.concretize.concretized(spack.spec.Spec("externaltest")) source_path = s.package.stage.source_path mkdirp(source_path) yield s, s.package diff --git a/lib/spack/spack/test/cmd/logs.py b/lib/spack/spack/test/cmd/logs.py index b668cd449cb..4e5d119b94d 100644 --- a/lib/spack/spack/test/cmd/logs.py +++ b/lib/spack/spack/test/cmd/logs.py @@ -14,6 +14,7 @@ import spack import spack.cmd.logs +import spack.concretize import spack.main import spack.spec from spack.main import SpackCommand @@ -54,7 +55,7 @@ def disable_capture(capfd): def test_logs_cmd_errors(install_mockery, mock_fetch, mock_archive, mock_packages): - spec = spack.spec.Spec("libelf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libelf")) assert not spec.installed with pytest.raises(spack.main.SpackCommandError, match="is not installed or staged"): @@ -83,7 +84,7 @@ def test_dump_logs(install_mockery, mock_fetch, mock_archive, mock_packages, dis decompress them. """ cmdline_spec = spack.spec.Spec("libelf") - concrete_spec = cmdline_spec.concretized() + concrete_spec = spack.concretize.concretized(cmdline_spec) # Sanity check, make sure this test is checking what we want: to # start with diff --git a/lib/spack/spack/test/cmd/mirror.py b/lib/spack/spack/test/cmd/mirror.py index b10335d56f7..c31320a2a34 100644 --- a/lib/spack/spack/test/cmd/mirror.py +++ b/lib/spack/spack/test/cmd/mirror.py @@ -8,6 +8,7 @@ import pytest import spack.cmd.mirror +import spack.concretize import spack.config import spack.environment as ev import spack.error @@ -61,7 +62,7 @@ def test_mirror_from_env(tmp_path, mock_packages, mock_fetch, mutable_mock_env_p @pytest.fixture def source_for_pkg_with_hash(mock_packages, tmpdir): - s = spack.spec.Spec("trivial-pkg-with-valid-hash").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-pkg-with-valid-hash")) local_url_basename = os.path.basename(s.package.url) local_path = os.path.join(str(tmpdir), local_url_basename) with open(local_path, "w") as f: @@ -73,7 +74,10 @@ def source_for_pkg_with_hash(mock_packages, tmpdir): def test_mirror_skip_unstable(tmpdir_factory, mock_packages, config, source_for_pkg_with_hash): 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.concretized(spack.spec.Spec(x)) + for x in ["git-test", "trivial-pkg-with-valid-hash"] + ] spack.mirrors.utils.create(mirror_dir, specs, skip_unstable_versions=True) assert set(os.listdir(mirror_dir)) - set(["_source-cache"]) == set( @@ -112,7 +116,8 @@ def test_exclude_specs(mock_packages, config): mirror_specs, _ = spack.cmd.mirror._specs_and_action(args) expected_include = set( - spack.spec.Spec(x).concretized() for x in ["mpich@3.0.3", "mpich@3.0.4", "mpich@3.0"] + spack.concretize.concretized(spack.spec.Spec(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"]) assert expected_include <= set(mirror_specs) @@ -146,7 +151,8 @@ def test_exclude_file(mock_packages, tmpdir, config): mirror_specs, _ = spack.cmd.mirror._specs_and_action(args) expected_include = set( - spack.spec.Spec(x).concretized() for x in ["mpich@3.0.3", "mpich@3.0.4", "mpich@3.0"] + spack.concretize.concretized(spack.spec.Spec(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"]) assert expected_include <= set(mirror_specs) diff --git a/lib/spack/spack/test/cmd/module.py b/lib/spack/spack/test/cmd/module.py index 759d1391c97..7c70db726e3 100644 --- a/lib/spack/spack/test/cmd/module.py +++ b/lib/spack/spack/test/cmd/module.py @@ -8,6 +8,7 @@ import pytest +import spack.concretize import spack.config import spack.main import spack.modules @@ -34,7 +35,7 @@ def ensure_module_files_are_there(mock_repo_path, mock_store, mock_configuration def _module_files(module_type, *specs): - specs = [spack.spec.Spec(x).concretized() for x in specs] + specs = [spack.concretize.concretized(spack.spec.Spec(x)) for x in specs] writer_cls = spack.modules.module_types[module_type] return [writer_cls(spec, "default").layout.filename for spec in specs] @@ -185,12 +186,15 @@ def test_setdefault_command(mutable_database, mutable_config): # Install two different versions of pkg-a 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.concretized(spack.spec.Spec(other_spec)), + spack.concretize.concretized(spack.spec.Spec(preferred)), + ] PackageInstaller([s.package for s in specs], explicit=True, fake=True).install() writers = { - preferred: writer_cls(spack.spec.Spec(preferred).concretized(), "default"), - other_spec: writer_cls(spack.spec.Spec(other_spec).concretized(), "default"), + preferred: writer_cls(specs[1], "default"), + other_spec: writer_cls(specs[0], "default"), } # Create two module files for the same software diff --git a/lib/spack/spack/test/cmd/tags.py b/lib/spack/spack/test/cmd/tags.py index 0e8e7f01659..e3953c9bb93 100644 --- a/lib/spack/spack/test/cmd/tags.py +++ b/lib/spack/spack/test/cmd/tags.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import spack.concretize import spack.main import spack.repo import spack.spec @@ -48,7 +49,7 @@ class tag_path: def test_tags_installed(install_mockery, mock_fetch): - s = spack.spec.Spec("mpich").concretized() + s = spack.concretize.concretized(spack.spec.Spec("mpich")) PackageInstaller([s.package], explicit=True, fake=True).install() out = tags("-i") diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py index 866d579aa7f..3b20309aa89 100644 --- a/lib/spack/spack/test/cmd/test.py +++ b/lib/spack/spack/test/cmd/test.py @@ -12,6 +12,7 @@ import spack.cmd.common.arguments import spack.cmd.test +import spack.concretize import spack.config import spack.install_test import spack.paths @@ -241,7 +242,7 @@ def test_read_old_results(mock_packages, mock_test_stage): def test_test_results_none(mock_packages, mock_test_stage): name = "trivial" - spec = spack.spec.Spec("trivial-smoke-test").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) suite = spack.install_test.TestSuite([spec], name) suite.ensure_stage() spack.install_test.write_test_suite_file(suite) @@ -256,7 +257,7 @@ def test_test_results_none(mock_packages, mock_test_stage): def test_test_results_status(mock_packages, mock_test_stage, status): """Confirm 'spack test results' returns expected status.""" name = "trivial" - spec = spack.spec.Spec("trivial-smoke-test").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) suite = spack.install_test.TestSuite([spec], name) suite.ensure_stage() spack.install_test.write_test_suite_file(suite) @@ -279,7 +280,7 @@ def test_test_results_status(mock_packages, mock_test_stage, status): 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""" name = "trivial" - spec = spack.spec.Spec("trivial-smoke-test").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) suite = spack.install_test.TestSuite([spec], name) suite.ensure_stage() diff --git a/lib/spack/spack/test/cmd/undevelop.py b/lib/spack/spack/test/cmd/undevelop.py index 684a9f50198..fc3a9052701 100644 --- a/lib/spack/spack/test/cmd/undevelop.py +++ b/lib/spack/spack/test/cmd/undevelop.py @@ -2,6 +2,7 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import spack.concretize import spack.environment as ev import spack.spec from spack.main import SpackCommand @@ -31,9 +32,9 @@ def test_undevelop(tmpdir, mutable_config, mock_packages, mutable_mock_env_path) env("create", "test", "./spack.yaml") with ev.read("test"): - before = spack.spec.Spec("mpich").concretized() + before = spack.concretize.concretized(spack.spec.Spec("mpich")) undevelop("mpich") - after = spack.spec.Spec("mpich").concretized() + after = spack.concretize.concretized(spack.spec.Spec("mpich")) # Removing dev spec from environment changes concretization assert before.satisfies("dev_path=*") diff --git a/lib/spack/spack/test/cmd/verify.py b/lib/spack/spack/test/cmd/verify.py index 53b57cd7902..490c26be48e 100644 --- a/lib/spack/spack/test/cmd/verify.py +++ b/lib/spack/spack/test/cmd/verify.py @@ -8,6 +8,7 @@ import llnl.util.filesystem as fs +import spack.concretize import spack.spec import spack.store import spack.util.spack_json as sjson @@ -66,7 +67,7 @@ def test_single_file_verify_cmd(tmpdir): 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 install("libelf") - s = spack.spec.Spec("libelf").concretized() + s = spack.concretize.concretized(spack.spec.Spec("libelf")) prefix = s.prefix hash = s.dag_hash() diff --git a/lib/spack/spack/test/cmd/view.py b/lib/spack/spack/test/cmd/view.py index 1c405728b44..294aad803d9 100644 --- a/lib/spack/spack/test/cmd/view.py +++ b/lib/spack/spack/test/cmd/view.py @@ -10,6 +10,7 @@ from llnl.util.symlink import _windows_can_symlink +import spack.concretize import spack.util.spack_yaml as s_yaml from spack.installer import PackageInstaller from spack.main import SpackCommand @@ -191,7 +192,7 @@ def test_view_fails_with_missing_projections_file(tmpdir): def test_view_files_not_ignored( tmpdir, mock_packages, mock_archive, mock_fetch, install_mockery, cmd, with_projection ): - spec = Spec("view-not-ignored").concretized() + spec = spack.concretize.concretized(Spec("view-not-ignored")) pkg = spec.package PackageInstaller([pkg], explicit=True).install() pkg.assert_installed(spec.prefix) diff --git a/lib/spack/spack/test/concretization/compiler_runtimes.py b/lib/spack/spack/test/concretization/compiler_runtimes.py index fefa262ca4d..9cfa3448a45 100644 --- a/lib/spack/spack/test/concretization/compiler_runtimes.py +++ b/lib/spack/spack/test/concretization/compiler_runtimes.py @@ -9,6 +9,7 @@ import archspec.cpu +import spack.concretize import spack.config import spack.paths import spack.repo @@ -21,7 +22,7 @@ def _concretize_with_reuse(*, root_str, reused_str): - reused_spec = spack.spec.Spec(reused_str).concretized() + reused_spec = spack.concretize.concretized(spack.spec.Spec(reused_str)) setup = spack.solver.asp.SpackSolverSetup(tests=False) driver = spack.solver.asp.PyclingoDriver() result, _, _ = driver.solve(setup, [spack.spec.Spec(f"{root_str}")], reuse=[reused_spec]) @@ -45,7 +46,7 @@ def enable_runtimes(): 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.concretized(spack.spec.Spec("pkg-a%gcc@10.2.1 ^pkg-b%gcc@9.4.0")) a, b = s["pkg-a"], s["pkg-b"] # Both a and b should depend on the same gcc-runtime directly @@ -62,7 +63,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)}"}]}} spack.config.set("packages", packages_yaml) - s = spack.spec.Spec("pkg-a%gcc@10.2.1").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a%gcc@10.2.1")) a, b = s["pkg-a"], s["pkg-b"] diff --git a/lib/spack/spack/test/concretization/core.py b/lib/spack/spack/test/concretization/core.py index 8f136d46a4a..14f33682321 100644 --- a/lib/spack/spack/test/concretization/core.py +++ b/lib/spack/spack/test/concretization/core.py @@ -69,7 +69,7 @@ def check_spec(abstract, concrete): def check_concretize(abstract_spec): abstract = Spec(abstract_spec) - concrete = abstract.concretized() + concrete = spack.concretize.concretized(abstract) assert not abstract.concrete assert concrete.concrete check_spec(abstract, concrete) @@ -386,10 +386,12 @@ def test_different_compilers_get_different_flags( ): """Tests that nodes get the flags of the associated compiler.""" mutable_config.set("compilers", [clang12_with_flags, gcc11_with_flags]) - client = Spec( - "cmake-client %gcc@11.1.0 platform=test os=fe target=fe" - " ^cmake %clang@12.2.0 platform=test os=fe target=fe" - ).concretized() + client = spack.concretize.concretized( + Spec( + "cmake-client %gcc@11.1.0 platform=test os=fe target=fe" + " ^cmake %clang@12.2.0 platform=test os=fe target=fe" + ) + ) cmake = client["cmake"] assert set(client.compiler_flags["cflags"]) == {"-O0", "-g"} assert set(cmake.compiler_flags["cflags"]) == {"-O3"} @@ -404,7 +406,7 @@ def test_spec_flags_maintain_order(self, mutable_config, gcc11_with_flags): mutable_config.set("compilers", [gcc11_with_flags]) spec_str = "libelf %gcc@11.1.0 os=redhat6" for _ in range(3): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert all( s.compiler_flags[x] == ["-O0", "-g"] for x in ("cflags", "cxxflags", "fflags") ) @@ -423,7 +425,7 @@ def test_compiler_flags_differ_identical_compilers(self, mutable_config, clang12 different_dict["compiler"]["flags"] = {"cflags": "-O2"} with spack.config.override("compilers", [different_dict]): - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("cflags=-O2") @pytest.mark.parametrize( @@ -458,7 +460,7 @@ def test_compiler_flags_differ_identical_compilers(self, mutable_config, clang12 ], ) def test_compiler_flag_propagation(self, spec_str, expected, not_expected): - root = Spec(spec_str).concretized() + root = spack.concretize.concretized(Spec(spec_str)) for constraint in expected: assert root.satisfies(constraint) @@ -468,12 +470,12 @@ def test_compiler_flag_propagation(self, spec_str, expected, not_expected): def test_mixing_compilers_only_affects_subdag(self): spack.config.set("packages:all:compiler", ["clang", "gcc"]) - spec = Spec("dt-diamond%gcc ^dt-diamond-bottom%clang").concretized() + spec = spack.concretize.concretized(Spec("dt-diamond%gcc ^dt-diamond-bottom%clang")) for dep in spec.traverse(): assert ("%clang" in dep) == (dep.name == "dt-diamond-bottom") def test_compiler_inherited_upwards(self): - spec = Spec("dt-diamond ^dt-diamond-bottom%clang").concretized() + spec = spack.concretize.concretized(Spec("dt-diamond ^dt-diamond-bottom%clang")) for dep in spec.traverse(): assert "%clang" in dep @@ -487,50 +489,50 @@ def test_architecture_deep_inheritance(self, mock_targets, compiler_factory): del cnl_compiler["compiler"]["target"] with spack.config.override("compilers", [cnl_compiler]): spec_str = "mpileaks %gcc@4.5.0 os=CNL target=nocona ^dyninst os=CNL ^callpath os=CNL" - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) for s in spec.traverse(root=False): assert s.architecture.target == spec.architecture.target def test_compiler_flags_from_user_are_grouped(self): spec = Spec('pkg-a%gcc cflags="-O -foo-flag foo-val" platform=test') - spec.concretize() + spec = spack.concretize.concretized(spec) cflags = spec.compiler_flags["cflags"] assert any(x == "-foo-flag foo-val" for x in cflags) def concretize_multi_provider(self): s = Spec("mpileaks ^multi-provider-mpi@3.0") - s.concretize() + s = spack.concretize.concretized(s) assert s["mpi"].version == ver("1.10.3") def test_concretize_dependent_with_singlevalued_variant_type(self): s = Spec("singlevalue-variant-dependent-type") - s.concretize() + s = spack.concretize.concretized(s) @pytest.mark.parametrize("spec,version", [("dealii", "develop"), ("xsdk", "0.4.0")]) def concretize_difficult_packages(self, a, b): """Test a couple of large packages that are often broken due to current limitations in the concretizer""" s = Spec(a + "@" + b) - s.concretize() + s = spack.concretize.concretized(s) assert s[a].version == ver(b) def test_concretize_two_virtuals(self): """Test a package with multiple virtual dependencies.""" - Spec("hypre").concretize() + spack.concretize.concretized(Spec("hypre")) def test_concretize_two_virtuals_with_one_bound(self, mutable_mock_repo): """Test a package with multiple virtual dependencies and one preset.""" - Spec("hypre ^openblas").concretize() + spack.concretize.concretized(Spec("hypre ^openblas")) def test_concretize_two_virtuals_with_two_bound(self): """Test a package with multiple virtual deps and two of them preset.""" - Spec("hypre ^openblas ^netlib-lapack").concretize() + spack.concretize.concretized(Spec("hypre ^netlib-lapack")) def test_concretize_two_virtuals_with_dual_provider(self): """Test a package with multiple virtual dependencies and force a provider that provides both. """ - Spec("hypre ^openblas-with-lapack").concretize() + spack.concretize.concretized(Spec("hypre ^openblas-with-lapack")) def test_concretize_two_virtuals_with_dual_provider_and_a_conflict(self): """Test a package with multiple virtual dependencies and force a @@ -539,7 +541,7 @@ def test_concretize_two_virtuals_with_dual_provider_and_a_conflict(self): """ s = Spec("hypre ^openblas-with-lapack ^netlib-lapack") with pytest.raises(spack.error.SpackError): - s.concretize() + spack.concretize.concretized(s) @pytest.mark.parametrize( "spec_str,expected_propagation", @@ -560,7 +562,7 @@ def test_concretize_two_virtuals_with_dual_provider_and_a_conflict(self): ) def test_concretize_propagate_disabled_variant(self, spec_str, expected_propagation): """Tests various patterns of boolean variant propagation""" - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) for key, expected_satisfies in expected_propagation: spec[key].satisfies(expected_satisfies) @@ -568,7 +570,7 @@ def test_concretize_propagate_variant_not_dependencies(self): """Test that when propagating a variant it is not propagated to dependencies that do not have that variant""" spec = Spec("quantum-espresso~~invino") - spec.concretize() + spec = spack.concretize.concretized(spec) for dep in spec.traverse(root=False): assert "invino" not in dep.variants.keys() @@ -578,21 +580,21 @@ def test_concretize_propagate_variant_exclude_dependency_fail(self): the source package's dependencies""" spec = Spec("hypre ~~shared ^openblas +shared") with pytest.raises(spack.error.UnsatisfiableSpecError): - spec.concretize() + spec = spack.concretize.concretized(spec) def test_concretize_propagate_same_variant_from_direct_dep_fail(self): """Test that when propagating a variant from the source package and a direct dependency also propagates the same variant with a different value. Raises error""" spec = Spec("ascent +adios2 ++shared ^adios2 ~~shared") with pytest.raises(spack.error.UnsatisfiableSpecError): - spec.concretize() + spec = spack.concretize.concretized(spec) def test_concretize_propagate_same_variant_in_dependency_fail(self): """Test that when propagating a variant from the source package, none of it's dependencies can propagate that variant with a different value. Raises error.""" spec = Spec("ascent +adios2 ++shared ^bzip2 ~~shared") with pytest.raises(spack.error.UnsatisfiableSpecError): - spec.concretize() + spec = spack.concretize.concretized(spec) def test_concretize_propagate_same_variant_virtual_dependency_fail(self): """Test that when propagating a variant from the source package and a direct @@ -600,19 +602,19 @@ def test_concretize_propagate_same_variant_virtual_dependency_fail(self): different value. Raises error""" spec = Spec("hypre ++shared ^openblas ~~shared") with pytest.raises(spack.error.UnsatisfiableSpecError): - spec.concretize() + spec = spack.concretize.concretized(spec) def test_concretize_propagate_same_variant_multiple_sources_diamond_dep_fail(self): """Test that fails when propagating the same variant with different values from multiple sources that share a dependency""" spec = Spec("parent-foo-bar ^dependency-foo-bar++bar ^direct-dep-foo-bar~~bar") with pytest.raises(spack.error.UnsatisfiableSpecError): - spec.concretize() + spec = spack.concretize.concretized(spec) def test_concretize_propagate_specified_variant(self): """Test that only the specified variant is propagated to the dependencies""" spec = Spec("parent-foo-bar ~~foo") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("^dependency-foo-bar~foo") assert spec.satisfies("^second-dependency-foo-bar-fee~foo") @@ -625,7 +627,7 @@ def test_concretize_propagate_specified_variant(self): def test_concretize_propagate_one_variant(self): """Test that you can specify to propagate one variant and not all""" spec = Spec("parent-foo-bar ++bar ~foo") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("~foo") and not spec.satisfies("^dependency-foo-bar~foo") assert spec.satisfies("+bar") and spec.satisfies("^dependency-foo-bar+bar") @@ -634,7 +636,7 @@ def test_concretize_propagate_through_first_level_deps(self): """Test that boolean valued variants can be propagated past first level dependecies even if the first level dependency does have the variant""" spec = Spec("parent-foo-bar-fee ++fee") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("+fee") and not spec.satisfies("dependency-foo-bar+fee") assert spec.satisfies("^second-dependency-foo-bar-fee+fee") @@ -643,7 +645,7 @@ def test_concretize_propagate_multiple_variants(self): """Test that multiple boolean valued variants can be propagated from the same source package""" spec = Spec("parent-foo-bar-fee ~~foo ++bar") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("~foo") and spec.satisfies("+bar") assert spec.satisfies("^dependency-foo-bar ~foo +bar") @@ -653,7 +655,7 @@ def test_concretize_propagate_multiple_variants_mulitple_sources(self): """Test the propagates multiple different variants for multiple sources in a diamond dependency""" spec = Spec("parent-foo-bar ^dependency-foo-bar++bar ^direct-dep-foo-bar~~foo") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("^second-dependency-foo-bar-fee+bar") assert spec.satisfies("^second-dependency-foo-bar-fee~foo") @@ -663,7 +665,7 @@ def test_concretize_propagate_multiple_variants_mulitple_sources(self): def test_concretize_propagate_single_valued_variant(self): """Test propagation for single valued variants""" spec = Spec("multivalue-variant libs==static") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("libs=static") assert spec.satisfies("^pkg-a libs=static") @@ -672,7 +674,7 @@ def test_concretize_propagate_multivalue_variant(self): """Test that multivalue variants are propagating the specified value(s) to their dependecies. The dependencies should not have the default value""" spec = Spec("multivalue-variant foo==baz,fee") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("^pkg-a foo=baz,fee") assert spec.satisfies("^pkg-b foo=baz,fee") @@ -683,7 +685,7 @@ def test_concretize_propagate_multiple_multivalue_variant(self): """Tests propagating the same mulitvalued variant from different sources allows the dependents to accept all propagated values""" spec = Spec("multivalue-variant foo==bar ^pkg-a foo==baz") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("multivalue-variant foo=bar") assert spec.satisfies("^pkg-a foo=bar,baz") @@ -693,7 +695,7 @@ def test_concretize_propagate_variant_not_in_source(self): """Test that variant is still propagated even if the source pkg doesn't have the variant""" spec = Spec("callpath++debug") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("^mpich+debug") assert not spec.satisfies("callpath+debug") @@ -703,7 +705,7 @@ def test_concretize_propagate_variant_multiple_deps_not_in_source(self): """Test that a variant can be propagated to multiple dependencies when the variant is not in the source package""" spec = Spec("netlib-lapack++shared") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("^openblas+shared") assert spec.satisfies("^perl+shared") @@ -714,7 +716,7 @@ def test_concretize_propagate_variant_second_level_dep_not_in_source(self): when the variant is not in the source package or any of the first level dependencies""" spec = Spec("parent-foo-bar ++fee") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec.satisfies("^second-dependency-foo-bar-fee +fee") assert not spec.satisfies("parent-foo-bar +fee") @@ -724,12 +726,12 @@ def test_no_matching_compiler_specs(self, mock_low_high_config): with spack.concretize.enable_compiler_existence_check(): s = Spec("pkg-a %gcc@=0.0.0") with pytest.raises(spack.concretize.UnavailableCompilerVersionError): - s.concretize() + s = spack.concretize.concretized(s) def test_no_compilers_for_arch(self): s = Spec("pkg-a arch=linux-rhel0-x86_64") with pytest.raises(spack.error.SpackError): - s.concretize() + s = spack.concretize.concretized(s) def test_virtual_is_fully_expanded_for_callpath(self): # force dependence on fake "zmpi" by asking for MPI 10.0 @@ -737,7 +739,7 @@ def test_virtual_is_fully_expanded_for_callpath(self): assert len(spec.dependencies(name="mpi")) == 1 assert "fake" not in spec - spec.concretize() + spec = spack.concretize.concretized(spec) assert len(spec.dependencies(name="zmpi")) == 1 assert all(not d.dependencies(name="mpi") for d in spec.traverse()) assert all(x in spec for x in ("zmpi", "mpi")) @@ -751,7 +753,7 @@ def test_virtual_is_fully_expanded_for_mpileaks(self): assert len(spec.dependencies(name="mpi")) == 1 assert "fake" not in spec - spec.concretize() + spec = spack.concretize.concretized(spec) assert len(spec.dependencies(name="zmpi")) == 1 assert len(spec.dependencies(name="callpath")) == 1 @@ -767,13 +769,13 @@ def test_virtual_is_fully_expanded_for_mpileaks(self): @pytest.mark.parametrize("compiler_str", ["clang", "gcc", "gcc@10.2.1", "clang@:15.0.0"]) def test_compiler_inheritance(self, compiler_str): spec_str = "mpileaks %{0}".format(compiler_str) - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) assert spec["libdwarf"].compiler.satisfies(compiler_str) assert spec["libelf"].compiler.satisfies(compiler_str) def test_external_package(self): spec = Spec("externaltool%gcc") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec["externaltool"].external_path == os.path.sep + os.path.join( "path", "to", "external_tool" ) @@ -786,12 +788,12 @@ def test_nobuild_package(self): """ spec = Spec("externaltool%clang") with pytest.raises(spack.error.SpecError): - spec.concretize() + spec = spack.concretize.concretized(spec) def test_external_and_virtual(self, mutable_config): mutable_config.set("packages:stuff", {"buildable": False}) spec = Spec("externaltest") - spec.concretize() + spec = spack.concretize.concretized(spec) assert spec["externaltool"].external_path == os.path.sep + os.path.join( "path", "to", "external_tool" ) @@ -803,26 +805,26 @@ def test_external_and_virtual(self, mutable_config): def test_compiler_child(self): s = Spec("mpileaks%clang target=x86_64 ^dyninst%gcc") - s.concretize() + s = spack.concretize.concretized(s) assert s["mpileaks"].satisfies("%clang") assert s["dyninst"].satisfies("%gcc") def test_conflicts_in_spec(self, conflict_spec): s = Spec(conflict_spec) with pytest.raises(spack.error.SpackError): - s.concretize() + s = spack.concretize.concretized(s) def test_conflicts_show_cores(self, conflict_spec, monkeypatch): s = Spec(conflict_spec) with pytest.raises(spack.error.SpackError) as e: - s.concretize() + s = spack.concretize.concretized(s) assert "conflict" in e.value.message def test_conflict_in_all_directives_true(self): s = Spec("when-directives-true") with pytest.raises(spack.error.SpackError): - s.concretize() + s = spack.concretize.concretized(s) @pytest.mark.parametrize("spec_str", ["conflict@10.0%clang+foo"]) def test_no_conflict_in_external_specs(self, spec_str): @@ -831,7 +833,7 @@ def test_no_conflict_in_external_specs(self, spec_str): ext = Spec(spec_str) data = {"externals": [{"spec": spec_str, "prefix": "/fake/path"}]} spack.config.set("packages::{0}".format(ext.name), data) - ext.concretize() # failure raises exception + ext = spack.concretize.concretized(ext) # failure raises exception def test_regression_issue_4492(self): # Constructing a spec which has no dependencies, but is otherwise @@ -840,7 +842,7 @@ def test_regression_issue_4492(self): # cache values. s = Spec("mpileaks") - s.concretize() + s = spack.concretize.concretized(s) # Check that now the Spec is concrete, store the hash assert s.concrete @@ -858,7 +860,7 @@ def test_regression_issue_7239(self): # Normal Spec s = Spec("mpileaks") - s.concretize() + s = spack.concretize.concretized(s) assert llnl.util.lang.ObjectWrapper not in s.__class__.__mro__ @@ -875,7 +877,7 @@ def test_regression_issue_7705(self): # spec.package.provides(name) doesn't account for conditional # constraints in the concretized spec s = Spec("simple-inheritance~openblas") - s.concretize() + s = spack.concretize.concretized(s) assert not s.package.provides("lapack") @@ -887,8 +889,8 @@ def test_regression_issue_7941(self): s = Spec("pkg-a foobar=bar ^pkg-b") t = Spec(str(s)) - s.concretize() - t.concretize() + s = spack.concretize.concretized(s) + t = spack.concretize.concretized(t) assert s.dag_hash() == t.dag_hash() @@ -930,7 +932,7 @@ def test_simultaneous_concretization_of_specs(self, abstract_specs): def test_noversion_pkg(self, spec): """Test concretization failures for no-version packages.""" with pytest.raises(spack.error.SpackError): - Spec(spec).concretized() + spack.concretize.concretized(Spec(spec)) @pytest.mark.not_on_windows("Not supported on Windows (yet)") # Include targets to prevent regression on 20537 @@ -950,29 +952,33 @@ def test_adjusting_default_target_based_on_compiler( best_achievable = archspec.cpu.TARGETS[best_achievable] expected = best_achievable if best_achievable < current_host else current_host with spack.concretize.disable_compiler_existence_check(): - s = Spec(spec).concretized() + s = spack.concretize.concretized(Spec(spec)) assert str(s.architecture.target) == str(expected) def test_compiler_version_matches_any_entry_in_compilers_yaml(self): # The behavior here has changed since #8735 / #14730. Now %gcc@10.2 is an abstract # compiler spec, and it should first find a matching compiler gcc@=10.2.1 - assert Spec("mpileaks %gcc@10.2").concretized().compiler == CompilerSpec("gcc@=10.2.1") - assert Spec("mpileaks %gcc@10.2:").concretized().compiler == CompilerSpec("gcc@=10.2.1") + assert spack.concretize.concretized(Spec("mpileaks %gcc@10.2")).compiler == CompilerSpec( + "gcc@=10.2.1" + ) + assert spack.concretize.concretized(Spec("mpileaks %gcc@10.2:")).compiler == CompilerSpec( + "gcc@=10.2.1" + ) # This compiler does not exist with pytest.raises(spack.concretize.UnavailableCompilerVersionError): - Spec("mpileaks %gcc@=10.2").concretized() + spack.concretize.concretized(Spec("mpileaks %gcc@=10.2")) def test_concretize_anonymous(self): with pytest.raises(spack.error.SpackError): s = Spec("+variant") - s.concretize() + s = spack.concretize.concretized(s) @pytest.mark.parametrize("spec_str", ["mpileaks ^%gcc", "mpileaks ^cflags=-g"]) def test_concretize_anonymous_dep(self, spec_str): with pytest.raises(spack.error.SpackError): s = Spec(spec_str) - s.concretize() + s = spack.concretize.concretized(s) @pytest.mark.parametrize( "spec_str,expected_str", @@ -989,7 +995,7 @@ def test_compiler_conflicts_in_package_py( self, spec_str, expected_str, clang12_with_flags, gcc11_with_flags ): with spack.config.override("compilers", [clang12_with_flags, gcc11_with_flags]): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.satisfies(expected_str) @pytest.mark.parametrize( @@ -1010,7 +1016,7 @@ def test_compiler_conflicts_in_package_py( ], ) def test_conditional_variants(self, spec_str, expected, unexpected): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for var in expected: assert s.satisfies("%s=*" % var) @@ -1030,7 +1036,7 @@ def test_conditional_variants_fail(self, bad_spec): with pytest.raises( (spack.error.UnsatisfiableSpecError, spack.spec.InvalidVariantForSpecError) ): - _ = Spec("conditional-variant-pkg" + bad_spec).concretized() + _ = spack.concretize.concretized(Spec("conditional-variant-pkg" + bad_spec)) @pytest.mark.parametrize( "spec_str,expected,unexpected", @@ -1051,7 +1057,7 @@ def test_conditional_dependencies(self, spec_str, expected, unexpected, fuzz_dep """ fuzz_dep_order("py-extension3") # test forwards and backwards - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for dep in expected: msg = '"{0}" is not in "{1}" and was expected' @@ -1075,7 +1081,7 @@ def test_conditional_dependencies(self, spec_str, expected, unexpected, fuzz_dep ], ) def test_patching_dependencies(self, spec_str, patched_deps): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for dep, num_patches in patched_deps: assert s[dep].satisfies("patches=*") @@ -1103,7 +1109,7 @@ def test_patching_dependencies(self, spec_str, patched_deps): ], ) def test_working_around_conflicting_defaults(self, spec_str, expected): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.concrete for constraint in expected: @@ -1123,7 +1129,7 @@ def test_external_package_and_compiler_preferences(self, spec_str, expected, mut }, } mutable_config.set("packages", packages_yaml) - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.external for condition in expected: @@ -1139,13 +1145,13 @@ def test_package_with_constraint_not_met_by_external(self): spack.config.set("packages", packages_yaml) # quantum-espresso+veritas requires libelf@:0.8.12 - s = Spec("quantum-espresso+veritas").concretized() + s = spack.concretize.concretized(Spec("quantum-espresso+veritas")) assert s.satisfies("^libelf@0.8.12") assert not s["libelf"].external @pytest.mark.regression("9744") def test_cumulative_version_ranges_with_different_length(self): - s = Spec("cumulative-vrange-root").concretized() + s = spack.concretize.concretized(Spec("cumulative-vrange-root")) assert s.concrete assert s.satisfies("^cumulative-vrange-bottom@2.2") @@ -1155,15 +1161,15 @@ def test_dependency_conditional_on_another_dependency_state(self): dep_str = "variant-on-dependency-condition-a" spec_str = "{0} ^{1}".format(root_str, dep_str) - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.concrete assert s.satisfies("^variant-on-dependency-condition-b") - s = Spec(spec_str + "+x").concretized() + s = spack.concretize.concretized(Spec(spec_str + "+x")) assert s.concrete assert s.satisfies("^variant-on-dependency-condition-b") - s = Spec(spec_str + "~x").concretized() + s = spack.concretize.concretized(Spec(spec_str + "~x")) assert s.concrete assert not s.satisfies("^variant-on-dependency-condition-b") @@ -1177,7 +1183,7 @@ def test_compiler_constraint_with_external_package(self, spec_str, expected): } spack.config.set("packages", packages_yaml) - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.external assert s.satisfies(expected) @@ -1214,12 +1220,12 @@ def test_compiler_in_nonbuildable_external_package( } spack.config.set("packages", packages_yaml) - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.satisfies(expected) assert "external-common-perl" not in [d.name for d in s.dependencies()] def test_external_that_would_require_a_virtual_dependency(self): - s = Spec("requires-virtual").concretized() + s = spack.concretize.concretized(Spec("requires-virtual")) assert s.external assert "stuff" not in s @@ -1227,7 +1233,7 @@ def test_external_that_would_require_a_virtual_dependency(self): def test_transitive_conditional_virtual_dependency(self, mutable_config): """Test that an external is used as provider if the virtual is non-buildable""" mutable_config.set("packages:stuff", {"buildable": False}) - s = Spec("transitive-conditional-virtual-dependency").concretized() + s = spack.concretize.concretized(Spec("transitive-conditional-virtual-dependency")) # Test that the default +stuff~mpi is maintained, and the right provider is selected assert s.satisfies("^conditional-virtual-dependency +stuff~mpi") @@ -1237,7 +1243,7 @@ def test_transitive_conditional_virtual_dependency(self, mutable_config): def test_conditional_provides_or_depends_on(self): # Check that we can concretize correctly a spec that can either # provide a virtual or depend on it based on the value of a variant - s = Spec("conditional-provider +disable-v1").concretized() + s = spack.concretize.concretized(Spec("conditional-provider +disable-v1")) assert "v1-provider" in s assert s["v1"].name == "v1-provider" assert s["v2"].name == "conditional-provider" @@ -1259,7 +1265,7 @@ def test_conditional_provides_or_depends_on(self): ], ) def test_activating_test_dependencies(self, spec_str, tests_arg, with_dep, without_dep): - s = Spec(spec_str).concretized(tests=tests_arg) + s = spack.concretize.concretized(Spec(spec_str), tests=tests_arg) for pkg_name in with_dep: msg = "Cannot find test dependency in package '{0}'" @@ -1281,22 +1287,22 @@ def test_compiler_match_is_preferred_to_newer_version(self, compiler_factory): "compilers", [compiler_factory(spec="gcc@10.1.0", operating_system="redhat6")] ): spec_str = "simple-inheritance+openblas %gcc@10.1.0 os=redhat6" - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert "openblas@0.2.15" in s assert s["openblas"].satisfies("%gcc@10.1.0") @pytest.mark.regression("19981") def test_target_ranges_in_conflicts(self): with pytest.raises(spack.error.SpackError): - Spec("impossible-concretization").concretized() + spack.concretize.concretized(Spec("impossible-concretization")) def test_target_compatibility(self): with pytest.raises(spack.error.SpackError): - Spec("libdwarf target=x86_64 ^libelf target=x86_64_v2").concretized() + spack.concretize.concretized(Spec("libdwarf target=x86_64 ^libelf target=x86_64_v2")) @pytest.mark.regression("20040") def test_variant_not_default(self): - s = Spec("ecp-viz-sdk").concretized() + s = spack.concretize.concretized(Spec("ecp-viz-sdk")) # Check default variant value for the package assert "+dep" in s["conditional-constrained-dependencies"] @@ -1311,7 +1317,7 @@ def test_custom_compiler_version(self, mutable_config, compiler_factory, monkeyp "compilers", [compiler_factory(spec="gcc@10foo", operating_system="redhat6")] ) monkeypatch.setattr(spack.compiler.Compiler, "real_version", "10.2.1") - s = Spec("pkg-a %gcc@10foo os=redhat6").concretized() + s = spack.concretize.concretized(Spec("pkg-a %gcc@10foo os=redhat6")) assert "%gcc@10foo" in s def test_all_patches_applied(self): @@ -1322,11 +1328,11 @@ def test_all_patches_applied(self): ) localpatch = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" spec = Spec("conditionally-patch-dependency+jasper") - spec.concretize() + spec = spack.concretize.concretized(spec) assert (uuidpatch, localpatch) == spec["libelf"].variants["patches"].value def test_dont_select_version_that_brings_more_variants_in(self): - s = Spec("dep-with-variants-if-develop-root").concretized() + s = spack.concretize.concretized(Spec("dep-with-variants-if-develop-root")) assert s["dep-with-variants-if-develop"].satisfies("@1.0") @pytest.mark.regression("20244,20736") @@ -1353,7 +1359,7 @@ def test_dont_select_version_that_brings_more_variants_in(self): ], ) def test_external_package_versions(self, spec_str, is_external, expected): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.external == is_external assert s.satisfies(expected) @@ -1382,7 +1388,7 @@ def test_reuse_does_not_overwrite_dev_specs( second_spec = spec if dev_first else dev_spec # concretize and setup spack to reuse in the appropriate manner - first_spec.concretize() + first_spec = spack.concretize.concretized(first_spec) def mock_fn(*args, **kwargs): return [first_spec] @@ -1394,7 +1400,7 @@ def mock_fn(*args, **kwargs): # concretize and ensure we did not reuse with spack.config.override("concretizer:reuse", True): - second_spec.concretize() + second_spec = spack.concretize.concretized(second_spec) assert first_spec.dag_hash() != second_spec.dag_hash() @pytest.mark.regression("20292") @@ -1413,7 +1419,7 @@ def test_reuse_installed_packages_when_package_def_changes( spack.config.set("concretizer:reuse", False) # Install a spec - root = Spec("root").concretized() + root = spack.concretize.concretized(Spec("root")) dependency = root["changing"].copy() PackageInstaller([root.package], fake=True, explicit=True).install() @@ -1421,9 +1427,11 @@ def test_reuse_installed_packages_when_package_def_changes( repo_with_changing_recipe.change(context) # Try to concretize with the spec installed previously - new_root_with_reuse = Spec("root ^/{0}".format(dependency.dag_hash())).concretized() + new_root_with_reuse = spack.concretize.concretized( + Spec("root ^/{0}".format(dependency.dag_hash())) + ) - new_root_without_reuse = Spec("root").concretized() + new_root_without_reuse = spack.concretize.concretized(Spec("root")) # validate that the graphs are the same with reuse, but not without assert ht.build_hash(root) == ht.build_hash(new_root_with_reuse) @@ -1440,23 +1448,23 @@ def test_no_reuse_when_variant_condition_does_not_hold(self, mutable_database, m spack.config.set("concretizer:reuse", True) # Install a spec for which the `version_based` variant condition does not hold - old = Spec("conditional-variant-pkg @1").concretized() + old = spack.concretize.concretized(Spec("conditional-variant-pkg @1")) PackageInstaller([old.package], fake=True, explicit=True).install() # Then explicitly require a spec with `+version_based`, which shouldn't reuse previous spec - new1 = Spec("conditional-variant-pkg +version_based").concretized() + new1 = spack.concretize.concretized(Spec("conditional-variant-pkg +version_based")) assert new1.satisfies("@2 +version_based") - new2 = Spec("conditional-variant-pkg +two_whens").concretized() + new2 = spack.concretize.concretized(Spec("conditional-variant-pkg +two_whens")) assert new2.satisfies("@2 +two_whens +version_based") def test_reuse_with_flags(self, mutable_database, mutable_config): spack.config.set("concretizer:reuse", True) - spec = Spec("pkg-a cflags=-g cxxflags=-g").concretized() + spec = spack.concretize.concretized(Spec("pkg-a cflags=-g cxxflags=-g")) PackageInstaller([spec.package], fake=True, explicit=True).install() testspec = Spec("pkg-a cflags=-g") - testspec.concretize() + testspec = spack.concretize.concretized(testspec) assert testspec == spec @pytest.mark.regression("20784") @@ -1464,7 +1472,7 @@ def test_concretization_of_test_dependencies(self): # With clingo we emit dependency_conditions regardless of the type # of the dependency. We need to ensure that there's at least one # dependency type declared to infer that the dependency holds. - s = Spec("test-dep-with-imposed-conditions").concretized() + s = spack.concretize.concretized(Spec("test-dep-with-imposed-conditions")) assert "c" not in s @pytest.mark.parametrize( @@ -1473,7 +1481,7 @@ def test_concretization_of_test_dependencies(self): def test_error_message_for_inconsistent_variants(self, spec_str): s = Spec(spec_str) with pytest.raises(vt.UnknownVariantError): - s.concretize() + s = spack.concretize.concretized(s) @pytest.mark.regression("22533") @pytest.mark.parametrize( @@ -1488,7 +1496,7 @@ def test_error_message_for_inconsistent_variants(self, spec_str): ], ) def test_mv_variants_disjoint_sets_from_spec(self, spec_str, variant_name, expected_values): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert set(expected_values) == set(s.variants[variant_name].value) @pytest.mark.regression("22533") @@ -1501,14 +1509,14 @@ def test_mv_variants_disjoint_sets_from_packages_yaml(self): } spack.config.set("packages", external_mvapich2) - s = Spec("mvapich2").concretized() + s = spack.concretize.concretized(Spec("mvapich2")) assert set(s.variants["file_systems"].value) == set(["ufs", "nfs"]) @pytest.mark.regression("22596") def test_external_with_non_default_variant_as_dependency(self): # This package depends on another that is registered as an external # with 'buildable: true' and a variant with a non-default value set - s = Spec("trigger-external-non-default-variant").concretized() + s = spack.concretize.concretized(Spec("trigger-external-non-default-variant")) assert "~foo" in s["external-non-default-variant"] assert "~bar" in s["external-non-default-variant"] @@ -1532,7 +1540,7 @@ def test_os_selection_when_multiple_choices_are_possible( with spack.config.override( "compilers", [compiler_factory(spec="gcc@10.2.1", operating_system="redhat6")] ): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for node in s.traverse(): if node.name == "glibc": continue @@ -1544,7 +1552,7 @@ def test_os_selection_when_multiple_choices_are_possible( [("mpileaks", "%gcc@10.2.1"), ("mpileaks ^mpich%clang@15.0.0", "%clang@15.0.0")], ) def test_compiler_is_unique(self, spec_str, expected_compiler): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for node in s.traverse(): assert node.satisfies(expected_compiler) @@ -1559,7 +1567,7 @@ def test_compiler_is_unique(self, spec_str, expected_compiler): ], ) def test_multivalued_variants_from_cli(self, spec_str, expected_dict): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for constraint, value in expected_dict.items(): assert s.satisfies(constraint) == value @@ -1576,7 +1584,7 @@ def test_multivalued_variants_from_cli(self, spec_str, expected_dict): ) def test_deprecated_versions_not_selected(self, spec_str, expected): with spack.config.override("config:deprecated", True): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) s.satisfies(expected) @pytest.mark.regression("24196") @@ -1585,7 +1593,7 @@ def test_version_badness_more_important_than_default_mv_variants(self): # a transitive dependency with a multi-valued variant, that old # version was preferred because of the order of our optimization # criteria. - s = Spec("root").concretized() + s = spack.concretize.concretized(Spec("root")) assert s["gmt"].satisfies("@2.0") @pytest.mark.regression("24205") @@ -1594,7 +1602,7 @@ def test_provider_must_meet_requirements(self): # requirements are met. s = Spec("unsat-virtual-dependency") with pytest.raises((RuntimeError, spack.error.UnsatisfiableSpecError)): - s.concretize() + s = spack.concretize.concretized(s) @pytest.mark.regression("23951") def test_newer_dependency_adds_a_transitive_virtual(self): @@ -1606,7 +1614,7 @@ def test_newer_dependency_adds_a_transitive_virtual(self): # root@1.0 <- middle@1.0 <- leaf@1.0 # # and "blas" is pulled in only by newer versions of "leaf" - s = Spec("root-adds-virtual").concretized() + s = spack.concretize.concretized(Spec("root-adds-virtual")) assert s["leaf-adds-virtual"].satisfies("@2.0") assert "blas" in s @@ -1614,12 +1622,12 @@ def test_newer_dependency_adds_a_transitive_virtual(self): def test_versions_in_virtual_dependencies(self): # Ensure that a package that needs a given version of a virtual # package doesn't end up using a later implementation - s = Spec("hpcviewer@2019.02").concretized() + s = spack.concretize.concretized(Spec("hpcviewer@2019.02")) assert s["java"].satisfies("virtual-with-versions@1.8.0") @pytest.mark.regression("26866") def test_non_default_provider_of_multiple_virtuals(self): - s = Spec("many-virtual-consumer ^low-priority-provider").concretized() + s = spack.concretize.concretized(Spec("many-virtual-consumer ^low-priority-provider")) assert s["mpi"].name == "low-priority-provider" assert s["lapack"].name == "low-priority-provider" @@ -1642,7 +1650,7 @@ def test_concrete_specs_are_not_modified_on_reuse( # like additional constraints being added to concrete specs in # the answer set produced by clingo. with spack.config.override("concretizer:reuse", True): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) assert s.installed is expect_installed assert s.satisfies(spec_str) @@ -1653,12 +1661,12 @@ def test_sticky_variant_in_package(self): # to have +allow-gcc set to be concretized with %gcc and clingo is not allowed # to change the default ~allow-gcc with pytest.raises(spack.error.SpackError): - Spec("sticky-variant %gcc").concretized() + spack.concretize.concretized(Spec("sticky-variant %gcc")) - s = Spec("sticky-variant+allow-gcc %gcc").concretized() + s = spack.concretize.concretized(Spec("sticky-variant+allow-gcc %gcc")) assert s.satisfies("%gcc") and s.satisfies("+allow-gcc") - s = Spec("sticky-variant %clang").concretized() + s = spack.concretize.concretized(Spec("sticky-variant %clang")) assert s.satisfies("%clang") and s.satisfies("~allow-gcc") @pytest.mark.regression("42172") @@ -1677,7 +1685,7 @@ def test_sticky_variant_in_external(self, spec, allow_gcc): maybe = llnl.util.lang.nullcontext if allow_gcc else pytest.raises with maybe(spack.error.SpackError): - s = Spec("sticky-variant-dependent%gcc").concretized() + s = spack.concretize.concretized(Spec("sticky-variant-dependent%gcc")) if allow_gcc: assert s.satisfies("%gcc") @@ -1687,10 +1695,10 @@ def test_sticky_variant_in_external(self, spec, allow_gcc): def test_do_not_invent_new_concrete_versions_unless_necessary(self): # ensure we select a known satisfying version rather than creating # a new '2.7' version. - assert ver("=2.7.11") == Spec("python@2.7").concretized().version + assert ver("=2.7.11") == spack.concretize.concretized(Spec("python@2.7")).version # Here there is no known satisfying version - use the one on the spec. - assert ver("=2.7.21") == Spec("python@=2.7.21").concretized().version + assert ver("=2.7.21") == spack.concretize.concretized(Spec("python@=2.7.21")).version @pytest.mark.parametrize( "spec_str,valid", @@ -1709,14 +1717,14 @@ def test_conditional_values_in_variants(self, spec_str, valid): s = Spec(spec_str) raises = pytest.raises((RuntimeError, spack.error.UnsatisfiableSpecError)) with llnl.util.lang.nullcontext() if valid else raises: - s.concretize() + s = spack.concretize.concretized(s) def test_conditional_values_in_conditional_variant(self): """Test that conditional variants play well with conditional possible values""" - s = Spec("conditional-values-in-variant@1.50.0").concretized() + s = spack.concretize.concretized(Spec("conditional-values-in-variant@1.50.0")) assert "cxxstd" not in s.variants - s = Spec("conditional-values-in-variant@1.60.0").concretized() + s = spack.concretize.concretized(Spec("conditional-values-in-variant@1.60.0")) assert "cxxstd" in s.variants def test_target_granularity(self): @@ -1725,9 +1733,9 @@ def test_target_granularity(self): default_target = spack.platforms.test.Test.default generic_target = archspec.cpu.TARGETS[default_target].generic.name s = Spec("python") - assert s.concretized().satisfies("target=%s" % default_target) + assert spack.concretize.concretized(s).satisfies("target=%s" % default_target) with spack.config.override("concretizer:targets", {"granularity": "generic"}): - assert s.concretized().satisfies("target=%s" % generic_target) + assert spack.concretize.concretized(s).satisfies("target=%s" % generic_target) def test_host_compatible_concretization(self): # Check that after setting "host_compatible" to false we cannot concretize. @@ -1736,16 +1744,16 @@ def test_host_compatible_concretization(self): # is that the defaults for the test platform are very old, so there's no # compiler supporting e.g. icelake etc. s = Spec("python target=k10") - assert s.concretized() + assert spack.concretize.concretized(s) with spack.config.override("concretizer:targets", {"host_compatible": True}): with pytest.raises(spack.error.SpackError): - s.concretized() + spack.concretize.concretized(s) def test_add_microarchitectures_on_explicit_request(self): # Check that if we consider only "generic" targets, we can still solve for # specific microarchitectures on explicit requests with spack.config.override("concretizer:targets", {"granularity": "generic"}): - s = Spec("python target=k10").concretized() + s = spack.concretize.concretized(Spec("python target=k10")) assert s.satisfies("target=k10") @pytest.mark.regression("29201") @@ -1753,12 +1761,12 @@ def test_delete_version_and_reuse(self, mutable_database, repo_with_changing_rec """Test that we can reuse installed specs with versions not declared in package.py """ - root = Spec("root").concretized() + root = spack.concretize.concretized(Spec("root")) PackageInstaller([root.package], fake=True, explicit=True).install() repo_with_changing_recipe.change({"delete_version": True}) with spack.config.override("concretizer:reuse", True): - new_root = Spec("root").concretized() + new_root = spack.concretize.concretized(Spec("root")) assert root.dag_hash() == new_root.dag_hash() @@ -1771,12 +1779,12 @@ def test_installed_version_is_selected_only_for_reuse( """ # Install a dependency that cannot be reused with "root" # because of a conflict in a variant, then delete its version - dependency = Spec("changing@1.0~foo").concretized() + dependency = spack.concretize.concretized(Spec("changing@1.0~foo")) PackageInstaller([dependency.package], fake=True, explicit=True).install() repo_with_changing_recipe.change({"delete_version": True}) with spack.config.override("concretizer:reuse", True): - new_root = Spec("root").concretized() + new_root = spack.concretize.concretized(Spec("root")) assert not new_root["changing"].satisfies("@1.0") @@ -1785,12 +1793,12 @@ def test_reuse_with_unknown_namespace_dont_raise( self, temporary_store, mock_custom_repository ): with spack.repo.use_repositories(mock_custom_repository, override=False): - s = Spec("pkg-c").concretized() + s = spack.concretize.concretized(Spec("pkg-c")) assert s.namespace != "builtin.mock" PackageInstaller([s.package], fake=True, explicit=True).install() with spack.config.override("concretizer:reuse", True): - s = Spec("pkg-c").concretized() + s = spack.concretize.concretized(Spec("pkg-c")) assert s.namespace == "builtin.mock" @pytest.mark.regression("45538") @@ -1798,12 +1806,12 @@ def test_reuse_from_other_namespace_no_raise(self, tmpdir, temporary_store, monk myrepo = spack.repo.MockRepositoryBuilder(tmpdir.mkdir("mock.repo"), namespace="myrepo") myrepo.add_package("zlib") - builtin = Spec("zlib").concretized() + builtin = spack.concretize.concretized(Spec("zlib")) PackageInstaller([builtin.package], fake=True, explicit=True).install() with spack.repo.use_repositories(myrepo.root, override=False): with spack.config.override("concretizer:reuse", True): - myrepo = Spec("myrepo.zlib").concretized() + myrepo = spack.concretize.concretized(Spec("myrepo.zlib")) assert myrepo.namespace == "myrepo" @@ -1812,7 +1820,7 @@ def test_reuse_with_unknown_package_dont_raise(self, tmpdir, temporary_store, mo builder = spack.repo.MockRepositoryBuilder(tmpdir.mkdir("mock.repo"), namespace="myrepo") builder.add_package("pkg-c") with spack.repo.use_repositories(builder.root, override=False): - s = Spec("pkg-c").concretized() + s = spack.concretize.concretized(Spec("pkg-c")) assert s.namespace == "myrepo" PackageInstaller([s.package], fake=True, explicit=True).install() @@ -1823,7 +1831,7 @@ def test_reuse_with_unknown_package_dont_raise(self, tmpdir, temporary_store, mo # TODO (INJECT CONFIGURATION): unclear why the cache needs to be invalidated explicitly repos.repos[0]._pkg_checker.invalidate() with spack.config.override("concretizer:reuse", True): - s = Spec("pkg-c").concretized() + s = spack.concretize.concretized(Spec("pkg-c")) assert s.namespace == "builtin.mock" @pytest.mark.parametrize( @@ -1917,7 +1925,7 @@ def test_solve_in_rounds_all_unsolved(self, monkeypatch, mock_packages): def test_coconcretize_reuse_and_virtuals(self): reusable_specs = [] for s in ["mpileaks ^mpich", "zmpi"]: - reusable_specs.extend(Spec(s).concretized().traverse(root=True)) + reusable_specs.extend(spack.concretize.concretized(Spec(s)).traverse(root=True)) root_specs = [Spec("mpileaks"), Spec("zmpi")] @@ -1934,7 +1942,7 @@ def test_misleading_error_message_on_version(self, mutable_database): # For this bug to be triggered we need a reusable dependency # that is not optimal in terms of optimization scores. # We pick an old version of "b" - reusable_specs = [Spec("non-existing-conditional-dep@1.0").concretized()] + reusable_specs = [spack.concretize.concretized(Spec("non-existing-conditional-dep@1.0"))] root_spec = Spec("non-existing-conditional-dep@2.0") with spack.config.override("concretizer:reuse", True): @@ -1948,7 +1956,9 @@ def test_misleading_error_message_on_version(self, mutable_database): @pytest.mark.regression("31148") def test_version_weight_and_provenance(self): """Test package preferences during coconcretization.""" - reusable_specs = [Spec(spec_str).concretized() for spec_str in ("pkg-b@0.9", "pkg-b@1.0")] + reusable_specs = [ + spack.concretize.concretized(Spec(spec_str)) for spec_str in ("pkg-b@0.9", "pkg-b@1.0") + ] root_spec = Spec("pkg-a foobar=bar") with spack.config.override("concretizer:reuse", True): @@ -1979,7 +1989,7 @@ def test_version_weight_and_provenance(self): def test_reuse_succeeds_with_config_compatible_os(self): root_spec = Spec("pkg-b") - s = root_spec.concretized() + s = spack.concretize.concretized(root_spec) other_os = s.copy() mock_os = "ubuntu2204" other_os.architecture = spack.spec.ArchSpec( @@ -1998,13 +2008,13 @@ def test_reuse_succeeds_with_config_compatible_os(self): def test_git_hash_assigned_version_is_preferred(self): hash = "a" * 40 s = Spec("develop-branch-version@%s=develop" % hash) - c = s.concretized() + c = spack.concretize.concretized(s) assert hash in str(c) @pytest.mark.parametrize("git_ref", ("a" * 40, "0.2.15", "main")) def test_git_ref_version_is_equivalent_to_specified_version(self, git_ref): s = Spec("develop-branch-version@git.%s=develop" % git_ref) - c = s.concretized() + c = spack.concretize.concretized(s) assert git_ref in str(c) print(str(c)) assert s.satisfies("@develop") @@ -2014,7 +2024,7 @@ def test_git_ref_version_is_equivalent_to_specified_version(self, git_ref): def test_git_ref_version_succeeds_with_unknown_version(self, git_ref): # main is not defined in the package.py for this file s = Spec("develop-branch-version@git.%s=main" % git_ref) - s.concretize() + s = spack.concretize.concretized(s) assert s.satisfies("develop-branch-version@main") @pytest.mark.regression("31484") @@ -2031,7 +2041,7 @@ def test_installed_externals_are_reused( spack.config.set("packages", external_conf) # Install the external spec - external1 = Spec("changing@1.0").concretized() + external1 = spack.concretize.concretized(Spec("changing@1.0")) PackageInstaller([external1.package], fake=True, explicit=True).install() assert external1.external @@ -2040,12 +2050,12 @@ def test_installed_externals_are_reused( # Try to concretize the external without reuse and confirm the hash changed with spack.config.override("concretizer:reuse", False): - external2 = Spec("changing@1.0").concretized() + external2 = spack.concretize.concretized(Spec("changing@1.0")) assert external2.dag_hash() != external1.dag_hash() # ... while with reuse we have the same hash with spack.config.override("concretizer:reuse", True): - external3 = Spec("changing@1.0").concretized() + external3 = spack.concretize.concretized(Spec("changing@1.0")) assert external3.dag_hash() == external1.dag_hash() @pytest.mark.regression("31484") @@ -2062,18 +2072,18 @@ def test_user_can_select_externals_with_require(self, mutable_database, tmp_path # mpich and others are installed, so check that # fresh use the external, reuse does not with spack.config.override("concretizer:reuse", False): - mpi_spec = Spec("mpi").concretized() + mpi_spec = spack.concretize.concretized(Spec("mpi")) assert mpi_spec.name == "multi-provider-mpi" with spack.config.override("concretizer:reuse", True): - mpi_spec = Spec("mpi").concretized() + mpi_spec = spack.concretize.concretized(Spec("mpi")) assert mpi_spec.name != "multi-provider-mpi" external_conf["mpi"]["require"] = "multi-provider-mpi" spack.config.set("packages", external_conf) with spack.config.override("concretizer:reuse", True): - mpi_spec = Spec("mpi").concretized() + mpi_spec = spack.concretize.concretized(Spec("mpi")) assert mpi_spec.name == "multi-provider-mpi" @pytest.mark.regression("31484") @@ -2087,12 +2097,12 @@ def test_installed_specs_disregard_conflicts(self, mutable_database, monkeypatch # If we concretize with --fresh the conflict is taken into account with spack.config.override("concretizer:reuse", False): - s = Spec("mpich").concretized() + s = spack.concretize.concretized(Spec("mpich")) assert s.satisfies("+debug") # If we concretize with --reuse it is not, since "mpich~debug" was already installed with spack.config.override("concretizer:reuse", True): - s = Spec("mpich").concretized() + s = spack.concretize.concretized(Spec("mpich")) assert s.installed assert s.satisfies("~debug"), s @@ -2104,7 +2114,7 @@ def test_require_targets_are_allowed(self, mutable_database): spack.config.set("packages", external_conf) with spack.config.override("concretizer:reuse", False): - spec = Spec("mpich").concretized() + spec = spack.concretize.concretized(Spec("mpich")) for s in spec.traverse(): assert s.satisfies("target=%s" % spack.platforms.test.Test.front_end) @@ -2121,7 +2131,7 @@ def test_external_python_extensions_have_dependency(self): } spack.config.set("packages", external_conf) - spec = Spec("py-extension2").concretized() + spec = spack.concretize.concretized(Spec("py-extension2")) assert "python" in spec["py-extension1"] assert spec["python"] == spec["py-extension1"]["python"] @@ -2149,7 +2159,7 @@ def test_external_python_extension_find_dependency_from_config(self, python_spec } spack.config.set("packages", external_conf) - spec = Spec("py-extension1").concretized() + spec = spack.concretize.concretized(Spec("py-extension1")) assert "python" in spec["py-extension1"] assert spec["python"].prefix == fake_path @@ -2173,7 +2183,7 @@ def test_external_python_extension_find_dependency_from_installed(self, monkeypa spack.config.set("packages", external_conf) # install python external - python = Spec("python").concretized() + python = spack.concretize.concretized(Spec("python")) def query(*args, **kwargs): return [python] @@ -2184,7 +2194,7 @@ def query(*args, **kwargs): external_conf.pop("python") spack.config.set("packages", external_conf) - spec = Spec("py-extension1").concretized() + spec = spack.concretize.concretized(Spec("py-extension1")) assert "python" in spec["py-extension1"] assert spec["python"].prefix == fake_path @@ -2213,7 +2223,7 @@ def find_fake_python(classes, path_hints): } spack.config.set("packages", external_conf) - spec = Spec("py-extension1").concretized() + spec = spack.concretize.concretized(Spec("py-extension1")) assert "python" in spec["py-extension1"] assert spec["python"].prefix == prefix @@ -2279,7 +2289,7 @@ def test_clear_error_when_unknown_compiler_requested(self, mock_packages): with pytest.raises( spack.error.UnsatisfiableSpecError, match="Cannot set the required compiler: pkg-a%foo" ): - Spec("pkg-a %foo").concretized() + spack.concretize.concretized(Spec("pkg-a %foo")) @pytest.mark.regression("36339") def test_compiler_match_constraints_when_selected(self): @@ -2315,7 +2325,7 @@ def test_compiler_match_constraints_when_selected(self): }, ] spack.config.set("compilers", compiler_configuration) - s = Spec("pkg-a %gcc@:11").concretized() + s = spack.concretize.concretized(Spec("pkg-a %gcc@:11")) assert s.compiler.version == ver("=11.1.0"), s @pytest.mark.regression("36339") @@ -2337,7 +2347,7 @@ def test_compiler_with_custom_non_numeric_version(self, mock_executable): } ] spack.config.set("compilers", compiler_configuration) - s = Spec("pkg-a %gcc@foo").concretized() + s = spack.concretize.concretized(Spec("pkg-a %gcc@foo")) assert s.compiler.version == ver("=foo") @pytest.mark.regression("36628") @@ -2363,13 +2373,13 @@ def test_concretization_with_compilers_supporting_target_any(self): ] with spack.config.override("compilers", compiler_configuration): - s = Spec("pkg-a").concretized() + s = spack.concretize.concretized(Spec("pkg-a")) assert s.satisfies("%gcc@12.1.0") @pytest.mark.parametrize("spec_str", ["mpileaks", "mpileaks ^mpich"]) def test_virtuals_are_annotated_on_edges(self, spec_str): """Tests that information on virtuals is annotated on DAG edges""" - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) mpi_provider = spec["mpi"].name edges = spec.edges_to_dependencies(name=mpi_provider) @@ -2389,7 +2399,7 @@ def test_explicit_splices( } spack.config.CONFIG.set("concretizer", {"splice": {"explicit": [splice_info]}}) - spec = spack.spec.Spec("hdf5 ^zmpi").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("hdf5 ^zmpi")) assert spec.satisfies(f"^mpich@{mpich_spec.version}") assert spec.build_spec.dependencies(name="zmpi", deptype="link") @@ -2407,14 +2417,14 @@ def test_explicit_splice_fails_nonexistent(mutable_config, mock_packages, mock_s spack.config.CONFIG.set("concretizer", {"splice": {"explicit": [splice_info]}}) with pytest.raises(spack.spec.InvalidHashError): - _ = spack.spec.Spec("hdf5^zmpi").concretized() + _ = spack.concretize.concretized(spack.spec.Spec("hdf5^zmpi")) def test_explicit_splice_fails_no_hash(mutable_config, mock_packages, mock_store): splice_info = {"target": "mpi", "replacement": "mpich"} spack.config.CONFIG.set("concretizer", {"splice": {"explicit": [splice_info]}}) with pytest.raises(spack.solver.asp.InvalidSpliceError, match="must be specified by hash"): - _ = spack.spec.Spec("hdf5^zmpi").concretized() + _ = spack.concretize.concretized(spack.spec.Spec("hdf5^zmpi")) def test_explicit_splice_non_match_nonexistent_succeeds( mutable_config, mock_packages, mock_store @@ -2422,7 +2432,7 @@ def test_explicit_splice_non_match_nonexistent_succeeds( """When we have a nonexistent splice configured but are not using it, don't fail.""" splice_info = {"target": "will_not_match", "replacement": "nonexistent/doesnotexist"} spack.config.CONFIG.set("concretizer", {"splice": {"explicit": [splice_info]}}) - spec = spack.spec.Spec("zlib").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("zlib")) # the main test is that it does not raise assert not spec.spliced @@ -2434,7 +2444,7 @@ def test_explicit_splice_non_match_nonexistent_succeeds( def test_virtuals_are_reconstructed_on_reuse(self, spec_str, mpi_name, mutable_database): """Tests that when we reuse a spec, virtual on edges are reconstructed correctly""" with spack.config.override("concretizer:reuse", True): - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) assert spec.installed mpi_edges = spec.edges_to_dependencies(mpi_name) assert len(mpi_edges) == 1 @@ -2445,7 +2455,7 @@ def test_dont_define_new_version_from_input_if_checksum_required(self, working_e with pytest.raises(spack.error.UnsatisfiableSpecError): # normally spack concretizes to @=3.0 if it's not defined in package.py, except # when checksums are required - Spec("pkg-a@=3.0").concretized() + spack.concretize.concretized(Spec("pkg-a@=3.0")) @pytest.mark.regression("39570") @pytest.mark.db @@ -2453,15 +2463,15 @@ def test_reuse_python_from_cli_and_extension_from_db(self, mutable_database): """Tests that reusing python with and explicit request on the command line, when the spec also reuses a python extension from the DB, doesn't fail. """ - s = Spec("py-extension1").concretized() + s = spack.concretize.concretized(Spec("py-extension1")) python_hash = s["python"].dag_hash() PackageInstaller([s.package], fake=True, explicit=True).install() with spack.config.override("concretizer:reuse", True): - with_reuse = Spec(f"py-extension2 ^/{python_hash}").concretized() + with_reuse = spack.concretize.concretized(Spec(f"py-extension2 ^/{python_hash}")) with spack.config.override("concretizer:reuse", False): - without_reuse = Spec("py-extension2").concretized() + without_reuse = spack.concretize.concretized(Spec("py-extension2")) assert with_reuse.dag_hash() == without_reuse.dag_hash() @@ -2485,7 +2495,7 @@ def test_select_lower_priority_package_from_repository_stack( # 'builtin.mock" and "duplicates.test" share a 'gmake' package additional_repo = os.path.join(spack.paths.repos_path, "duplicates.test") with spack.repo.use_repositories(additional_repo, override=False): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for name, namespace in expected_namespaces.items(): assert s[name].concrete @@ -2502,13 +2512,13 @@ def test_reuse_specs_from_non_available_compilers(self, mutable_config, mutable_ mutable_config.set("concretizer:reuse", True) # mpileaks is in the database, it will be reused with gcc@=10.2.1 - root = Spec("mpileaks").concretized() + root = spack.concretize.concretized(Spec("mpileaks")) for s in root.traverse(): assert s.satisfies("%gcc@10.2.1") # fftw is not in the database, therefore the root will be compiled with gcc@=9.4.0, # while the mpi is reused from the database and is compiled with gcc@=10.2.1 - root = Spec("fftw").concretized() + root = spack.concretize.concretized(Spec("fftw")) assert root.satisfies("%gcc@=9.4.0") for s in root.traverse(root=False): assert s.satisfies("%gcc@10.2.1") @@ -2523,7 +2533,7 @@ def test_externals_with_platform_explicitly_set(self, tmp_path): } } spack.config.set("packages", external_conf) - s = Spec("mpich").concretized() + s = spack.concretize.concretized(Spec("mpich")) assert s.external @pytest.mark.regression("43267") @@ -2534,10 +2544,10 @@ def test_spec_with_build_dep_from_json(self, tmp_path): The bug was triggered by missing virtuals on edges that were trimmed from pure build dependencies. """ - build_dep = Spec("dttop").concretized() + build_dep = spack.concretize.concretized(Spec("dttop")) json_file = tmp_path / "build.json" json_file.write_text(build_dep.to_json()) - s = Spec(f"dtuse ^{str(json_file)}").concretized() + s = spack.concretize.concretized(Spec(f"dtuse ^{str(json_file)}")) assert s["dttop"].dag_hash() == build_dep.dag_hash() @pytest.mark.regression("44040") @@ -2564,14 +2574,14 @@ def test_exclude_specs_from_reuse(self, monkeypatch): """ # Prepare a mock mirror that returns an old version of dyninst request_str = "callpath ^mpich" - reused = Spec(f"{request_str} ^dyninst@8.1.1").concretized() + reused = spack.concretize.concretized(Spec(f"{request_str} ^dyninst@8.1.1")) monkeypatch.setattr(spack.solver.asp, "_specs_from_mirror", lambda: [reused]) # Exclude dyninst from reuse, so we expect that the old version is not taken into account with spack.config.override( "concretizer:reuse", {"from": [{"type": "buildcache", "exclude": ["dyninst"]}]} ): - result = Spec(request_str).concretized() + result = spack.concretize.concretized(Spec(request_str)) assert result.dag_hash() != reused.dag_hash() assert result["mpich"].dag_hash() == reused["mpich"].dag_hash() @@ -2608,7 +2618,7 @@ def test_include_specs_from_externals_and_libcs( with spack.config.override( "concretizer:reuse", {"from": [{"type": "external", "include": included_externals}]} ): - result = Spec(request_str).concretized() + result = spack.concretize.concretized(Spec(request_str)) assert result["deprecated-versions"].satisfies("@1.1.0") @@ -2617,7 +2627,7 @@ def test_include_specs_from_externals_and_libcs( "concretizer:reuse", {"from": [{"type": "external", "exclude": ["deprecated-versions"]}]}, ): - result = Spec(request_str).concretized() + result = spack.concretize.concretized(Spec(request_str)) assert result["deprecated-versions"].satisfies("@1.0.0") @@ -2631,7 +2641,7 @@ def test_can_reuse_concrete_externals_for_dependents(self, mutable_config, tmp_p } mutable_config.set("packages", packages_yaml) # Concretize with gcc@9 to get a suboptimal spec, since we have gcc@10 available - external_spec = Spec("externaltool@2 %gcc@9").concretized() + external_spec = spack.concretize.concretized(Spec("externaltool@2 %gcc@9")) assert external_spec.external root_specs = [Spec("sombrero")] @@ -2652,11 +2662,11 @@ def test_cannot_reuse_host_incompatible_libc(self): # We install b@1 ^glibc@2.30, and b@0 ^glibc@2.28. The former is not host compatible, the # latter is. - fst = Spec("pkg-b@1").concretized() + fst = spack.concretize.concretized(Spec("pkg-b@1")) fst._mark_concrete(False) fst.dependencies("glibc")[0].versions = VersionList(["=2.30"]) fst._mark_concrete(True) - snd = Spec("pkg-b@0").concretized() + snd = spack.concretize.concretized(Spec("pkg-b@0")) # The spec b@1 ^glibc@2.30 is "more optimal" than b@0 ^glibc@2.28, but due to glibc # incompatibility, it should not be reused. @@ -2685,7 +2695,7 @@ def test_corrupted_external_does_not_halt_concretization(self, corrupted_str, mu } mutable_config.set("packages", packages_yaml) # Assert we don't raise due to the corrupted external entry above - s = Spec("pkg-a").concretized() + s = spack.concretize.concretized(Spec("pkg-a")) assert s.concrete @pytest.mark.regression("44828") @@ -2708,7 +2718,7 @@ def test_correct_external_is_selected_from_packages_yaml(self, mutable_config): mutable_config.set("packages", packages_yaml) mutable_config.set("concretizer", concretizer_yaml) - s = Spec("cmake").concretized() + s = spack.concretize.concretized(Spec("cmake")) # Check that we got the properties from the right external assert s.external @@ -2741,7 +2751,7 @@ def test_two_gmake(self, strategy): """ spack.config.CONFIG.set("concretizer:duplicates:strategy", strategy) - s = Spec("hdf5").concretized() + s = spack.concretize.concretized(Spec("hdf5")) # Check that hdf5 depends on gmake@=4.1 hdf5_gmake = s["hdf5"].dependencies(name="gmake", deptype="build") @@ -2773,7 +2783,7 @@ def test_two_setuptools(self, strategy): """ spack.config.CONFIG.set("concretizer:duplicates:strategy", strategy) - s = Spec("py-shapely").concretized() + s = spack.concretize.concretized(Spec("py-shapely")) # Requirements on py-shapely setuptools = s["py-shapely"].dependencies(name="py-setuptools", deptype="build") assert len(setuptools) == 1 and setuptools[0].satisfies("@=60") @@ -2792,11 +2802,11 @@ def test_solution_without_cycles(self): """Tests that when we concretize a spec with cycles, a fallback kicks in to recompute a solution without cycles. """ - s = Spec("cycle-a").concretized() + s = spack.concretize.concretized(Spec("cycle-a")) assert s["cycle-a"].satisfies("+cycle") assert s["cycle-b"].satisfies("~cycle") - s = Spec("cycle-b").concretized() + s = spack.concretize.concretized(Spec("cycle-b")) assert s["cycle-a"].satisfies("~cycle") assert s["cycle-b"].satisfies("+cycle") @@ -2812,7 +2822,7 @@ def test_pure_build_virtual_dependency(self, strategy): """ spack.config.CONFIG.set("concretizer:duplicates:strategy", strategy) - s = Spec("virtual-build").concretized() + s = spack.concretize.concretized(Spec("virtual-build")) assert s["pkgconfig"].name == "pkg-config" @pytest.mark.regression("40595") @@ -2844,7 +2854,7 @@ def test_no_multiple_solutions_with_different_edges_same_nodes(self): """ spec_str = "py-floating" - root = spack.spec.Spec(spec_str).concretized() + root = spack.concretize.concretized(spack.spec.Spec(spec_str)) assert root["py-shapely"].satisfies("^py-setuptools@=60") assert root["py-numpy"].satisfies("^py-setuptools@=59") @@ -2923,7 +2933,7 @@ def test_adding_specs(self, input_specs, default_mock_concretization): objects in memory. """ container = spack.solver.asp.ConcreteSpecsByHash() - input_specs = [Spec(s).concretized() for s in input_specs] + input_specs = [spack.concretize.concretized(Spec(s)) for s in input_specs] for s in input_specs: container.add(s) @@ -2961,7 +2971,7 @@ def test_condition_triggered_by_edge_property( self, spec_str, expected_satisfies, expected_not_satisfies ): """Tests that we can enforce constraints based on edge attributes""" - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for expected in expected_satisfies: assert s.satisfies(expected), str(expected) @@ -2978,7 +2988,7 @@ def test_virtuals_provided_together_but_only_one_required_in_dag(self): o openblas (provides blas and lapack together) """ - s = Spec("blas-only-client ^openblas").concretized() + s = spack.concretize.concretized(Spec("blas-only-client ^openblas")) assert s.satisfies("^[virtuals=blas] openblas") assert not s.satisfies("^[virtuals=blas,lapack] openblas") @@ -3168,18 +3178,22 @@ def test_spec_filters(specs, include, exclude, expected): @pytest.mark.regression("38484") def test_git_ref_version_can_be_reused(install_mockery, do_not_check_runtimes_on_reuse): - first_spec = spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5~opt").concretized() + first_spec = spack.concretize.concretized( + spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5~opt") + ) PackageInstaller([first_spec.package], fake=True, explicit=True).install() with spack.config.override("concretizer:reuse", True): # reproducer of the issue is that spack will solve when there is a change to the base spec - second_spec = spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5+opt").concretized() + second_spec = spack.concretize.concretized( + spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5+opt") + ) assert second_spec.dag_hash() != first_spec.dag_hash() # we also want to confirm that reuse actually works so leave variant off to # let solver reuse third_spec = spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5") assert first_spec.satisfies(third_spec) - third_spec.concretize() + third_spec = spack.concretize.concretized(third_spec) assert third_spec.dag_hash() == first_spec.dag_hash() @@ -3192,14 +3206,16 @@ def test_reuse_prefers_standard_over_git_versions( but we want to prefer the standard version over git ref based versions so install git ref last and ensure it is not picked up by reuse """ - standard_spec = spack.spec.Spec(f"git-ref-package@{standard_version}").concretized() + standard_spec = spack.concretize.concretized( + spack.spec.Spec(f"git-ref-package@{standard_version}") + ) PackageInstaller([standard_spec.package], fake=True, explicit=True).install() - git_spec = spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5").concretized() + git_spec = spack.concretize.concretized(spack.spec.Spec("git-ref-package@git.2.1.5=2.1.5")) PackageInstaller([git_spec.package], fake=True, explicit=True).install() with spack.config.override("concretizer:reuse", True): - test_spec = spack.spec.Spec("git-ref-package@2").concretized() + test_spec = spack.concretize.concretized(spack.spec.Spec("git-ref-package@2")) assert git_spec.dag_hash() != test_spec.dag_hash() assert standard_spec.dag_hash() == test_spec.dag_hash() diff --git a/lib/spack/spack/test/concretization/errors.py b/lib/spack/spack/test/concretization/errors.py index 0cb7a533c1d..71a2af83e88 100644 --- a/lib/spack/spack/test/concretization/errors.py +++ b/lib/spack/spack/test/concretization/errors.py @@ -5,6 +5,7 @@ import pytest +import spack.concretize import spack.config import spack.solver.asp import spack.spec @@ -58,7 +59,7 @@ def test_error_messages(error_messages, config_set, spec, mock_packages, mutable spack.config.set(path, conf) with pytest.raises(spack.solver.asp.UnsatisfiableSpecError) as e: - _ = spack.spec.Spec(spec).concretized() + _ = spack.concretize.concretized(spack.spec.Spec(spec)) for em in error_messages: assert em in str(e.value) diff --git a/lib/spack/spack/test/concretization/flag_mixing.py b/lib/spack/spack/test/concretization/flag_mixing.py index 878c0c71efc..91075d56f77 100644 --- a/lib/spack/spack/test/concretization/flag_mixing.py +++ b/lib/spack/spack/test/concretization/flag_mixing.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize import spack.config import spack.environment as ev import spack.paths @@ -63,12 +64,12 @@ def test_mix_spec_and_requirements(concretize_scope, test_repo): """ update_concretize_scope(conf_str, "packages") - s1 = Spec('y cflags="-a"').concretized() + s1 = spack.concretize.concretized(Spec('y cflags="-a"')) assert s1.satisfies('cflags="-a -c"') def test_mix_spec_and_dependent(concretize_scope, test_repo): - s1 = Spec('x ^y cflags="-a"').concretized() + s1 = spack.concretize.concretized(Spec('x ^y cflags="-a"')) assert s1["y"].satisfies('cflags="-a -d1"') @@ -93,7 +94,7 @@ def test_mix_spec_and_compiler_cfg(concretize_scope, test_repo): conf_str = _compiler_cfg_one_entry_with_cflags("-Wall") update_concretize_scope(conf_str, "compilers") - s1 = Spec('y %gcc@12.100.100 cflags="-O2"').concretized() + s1 = spack.concretize.concretized(Spec('y %gcc@12.100.100 cflags="-O2"')) assert s1.satisfies('cflags="-Wall -O2"') @@ -148,7 +149,7 @@ def test_flag_order_and_grouping( if cmd_flags: spec_str += f' cflags="{cmd_flags}"' - root_spec = Spec(spec_str).concretized() + root_spec = spack.concretize.concretized(Spec(spec_str)) spec = root_spec["y"] satisfy_flags = " ".join(x for x in [cmd_flags, req_flags, cmp_flags, expected_dflags] if x) assert spec.satisfies(f'cflags="{satisfy_flags}"') @@ -156,11 +157,11 @@ def test_flag_order_and_grouping( def test_two_dependents_flag_mixing(concretize_scope, test_repo): - root_spec1 = Spec("w~moveflaglater").concretized() + root_spec1 = spack.concretize.concretized(Spec("w~moveflaglater")) spec1 = root_spec1["y"] assert spec1.compiler_flags["cflags"] == "-d0 -d1 -d2".split() - root_spec2 = Spec("w+moveflaglater").concretized() + root_spec2 = spack.concretize.concretized(Spec("w+moveflaglater")) spec2 = root_spec2["y"] assert spec2.compiler_flags["cflags"] == "-d3 -d1 -d2".split() @@ -169,7 +170,7 @@ def test_propagate_and_compiler_cfg(concretize_scope, test_repo): conf_str = _compiler_cfg_one_entry_with_cflags("-f2") update_concretize_scope(conf_str, "compilers") - root_spec = Spec("v %gcc@12.100.100 cflags=='-f1'").concretized() + root_spec = spack.concretize.concretized(Spec("v %gcc@12.100.100 cflags=='-f1'")) assert root_spec["y"].satisfies("cflags='-f1 -f2'") @@ -178,7 +179,7 @@ def test_propagate_and_compiler_cfg(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.concretized(Spec("x ~activatemultiflag cflags=='-f1'")) assert root_spec1["y"].satisfies("cflags='-f1 -d1'") @@ -190,7 +191,7 @@ def test_propagate_and_require(concretize_scope, test_repo): """ update_concretize_scope(conf_str, "packages") - root_spec1 = Spec("v cflags=='-f1'").concretized() + root_spec1 = spack.concretize.concretized(Spec("v cflags=='-f1'")) assert root_spec1["y"].satisfies("cflags='-f1 -f2'") # Next, check that a requirement does not "undo" a request for @@ -202,7 +203,7 @@ def test_propagate_and_require(concretize_scope, test_repo): """ update_concretize_scope(conf_str, "packages") - root_spec2 = Spec("v cflags=='-f1'").concretized() + root_spec2 = spack.concretize.concretized(Spec("v cflags=='-f1'")) assert root_spec2["y"].satisfies("cflags='-f1'") # Note: requirements cannot enforce propagation: any attempt to do @@ -246,7 +247,7 @@ def test_diamond_dep_flag_mixing(concretize_scope, test_repo): nodes of the diamond always appear in the same order). `Spec.traverse` is responsible for handling both of these needs. """ - root_spec1 = Spec("t").concretized() + root_spec1 = spack.concretize.concretized(Spec("t")) spec1 = root_spec1["y"] assert spec1.satisfies('cflags="-c1 -c2 -d1 -d2 -e1 -e2"') assert spec1.compiler_flags["cflags"] == "-c1 -c2 -e1 -e2 -d1 -d2".split() diff --git a/lib/spack/spack/test/concretization/preferences.py b/lib/spack/spack/test/concretization/preferences.py index faf7b07fc09..cd4080a53c5 100644 --- a/lib/spack/spack/test/concretization/preferences.py +++ b/lib/spack/spack/test/concretization/preferences.py @@ -8,6 +8,7 @@ import pytest +import spack.concretize import spack.config import spack.package_prefs import spack.repo @@ -47,7 +48,7 @@ def configure_permissions(): def concretize(abstract_spec): - return Spec(abstract_spec).concretized() + return spack.concretize.concretized(Spec(abstract_spec)) def update_packages(pkgname, section, value): @@ -112,7 +113,7 @@ def test_preferred_variants_from_wildcard(self): def test_preferred_compilers(self, compiler_str, spec_str): """Test preferred compilers are applied correctly""" update_packages("all", "compiler", [compiler_str]) - spec = spack.spec.Spec(spec_str).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(spec_str)) assert spec.compiler == CompilerSpec(compiler_str) def test_preferred_target(self, mutable_mock_repo): @@ -214,15 +215,13 @@ def test_config_set_pkg_property_new(self, mock_repo_path): def test_preferred(self): """ "Test packages with some version marked as preferred=True""" - spec = Spec("python") - spec.concretize() + spec = spack.concretize.concretized(Spec("python")) assert spec.version == Version("2.7.11") # now add packages.yaml with versions other than preferred # ensure that once config is in place, non-preferred version is used update_packages("python", "version", ["3.5.0"]) - spec = Spec("python") - spec.concretize() + spec = spack.concretize.concretized(Spec("python")) assert spec.version == Version("3.5.0") def test_preferred_undefined_raises(self): @@ -230,7 +229,7 @@ def test_preferred_undefined_raises(self): update_packages("python", "version", ["3.5.0.1"]) spec = Spec("python") with pytest.raises(ConfigError): - spec.concretize() + spack.concretize.concretized(spec) def test_preferred_truncated(self): """Versions without "=" are treated as version ranges: if there is @@ -238,35 +237,29 @@ def test_preferred_truncated(self): (don't define a new version). """ update_packages("python", "version", ["3.5"]) - spec = Spec("python") - spec.concretize() + spec = spack.concretize.concretized(Spec("python")) assert spec.satisfies("@3.5.1") def test_develop(self): """Test concretization with develop-like versions""" - spec = Spec("develop-test") - spec.concretize() + spec = spack.concretize.concretized(Spec("develop-test")) assert spec.version == Version("0.2.15") - spec = Spec("develop-test2") - spec.concretize() + spec = spack.concretize.concretized(Spec("develop-test2")) assert spec.version == Version("0.2.15") # now add packages.yaml with develop-like versions # ensure that once config is in place, develop-like version is used update_packages("develop-test", "version", ["develop"]) - spec = Spec("develop-test") - spec.concretize() + spec = spack.concretize.concretized(Spec("develop-test")) assert spec.version == Version("develop") update_packages("develop-test2", "version", ["0.2.15.develop"]) - spec = Spec("develop-test2") - spec.concretize() + spec = spack.concretize.concretized(Spec("develop-test2")) assert spec.version == Version("0.2.15.develop") def test_external_mpi(self): # make sure this doesn't give us an external first. - spec = Spec("mpi") - spec.concretize() + spec = spack.concretize.concretized(Spec("mpi")) assert not spec["mpi"].external # load config @@ -285,8 +278,7 @@ def test_external_mpi(self): spack.config.set("packages", conf, scope="concretize") # ensure that once config is in place, external is used - spec = Spec("mpi") - spec.concretize() + spec = spack.concretize.concretized(Spec("mpi")) assert spec["mpich"].external_path == os.path.sep + os.path.join("dummy", "path") def test_external_module(self, monkeypatch): @@ -301,8 +293,7 @@ def mock_module(cmd, module): monkeypatch.setattr(spack.util.module_cmd, "module", mock_module) - spec = Spec("mpi") - spec.concretize() + spec = spack.concretize.concretized(Spec("mpi")) assert not spec["mpi"].external # load config @@ -321,8 +312,7 @@ def mock_module(cmd, module): spack.config.set("packages", conf, scope="concretize") # ensure that once config is in place, external is used - spec = Spec("mpi") - spec.concretize() + spec = spack.concretize.concretized(Spec("mpi")) assert spec["mpich"].external_path == os.path.sep + os.path.join("dummy", "path") def test_buildable_false(self): @@ -468,7 +458,7 @@ def test_variant_not_flipped_to_pull_externals(self): """Test that a package doesn't prefer pulling in an external to using the default value of a variant. """ - s = Spec("vdefault-or-external-root").concretized() + s = spack.concretize.concretized(Spec("vdefault-or-external-root")) assert "~external" in s["vdefault-or-external"] assert "externaltool" not in s @@ -480,7 +470,7 @@ def test_dependencies_cant_make_version_parent_score_better(self): that makes the overall version score even or better and maybe has a better score in some lower priority criteria. """ - s = Spec("version-test-root").concretized() + s = spack.concretize.concretized(Spec("version-test-root")) assert s.satisfies("^version-test-pkg@2.4.6") assert "version-test-dependency-preferred" not in s @@ -498,13 +488,13 @@ def test_multivalued_variants_are_lower_priority_than_providers(self): with spack.config.override( "packages:all", {"providers": {"somevirtual": ["some-virtual-preferred"]}} ): - s = Spec("somevirtual").concretized() + s = spack.concretize.concretized(Spec("somevirtual")) assert s.name == "some-virtual-preferred" @pytest.mark.regression("26721,19736") def test_sticky_variant_accounts_for_packages_yaml(self): with spack.config.override("packages:sticky-variant", {"variants": "+allow-gcc"}): - s = Spec("sticky-variant %gcc").concretized() + s = spack.concretize.concretized(Spec("sticky-variant %gcc")) assert s.satisfies("%gcc") and s.satisfies("+allow-gcc") @pytest.mark.regression("41134") @@ -513,5 +503,5 @@ def test_default_preference_variant_different_type_does_not_error(self): packages.yaml doesn't fail with an error. """ with spack.config.override("packages:all", {"variants": "+foo"}): - s = Spec("pkg-a").concretized() + s = spack.concretize.concretized(Spec("pkg-a")) assert s.satisfies("foo=bar") diff --git a/lib/spack/spack/test/concretization/requirements.py b/lib/spack/spack/test/concretization/requirements.py index 9e703be51fe..db8b977f9b5 100644 --- a/lib/spack/spack/test/concretization/requirements.py +++ b/lib/spack/spack/test/concretization/requirements.py @@ -7,6 +7,7 @@ import pytest +import spack.concretize import spack.config import spack.error import spack.package_base @@ -43,7 +44,7 @@ def test_one_package_multiple_reqs(concretize_scope, test_repo): - "~shared" """ update_packages_config(conf_str) - y_spec = Spec("y").concretized() + y_spec = spack.concretize.concretized(Spec("y")) assert y_spec.satisfies("@2.4~shared") @@ -58,7 +59,7 @@ def test_requirement_isnt_optional(concretize_scope, test_repo): """ update_packages_config(conf_str) with pytest.raises(UnsatisfiableSpecError): - Spec("x@1.1").concretize() + spack.concretize.concretized(Spec("x@1.1")) def test_require_undefined_version(concretize_scope, test_repo): @@ -75,7 +76,7 @@ def test_require_undefined_version(concretize_scope, test_repo): """ update_packages_config(conf_str) with pytest.raises(spack.error.ConfigError): - Spec("x").concretize() + spack.concretize.concretized(Spec("x")) def test_require_truncated(concretize_scope, test_repo): @@ -90,7 +91,7 @@ def test_require_truncated(concretize_scope, test_repo): require: "@1" """ update_packages_config(conf_str) - xspec = Spec("x").concretized() + xspec = spack.concretize.concretized(Spec("x")) assert xspec.satisfies("@1.1") @@ -160,7 +161,7 @@ def test_requirement_adds_new_version( ) update_packages_config(conf_str) - s1 = Spec("v").concretized() + s1 = spack.concretize.concretized(Spec("v")) assert s1.satisfies("@2.2") # Make sure the git commit info is retained assert isinstance(s1.version, spack.version.GitVersion) @@ -181,7 +182,7 @@ def test_requirement_adds_version_satisfies( ) # Sanity check: early version of T does not include U - s0 = Spec("t@2.0").concretized() + s0 = spack.concretize.concretized(Spec("t@2.0")) assert not ("u" in s0) conf_str = """\ @@ -193,7 +194,7 @@ def test_requirement_adds_version_satisfies( ) update_packages_config(conf_str) - s1 = Spec("t").concretized() + s1 = spack.concretize.concretized(Spec("t")) assert "u" in s1 assert s1.satisfies("@2.2") @@ -219,7 +220,7 @@ def test_requirement_adds_git_hash_version( """ update_packages_config(conf_str) - s1 = Spec("v").concretized() + s1 = spack.concretize.concretized(Spec("v")) assert isinstance(s1.version, spack.version.GitVersion) assert s1.satisfies(f"v@{a_commit_hash}") @@ -240,8 +241,8 @@ def test_requirement_adds_multiple_new_versions( """ update_packages_config(conf_str) - assert Spec("v").concretized().satisfies(f"@{commits[0]}=2.2") - assert Spec("v@2.3").concretized().satisfies(f"v@{commits[1]}=2.3") + assert spack.concretize.concretized(Spec("v")).satisfies(f"@{commits[0]}=2.2") + assert spack.concretize.concretized(Spec("v@2.3")).satisfies(f"v@{commits[1]}=2.3") # TODO: this belongs in the concretize_preferences test module but uses @@ -264,11 +265,11 @@ def test_preference_adds_new_version( """ update_packages_config(conf_str) - assert Spec("v").concretized().satisfies(f"@{commits[0]}=2.2") - assert Spec("v@2.3").concretized().satisfies(f"@{commits[1]}=2.3") + assert spack.concretize.concretized(Spec("v")).satisfies(f"@{commits[0]}=2.2") + assert spack.concretize.concretized(Spec("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. - s3 = Spec(f"v@{commits[1]}").concretized() + s3 = spack.concretize.concretized(Spec(f"v@{commits[1]}")) assert s3.satisfies(f"v@{commits[1]}") assert not s3.satisfies("@2.3") @@ -288,7 +289,7 @@ def test_external_adds_new_version_that_is_preferred(concretize_scope, test_repo """ update_packages_config(conf_str) - spec = Spec("x").concretized() + spec = spack.concretize.concretized(Spec("x")) assert spec["y"].satisfies("@2.7") assert spack.version.Version("2.7") not in spec["y"].package.versions @@ -297,7 +298,7 @@ def test_requirement_is_successfully_applied(concretize_scope, test_repo): """If a simple requirement can be satisfied, make sure the concretization succeeds and the requirement spec is applied. """ - s1 = Spec("x").concretized() + s1 = spack.concretize.concretized(Spec("x")) # Without any requirements/preferences, the later version is preferred assert s1.satisfies("@1.1") @@ -307,7 +308,7 @@ def test_requirement_is_successfully_applied(concretize_scope, test_repo): require: "@1.0" """ update_packages_config(conf_str) - s2 = Spec("x").concretized() + s2 = spack.concretize.concretized(Spec("x")) # The requirement forces choosing the eariler version assert s2.satisfies("@1.0") @@ -324,7 +325,7 @@ def test_multiple_packages_requirements_are_respected(concretize_scope, test_rep require: "@2.4" """ update_packages_config(conf_str) - spec = Spec("x").concretized() + spec = spack.concretize.concretized(Spec("x")) assert spec["x"].satisfies("@1.0") assert spec["y"].satisfies("@2.4") @@ -340,7 +341,7 @@ def test_oneof(concretize_scope, test_repo): - one_of: ["@2.4", "~shared"] """ update_packages_config(conf_str) - spec = Spec("x").concretized() + spec = spack.concretize.concretized(Spec("x")) # The concretizer only has to satisfy one of @2.4/~shared, and @2.4 # comes first so it is prioritized assert spec["y"].satisfies("@2.4+shared") @@ -359,10 +360,10 @@ def test_one_package_multiple_oneof_groups(concretize_scope, test_repo): """ update_packages_config(conf_str) - s1 = Spec("y@2.5").concretized() + s1 = spack.concretize.concretized(Spec("y@2.5")) assert s1.satisfies("%clang~shared") - s2 = Spec("y@2.4").concretized() + s2 = spack.concretize.concretized(Spec("y@2.4")) assert s2.satisfies("%gcc+shared") @@ -378,10 +379,10 @@ def test_require_cflags(concretize_scope, mock_packages): """ update_packages_config(conf_str) - spec_mpich2 = Spec("mpich2").concretized() + spec_mpich2 = spack.concretize.concretized(Spec("mpich2")) assert spec_mpich2.satisfies("cflags=-g") - spec_mpi = Spec("mpi").concretized() + spec_mpi = spack.concretize.concretized(Spec("mpi")) assert spec_mpi.satisfies("mpich cflags=-O1") @@ -404,7 +405,7 @@ def test_requirements_for_package_that_is_not_needed(concretize_scope, test_repo """ update_packages_config(conf_str) - s1 = Spec("v").concretized() + s1 = spack.concretize.concretized(Spec("v")) assert s1.satisfies("@2.1") @@ -421,10 +422,10 @@ def test_oneof_ordering(concretize_scope, test_repo): """ update_packages_config(conf_str) - s1 = Spec("y").concretized() + s1 = spack.concretize.concretized(Spec("y")) assert s1.satisfies("@2.4") - s2 = Spec("y@2.5").concretized() + s2 = spack.concretize.concretized(Spec("y@2.5")) assert s2.satisfies("@2.5") @@ -438,14 +439,14 @@ def test_reuse_oneof(concretize_scope, test_repo, tmp_path, mock_fetch): store_dir = tmp_path / "store" with spack.store.use_store(str(store_dir)): - s1 = Spec("y@2.5 ~shared").concretized() + s1 = spack.concretize.concretized(Spec("y@2.5~shared")) PackageInstaller([s1.package], fake=True, explicit=True).install() update_packages_config(conf_str) with spack.config.override("concretizer:reuse", True): - s2 = Spec("y").concretized() - assert not s2.satisfies("@2.5 ~shared") + s2 = spack.concretize.concretized(Spec("y")) + assert not s2.satisfies("@2.5~shared") @pytest.mark.parametrize( @@ -473,7 +474,7 @@ def test_requirements_and_deprecated_versions( update_packages_config(conf_str) with spack.config.override("config:deprecated", allow_deprecated): - s1 = Spec("y").concretized() + s1 = spack.concretize.concretized(Spec("y")) for constrain in expected: assert s1.satisfies(constrain) @@ -491,7 +492,7 @@ def test_default_requirements_with_all(spec_str, requirement_str, concretize_sco """ update_packages_config(conf_str) - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) for s in spec.traverse(): assert s.satisfies(requirement_str) @@ -500,7 +501,7 @@ def test_default_requirements_with_all(spec_str, requirement_str, concretize_sco "requirements,expectations", [ (("%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( @@ -518,7 +519,7 @@ def test_default_and_package_specific_requirements( """ update_packages_config(conf_str) - spec = Spec("x").concretized() + spec = spack.concretize.concretized(Spec("x")) assert spec.satisfies(specific_exp) for s in spec.traverse(root=False): assert s.satisfies(generic_exp) @@ -533,7 +534,7 @@ def test_requirements_on_virtual(mpi_requirement, concretize_scope, mock_package """ update_packages_config(conf_str) - spec = Spec("callpath").concretized() + spec = spack.concretize.concretized(Spec("callpath")) assert "mpi" in spec assert mpi_requirement in spec @@ -554,7 +555,7 @@ def test_requirements_on_virtual_and_on_package( """ update_packages_config(conf_str) - spec = Spec("callpath").concretized() + spec = spack.concretize.concretized(Spec("callpath")) assert "mpi" in spec assert mpi_requirement in spec assert spec["mpi"].satisfies(specific_requirement) @@ -568,10 +569,10 @@ def test_incompatible_virtual_requirements_raise(concretize_scope, mock_packages """ update_packages_config(conf_str) - spec = Spec("callpath ^zmpi") + spec = Spec("callpath^zmpi") # TODO (multiple nodes): recover a better error message later with pytest.raises((UnsatisfiableSpecError, InternalConcretizerError)): - spec.concretize() + spack.concretize.concretized(spec) def test_non_existing_variants_under_all(concretize_scope, mock_packages): @@ -583,7 +584,7 @@ def test_non_existing_variants_under_all(concretize_scope, mock_packages): """ update_packages_config(conf_str) - spec = Spec("callpath ^zmpi").concretized() + spec = spack.concretize.concretized(Spec("callpath^zmpi")) assert "~foo" not in spec @@ -658,7 +659,7 @@ def test_conditional_requirements_from_packages_yaml( and optional when the condition is not met. """ update_packages_config(packages_yaml) - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) for match_str, expected in expected_satisfies: assert spec.satisfies(match_str) is expected @@ -734,7 +735,7 @@ def test_requirements_fail_with_custom_message( """ update_packages_config(packages_yaml) with pytest.raises(spack.error.SpackError, match=expected_message): - Spec(spec_str).concretized() + spack.concretize.concretized(Spec(spec_str)) def test_skip_requirement_when_default_requirement_condition_cannot_be_met( @@ -753,9 +754,9 @@ def test_skip_requirement_when_default_requirement_condition_cannot_be_met( when: "+shared" """ update_packages_config(packages_yaml) - s = Spec("mpileaks").concretized() + s = spack.concretize.concretized(Spec("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 # cause failures during concretization. assert "shared" not in s["callpath"].variants @@ -782,12 +783,12 @@ def test_requires_directive(concretize_scope, mock_packages): spack.config.CONFIG.clear_caches() # This package requires either clang or gcc - s = Spec("requires_clang_or_gcc").concretized() + s = spack.concretize.concretized(Spec("requires_clang_or_gcc")) assert s.satisfies("%gcc@12.0.0") # This package 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.concretized(Spec("requires_clang")) @pytest.mark.parametrize( @@ -840,20 +841,20 @@ def test_default_requirements_semantic(packages_yaml, concretize_scope, mock_pac """ update_packages_config(packages_yaml) - # Regular zlib concretize to +shared - s = Spec("zlib").concretized() + # Regular zlib concretize to+shared + s = spack.concretize.concretized(Spec("zlib")) assert s.satisfies("+shared") # If we specify the variant we can concretize only the one matching the constraint - s = Spec("zlib +shared").concretized() + s = spack.concretize.concretized(Spec("zlib+shared")) assert s.satisfies("+shared") with pytest.raises(UnsatisfiableSpecError): - Spec("zlib ~shared").concretized() + spack.concretize.concretized(Spec("zlib~shared")) # A spec without the shared variant still concretize - s = Spec("pkg-a").concretized() - assert not s.satisfies("pkg-a +shared") - assert not s.satisfies("pkg-a ~shared") + s = spack.concretize.concretized(Spec("pkg-a")) + assert not s.satisfies("pkg-a+shared") + assert not s.satisfies("pkg-a~shared") @pytest.mark.parametrize( @@ -897,7 +898,7 @@ def test_default_requirements_semantic(packages_yaml, concretize_scope, mock_pac """ packages: all: - require: "libs=static +feefoo" + require: "libs=static+feefoo" """, "multivalue-variant", ["libs=shared"], @@ -912,7 +913,7 @@ def test_default_requirements_semantic_with_mv_variants( from MV variants. """ update_packages_config(packages_yaml) - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for constraint in expected: assert s.satisfies(constraint), constraint @@ -937,7 +938,7 @@ def test_requiring_package_on_multiple_virtuals(concretize_scope, mock_packages) require: intel-parallel-studio """ ) - s = Spec("dla-future").concretized() + s = spack.concretize.concretized(Spec("dla-future")) assert s["blas"].name == "intel-parallel-studio" assert s["lapack"].name == "intel-parallel-studio" @@ -990,7 +991,7 @@ def test_strong_preferences_packages_yaml( ): """Tests that "preferred" specs are stronger than usual preferences, but can be overridden.""" update_packages_config(packages_yaml) - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) for constraint in expected: assert s.satisfies(constraint), constraint @@ -1039,29 +1040,29 @@ def test_conflict_packages_yaml(packages_yaml, spec_str, concretize_scope, mock_ """Tests conflicts that are specified from configuration files.""" update_packages_config(packages_yaml) with pytest.raises(UnsatisfiableSpecError): - Spec(spec_str).concretized() + spack.concretize.concretized(Spec(spec_str)) @pytest.mark.parametrize( "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=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=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=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"], [], ), @@ -1074,9 +1075,9 @@ def test_forward_multi_valued_variant_using_requires( `requires` directives of the form: 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.concretized(Spec(spec_str)) for constraint in expected: assert s.satisfies(constraint) @@ -1087,7 +1088,7 @@ def test_forward_multi_valued_variant_using_requires( def test_strong_preferences_higher_priority_than_reuse(concretize_scope, mock_packages): """Tests that strong preferences have a higher priority than reusing specs.""" - reused_spec = Spec("adios2~bzip2").concretized() + reused_spec = spack.concretize.concretized(Spec("adios2~bzip2")) reuse_nodes = list(reused_spec.traverse()) root_specs = [Spec("ascent+adios2")] @@ -1122,7 +1123,7 @@ def test_strong_preferences_higher_priority_than_reuse(concretize_scope, mock_pa solver = spack.solver.asp.Solver() setup = spack.solver.asp.SpackSolverSetup() 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] assert ascent["adios2"].dag_hash() == reused_spec.dag_hash(), ascent diff --git a/lib/spack/spack/test/config_values.py b/lib/spack/spack/test/config_values.py index 70f50f1e88b..901eb7317b8 100644 --- a/lib/spack/spack/test/config_values.py +++ b/lib/spack/spack/test/config_values.py @@ -5,6 +5,7 @@ import pytest +import spack.concretize import spack.spec import spack.store @@ -14,7 +15,7 @@ def test_set_install_hash_length(hash_length, mutable_config, tmpdir): mutable_config.set("config:install_hash_length", hash_length) with spack.store.use_store(str(tmpdir)): - spec = spack.spec.Spec("libelf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libelf")) prefix = spec.prefix hash_str = prefix.rsplit("-")[-1] assert len(hash_str) == hash_length @@ -24,7 +25,7 @@ def test_set_install_hash_length(hash_length, mutable_config, tmpdir): def test_set_install_hash_length_upper_case(mutable_config, tmpdir): mutable_config.set("config:install_hash_length", 5) with spack.store.use_store(str(tmpdir), extra_data={"projections": {"all": "{name}-{HASH}"}}): - spec = spack.spec.Spec("libelf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libelf")) prefix = spec.prefix hash_str = prefix.rsplit("-")[-1] assert len(hash_str) == 5 diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index b56d75c6fab..1d8d45c6595 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -37,6 +37,7 @@ import spack.caches import spack.compiler import spack.compilers +import spack.concretize import spack.config import spack.directives_meta import spack.environment as ev @@ -855,7 +856,7 @@ def _populate(mock_db): """ def _install(spec): - s = spack.spec.Spec(spec).concretized() + s = spack.concretize.concretized(spack.spec.Spec(spec)) PackageInstaller([s.package], fake=True, explicit=True).install() _install("mpileaks ^mpich") @@ -1989,7 +1990,9 @@ def default_mock_concretization(config, mock_packages, concretized_specs_cache): def _func(spec_str, tests=False): key = spec_str, tests 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.concretized( + spack.spec.Spec(spec_str), tests=tests + ) return concretized_specs_cache[key].copy() return _func diff --git a/lib/spack/spack/test/cvs_fetch.py b/lib/spack/spack/test/cvs_fetch.py index b5ca766d52f..c0975272abb 100644 --- a/lib/spack/spack/test/cvs_fetch.py +++ b/lib/spack/spack/test/cvs_fetch.py @@ -9,6 +9,7 @@ from llnl.util.filesystem import mkdirp, touch, working_dir +import spack.concretize from spack.fetch_strategy import CvsFetchStrategy from spack.spec import Spec from spack.stage import Stage @@ -38,7 +39,7 @@ def test_fetch(type_of_test, mock_cvs_repository, config, mutable_mock_repo): get_date = mock_cvs_repository.get_date # Construct the package under test - spec = Spec("cvs-test").concretized() + spec = spack.concretize.concretized(Spec("cvs-test")) spec.package.versions[Version("cvs")] = test.args # Enter the stage directory and check some properties diff --git a/lib/spack/spack/test/database.py b/lib/spack/spack/test/database.py index 07cbe3dd81f..591c1ef6334 100644 --- a/lib/spack/spack/test/database.py +++ b/lib/spack/spack/test/database.py @@ -27,6 +27,7 @@ import llnl.util.lock as lk from llnl.util.tty.colify import colify +import spack.concretize import spack.database import spack.deptypes as dt import spack.package_base @@ -78,8 +79,8 @@ def test_query_by_install_tree( up_write_db, up_db, down_db = upstream_and_downstream_db # Set the upstream DB to contain "pkg-c" and downstream to contain "pkg-b") - b = spack.spec.Spec("pkg-b").concretized() - c = spack.spec.Spec("pkg-c").concretized() + b = spack.concretize.concretized(spack.spec.Spec("pkg-b")) + c = spack.concretize.concretized(spack.spec.Spec("pkg-c")) up_write_db.add(c) up_db._read() down_db.add(b) @@ -96,7 +97,7 @@ def test_spec_installed_upstream( # a known installed spec should say that it's installed with spack.repo.use_repositories(mock_custom_repository): - spec = spack.spec.Spec("pkg-c").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("pkg-c")) assert not spec.installed assert not spec.installed_upstream @@ -125,7 +126,7 @@ def test_installed_upstream(upstream_and_downstream_db, tmpdir): builder.add_package("w", dependencies=[("x", None, None), ("y", None, None)]) with spack.repo.use_repositories(builder.root): - spec = spack.spec.Spec("w").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("w")) for dep in spec.traverse(root=False): upstream_write_db.add(dep) upstream_db._read() @@ -136,7 +137,7 @@ def test_installed_upstream(upstream_and_downstream_db, tmpdir): with pytest.raises(spack.database.ForbiddenLockError): upstream_db.get_by_hash(dep.dag_hash()) - new_spec = spack.spec.Spec("w").concretized() + new_spec = spack.concretize.concretized(spack.spec.Spec("w")) downstream_db.add(new_spec) for dep in new_spec.traverse(root=False): upstream, record = downstream_db.query_by_spec_hash(dep.dag_hash()) @@ -158,7 +159,7 @@ def test_removed_upstream_dep(upstream_and_downstream_db, tmpdir, capsys, config builder.add_package("y", dependencies=[("z", None, None)]) with spack.repo.use_repositories(builder): - y = spack.spec.Spec("y").concretized() + y = spack.concretize.concretized(spack.spec.Spec("y")) z = y["z"] # add dependency to upstream, dependents to downstream @@ -190,7 +191,7 @@ def test_add_to_upstream_after_downstream(upstream_and_downstream_db, tmpdir): builder.add_package("x") with spack.repo.use_repositories(builder.root): - spec = spack.spec.Spec("x").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("x")) downstream_db.add(spec) upstream_write_db.add(spec) @@ -222,7 +223,7 @@ def test_cannot_write_upstream(tmp_path, mock_packages, config): db = spack.database.Database(str(tmp_path), is_upstream=True) with pytest.raises(spack.database.ForbiddenLockError): - db.add(spack.spec.Spec("pkg-a").concretized()) + db.add(spack.concretize.concretized(spack.spec.Spec("pkg-a"))) @pytest.mark.usefixtures("config", "temporary_store") @@ -236,7 +237,7 @@ def test_recursive_upstream_dbs(tmpdir, gen_mock_layout): builder.add_package("x", dependencies=[("y", None, None)]) with spack.repo.use_repositories(builder.root): - spec = spack.spec.Spec("x").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("x")) db_c = spack.database.Database(roots[2], layout=layouts[2]) db_c.add(spec["z"]) @@ -386,7 +387,7 @@ def _check_remove_and_add_package(database: spack.database.Database, spec): def _mock_install(spec: str): - s = spack.spec.Spec(spec).concretized() + s = spack.concretize.concretized(spack.spec.Spec(spec)) PackageInstaller([s.package], fake=True, explicit=True).install() @@ -731,8 +732,7 @@ def test_regression_issue_8036(mutable_database, usr_folder_exists): # existing. Even when the package prefix exists, the package should # not be considered installed until it is added to the database by # the installer with install(). - s = spack.spec.Spec("externaltool@0.9") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("externaltool@0.9")) assert not s.installed # Now install the external package and check again the `installed` property @@ -747,8 +747,7 @@ def test_old_external_entries_prefix(mutable_database): jsonschema.validate(db_obj, schema) - s = spack.spec.Spec("externaltool") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("externaltool")) db_obj["database"]["installs"][s.dag_hash()]["path"] = "None" @@ -777,8 +776,7 @@ def test_uninstall_by_spec(mutable_database): def test_query_unused_specs(mutable_database): # This spec installs a fake cmake as a build only dependency - s = spack.spec.Spec("simple-inheritance") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) PackageInstaller([s.package], fake=True, explicit=True).install() si = s.dag_hash() @@ -820,8 +818,7 @@ def check_unused(roots, deptype, expected): def test_query_spec_with_conditional_dependency(mutable_database): # The issue is triggered by having dependencies that are # conditional on a Boolean variant - s = spack.spec.Spec("hdf5~mpi") - s.concretize() + s = spack.concretize.concretized(spack.spec.Spec("hdf5~mpi")) PackageInstaller([s.package], fake=True, explicit=True).install() results = spack.store.STORE.db.query_local("hdf5 ^mpich") @@ -861,7 +858,7 @@ def _is(self, spec): # Pretend the spec has been failure locked monkeypatch.setattr(spack.database.FailureTracker, "lock_taken", _is) - s = spack.spec.Spec("pkg-a").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) spack.store.STORE.failure_tracker.clear(s) out = capfd.readouterr()[0] assert "Retaining failure marking" in out @@ -879,7 +876,7 @@ def _is(self, spec): # Ensure raise OSError when try to remove the non-existent marking monkeypatch.setattr(spack.database.FailureTracker, "persistent_mark", _is) - s = spack.spec.Spec("pkg-a").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) spack.store.STORE.failure_tracker.clear(s, force=True) out = capfd.readouterr()[1] assert "Removing failure marking despite lock" in out @@ -894,7 +891,7 @@ def _raise_exc(lock): raise lk.LockTimeoutError("write", "/mock-lock", 1.234, 10) with tmpdir.as_cwd(): - s = spack.spec.Spec("pkg-a").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) # Ensure attempt to acquire write lock on the mark raises the exception monkeypatch.setattr(lk.Lock, "acquire_write", _raise_exc) @@ -910,7 +907,7 @@ def _raise_exc(lock): def test_prefix_failed(mutable_database, monkeypatch): """Add coverage to failed operation.""" - s = spack.spec.Spec("pkg-a").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) # Confirm the spec is not already marked as failed assert not spack.store.STORE.failure_tracker.has_failed(s) @@ -934,7 +931,7 @@ def test_prefix_write_lock_error(mutable_database, monkeypatch): def _raise(db, spec): raise lk.LockError("Mock lock error") - s = spack.spec.Spec("pkg-a").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) # Ensure subsequent lock operations fail monkeypatch.setattr(lk.Lock, "acquire_write", _raise) @@ -1142,7 +1139,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 # `mpileaks` with the same hash in the upstream. After reindexing, `mpileaks` should still be # in the local db, and `callpath` should not. - mpileaks = spack.spec.Spec("mpileaks").concretized() + mpileaks = spack.concretize.concretized(spack.spec.Spec("mpileaks")) callpath = mpileaks.dependencies("callpath")[0] upstream_store = spack.store.create( diff --git a/lib/spack/spack/test/directives.py b/lib/spack/spack/test/directives.py index 6b38b282f43..3b3f76ffd68 100644 --- a/lib/spack/spack/test/directives.py +++ b/lib/spack/spack/test/directives.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize import spack.directives import spack.repo import spack.spec @@ -60,8 +61,8 @@ def test_constraints_from_context_are_merged(mock_packages): @pytest.mark.regression("27754") def test_extends_spec(config, mock_packages): - extender = spack.spec.Spec("extends-spec").concretized() - extendee = spack.spec.Spec("extendee").concretized() + extender = spack.concretize.concretized(spack.spec.Spec("extends-spec")) + extendee = spack.concretize.concretized(spack.spec.Spec("extendee")) assert extender.dependencies assert extender.package.extends(extendee) @@ -207,7 +208,7 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage): def test_redistribute_directive(test_repo, spec_str, distribute_src, distribute_bin): spec = spack.spec.Spec(spec_str) assert spec.package_class.redistribute_source(spec) == distribute_src - concretized_spec = spec.concretized() + concretized_spec = spack.concretize.concretized(spec) assert concretized_spec.package.redistribute_binary == distribute_bin diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py index 169c6a9c5e8..26f847add02 100644 --- a/lib/spack/spack/test/directory_layout.py +++ b/lib/spack/spack/test/directory_layout.py @@ -14,6 +14,7 @@ from llnl.path import path_to_os_path +import spack.concretize import spack.hash_types import spack.paths import spack.repo @@ -60,7 +61,7 @@ def test_yaml_directory_layout_parameters(tmpdir, default_mock_concretization): assert package7 == path_package7 # Test separation of architecture or namespace - spec2 = Spec("libelf").concretized() + spec2 = spack.concretize.concretized(Spec("libelf")) arch_scheme = ( "{architecture.platform}/{architecture.target}/{architecture.os}/{name}/{version}/{hash:7}" @@ -98,7 +99,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 # real error, it will be caught by concretization tests. try: - spec = spack.spec.Spec(name).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(name)) except Exception: continue @@ -137,7 +138,7 @@ def test_read_and_write_spec(temporary_store, config, mock_packages): assert norm.eq_dag(spec_from_file) # TODO: revise this when build deps are in dag_hash - conc = read_separately.concretized().copy(deps=stored_deptypes) + conc = spack.concretize.concretized(read_separately).copy(deps=stored_deptypes) assert conc == spec_from_file assert conc.eq_dag(spec_from_file) @@ -173,12 +174,10 @@ def test_handle_unknown_package(temporary_store, config, mock_packages, tmp_path # Create all the packages that are not in mock. installed_specs = {} for pkg_name in packages: - spec = spack.spec.Spec(pkg_name) - # If a spec fails to concretize, just skip it. If it is a # real error, it will be caught by concretization tests. try: - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec(pkg_name)) except Exception: continue @@ -210,7 +209,7 @@ def test_find(temporary_store, config, mock_packages): if name.startswith("external"): # External package tests cannot be installed continue - spec = spack.spec.Spec(name).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(name)) installed_specs[spec.name] = spec layout.create_install_directory(spec) diff --git a/lib/spack/spack/test/flag_handlers.py b/lib/spack/spack/test/flag_handlers.py index fd63de4b82f..99b197c978d 100644 --- a/lib/spack/spack/test/flag_handlers.py +++ b/lib/spack/spack/test/flag_handlers.py @@ -8,6 +8,7 @@ import pytest import spack.build_environment +import spack.concretize import spack.spec from spack.package import build_system_flags, env_flags, inject_flags @@ -31,10 +32,10 @@ def add_o3_to_build_system_cflags(pkg, name, flags): class TestFlagHandlers: def test_no_build_system_flags(self, temp_env): # Test that both autotools and cmake work getting no build_system flags - s1 = spack.spec.Spec("cmake-client").concretized() + s1 = spack.concretize.concretized(spack.spec.Spec("cmake-client")) spack.build_environment.setup_package(s1.package, False) - s2 = spack.spec.Spec("patchelf").concretized() + s2 = spack.concretize.concretized(spack.spec.Spec("patchelf")) spack.build_environment.setup_package(s2.package, False) # Use cppflags as a canary @@ -44,28 +45,28 @@ def test_no_build_system_flags(self, temp_env): def test_unbound_method(self, temp_env): # Other tests test flag_handlers set as bound methods and functions. # This tests an unbound method in python2 (no change in python3). - s = spack.spec.Spec("mpileaks cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("mpileaks cppflags=-g")) s.package.flag_handler = s.package.__class__.inject_flags spack.build_environment.setup_package(s.package, False) assert os.environ["SPACK_CPPFLAGS"] == "-g" assert "CPPFLAGS" not in os.environ def test_inject_flags(self, temp_env): - s = spack.spec.Spec("mpileaks cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("mpileaks cppflags=-g")) s.package.flag_handler = inject_flags spack.build_environment.setup_package(s.package, False) assert os.environ["SPACK_CPPFLAGS"] == "-g" assert "CPPFLAGS" not in os.environ def test_env_flags(self, temp_env): - s = spack.spec.Spec("mpileaks cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("mpileaks cppflags=-g")) s.package.flag_handler = env_flags spack.build_environment.setup_package(s.package, False) assert os.environ["CPPFLAGS"] == "-g" assert "SPACK_CPPFLAGS" not in os.environ def test_build_system_flags_cmake(self, temp_env): - s = spack.spec.Spec("cmake-client cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("cmake-client cppflags=-g")) s.package.flag_handler = build_system_flags spack.build_environment.setup_package(s.package, False) assert "SPACK_CPPFLAGS" not in os.environ @@ -77,7 +78,7 @@ def test_build_system_flags_cmake(self, temp_env): } def test_build_system_flags_autotools(self, temp_env): - s = spack.spec.Spec("patchelf cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("patchelf cppflags=-g")) s.package.flag_handler = build_system_flags spack.build_environment.setup_package(s.package, False) assert "SPACK_CPPFLAGS" not in os.environ @@ -86,7 +87,7 @@ def test_build_system_flags_autotools(self, temp_env): def test_build_system_flags_not_implemented(self, temp_env): """Test the command line flags method raises a NotImplementedError""" - s = spack.spec.Spec("mpileaks cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("mpileaks cppflags=-g")) s.package.flag_handler = build_system_flags try: spack.build_environment.setup_package(s.package, False) @@ -95,7 +96,7 @@ def test_build_system_flags_not_implemented(self, temp_env): assert True def test_add_build_system_flags_autotools(self, temp_env): - s = spack.spec.Spec("patchelf cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("patchelf cppflags=-g")) s.package.flag_handler = add_o3_to_build_system_cflags spack.build_environment.setup_package(s.package, False) assert "-g" in os.environ["SPACK_CPPFLAGS"] @@ -103,7 +104,7 @@ def test_add_build_system_flags_autotools(self, temp_env): assert s.package.configure_flag_args == ["CFLAGS=-O3"] def test_add_build_system_flags_cmake(self, temp_env): - s = spack.spec.Spec("cmake-client cppflags=-g").concretized() + s = spack.concretize.concretized(spack.spec.Spec("cmake-client cppflags=-g")) s.package.flag_handler = add_o3_to_build_system_cflags spack.build_environment.setup_package(s.package, False) assert "-g" in os.environ["SPACK_CPPFLAGS"] @@ -111,7 +112,7 @@ def test_add_build_system_flags_cmake(self, temp_env): assert s.package.cmake_flag_args == ["-DCMAKE_C_FLAGS=-O3"] def test_ld_flags_cmake(self, temp_env): - s = spack.spec.Spec("cmake-client ldflags=-mthreads").concretized() + s = spack.concretize.concretized(spack.spec.Spec("cmake-client ldflags=-mthreads")) s.package.flag_handler = build_system_flags spack.build_environment.setup_package(s.package, False) assert "SPACK_LDFLAGS" not in os.environ @@ -123,7 +124,7 @@ def test_ld_flags_cmake(self, temp_env): } def test_ld_libs_cmake(self, temp_env): - s = spack.spec.Spec("cmake-client ldlibs=-lfoo").concretized() + s = spack.concretize.concretized(spack.spec.Spec("cmake-client ldlibs=-lfoo")) s.package.flag_handler = build_system_flags spack.build_environment.setup_package(s.package, False) assert "SPACK_LDLIBS" not in os.environ @@ -139,7 +140,7 @@ def test_flag_handler(self, name, flags): flags.append("-foo") return (flags, None, None) - s = spack.spec.Spec("cmake-client").concretized() + s = spack.concretize.concretized(spack.spec.Spec("cmake-client")) s.package.flag_handler = test_flag_handler spack.build_environment.setup_package(s.package, False) diff --git a/lib/spack/spack/test/git_fetch.py b/lib/spack/spack/test/git_fetch.py index 54ac9d8a1be..7ece1cdcd59 100644 --- a/lib/spack/spack/test/git_fetch.py +++ b/lib/spack/spack/test/git_fetch.py @@ -11,6 +11,7 @@ from llnl.util.filesystem import mkdirp, touch, working_dir +import spack.concretize import spack.config import spack.error import spack.fetch_strategy @@ -186,8 +187,9 @@ def test_adhoc_version_submodules( monkeypatch.setitem(pkg_class.versions, Version("git"), t.args) 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.concretize() + spec = spack.concretize.concretized( + Spec("git-test@{0}".format(mock_git_repository.unversioned_commit)) + ) spec.package.do_stage() collected_fnames = set() for root, dirs, files in os.walk(spec.package.stage.source_path): diff --git a/lib/spack/spack/test/graph.py b/lib/spack/spack/test/graph.py index a622e855e55..898c47f72ec 100644 --- a/lib/spack/spack/test/graph.py +++ b/lib/spack/spack/test/graph.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import io +import spack.concretize import spack.graph import spack.spec @@ -39,7 +40,7 @@ def test_dynamic_dot_graph_mpileaks(default_mock_concretization): def test_ascii_graph_mpileaks(config, mock_packages, monkeypatch): monkeypatch.setattr(spack.graph.AsciiGraph, "_node_label", lambda self, node: node.name) - s = spack.spec.Spec("mpileaks").concretized() + s = spack.concretize.concretized(spack.spec.Spec("mpileaks")) stream = io.StringIO() graph = spack.graph.AsciiGraph() diff --git a/lib/spack/spack/test/hg_fetch.py b/lib/spack/spack/test/hg_fetch.py index f186ea14541..39479431b07 100644 --- a/lib/spack/spack/test/hg_fetch.py +++ b/lib/spack/spack/test/hg_fetch.py @@ -9,6 +9,7 @@ from llnl.util.filesystem import mkdirp, touch, working_dir +import spack.concretize import spack.config from spack.fetch_strategy import HgFetchStrategy from spack.spec import Spec @@ -41,7 +42,7 @@ def test_fetch(type_of_test, secure, mock_hg_repository, config, mutable_mock_re h = mock_hg_repository.hash # Construct the package under test - s = Spec("hg-test").concretized() + s = spack.concretize.concretized(Spec("hg-test")) monkeypatch.setitem(s.package.versions, Version("hg"), t.args) # Enter the stage directory and check some properties diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index 7b45b8969f9..334e1699349 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -12,6 +12,7 @@ import llnl.util.filesystem as fs import spack.build_environment +import spack.concretize import spack.config import spack.database import spack.error @@ -42,7 +43,7 @@ def find_nothing(*args): def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch): - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) PackageInstaller([spec.package], explicit=True).install() assert spec.installed @@ -54,7 +55,7 @@ def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch): @pytest.mark.regression("11870") 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""" - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) PackageInstaller([spec.package], explicit=True).install() assert spec.installed @@ -72,8 +73,7 @@ def test_uninstall_non_existing_package(install_mockery, mock_fetch, monkeypatch def test_pkg_attributes(install_mockery, mock_fetch, monkeypatch): # Get a basic concrete spec for the dummy package. - spec = Spec("attributes-foo-app ^attributes-foo") - spec.concretize() + spec = spack.concretize.concretized(Spec("attributes-foo-app ^attributes-foo")) assert spec.concrete pkg = spec.package @@ -128,7 +128,7 @@ def remove_prefix(self): def test_partial_install_delete_prefix_and_stage(install_mockery, mock_fetch, working_env): - s = Spec("canfail").concretized() + s = spack.concretize.concretized(Spec("canfail")) instance_rm_prefix = s.package.remove_prefix @@ -158,7 +158,7 @@ def test_failing_overwrite_install_should_keep_previous_installation( the original install prefix instead of cleaning it. """ # Do a successful install - s = Spec("canfail").concretized() + s = spack.concretize.concretized(Spec("canfail")) s.package.set_install_succeed() # Do a failing overwrite install @@ -174,13 +174,11 @@ def test_failing_overwrite_install_should_keep_previous_installation( def test_dont_add_patches_to_installed_package(install_mockery, mock_fetch, monkeypatch): - dependency = Spec("dependency-install") - dependency.concretize() + dependency = spack.concretize.concretized(Spec("dependency-install")) PackageInstaller([dependency.package], explicit=True).install() dependency_hash = dependency.dag_hash() - dependent = Spec("dependent-install ^/" + dependency_hash) - dependent.concretize() + dependent = spack.concretize.concretized(Spec("dependent-install ^/" + dependency_hash)) monkeypatch.setitem( dependency.package.patches, @@ -192,20 +190,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): - dependency = Spec("dependency-install") - dependency.concretize() + dependency = spack.concretize.concretized(Spec("dependency-install")) PackageInstaller([dependency.package], explicit=True).install() dependency_hash = dependency.dag_hash() dependent = Spec("conflicting-dependent ^/" + dependency_hash) with pytest.raises(spack.error.UnsatisfiableSpecError): - dependent.concretize() + spack.concretize.concretized(dependent) def test_install_dependency_symlinks_pkg(install_mockery, mock_fetch, mutable_mock_repo): """Test dependency flattening/symlinks mock package.""" - spec = Spec("flatten-deps") - spec.concretize() + spec = spack.concretize.concretized(Spec("flatten-deps")) pkg = spec.package PackageInstaller([pkg], explicit=True).install() @@ -216,7 +212,7 @@ def test_install_dependency_symlinks_pkg(install_mockery, mock_fetch, mutable_mo def test_install_times(install_mockery, mock_fetch, mutable_mock_repo): """Test install times added.""" - spec = Spec("dev-build-test-install-phases").concretized() + spec = spack.concretize.concretized(Spec("dev-build-test-install-phases")) PackageInstaller([spec.package], explicit=True).install() # Ensure dependency directory exists after the installation. @@ -237,8 +233,7 @@ def test_flatten_deps(install_mockery, mock_fetch, mutable_mock_repo): """Explicitly test the flattening code for coverage purposes.""" # Unfortunately, executing the 'flatten-deps' spec's installation does # not affect code coverage results, so be explicit here. - spec = Spec("dependent-install") - spec.concretize() + spec = spack.concretize.concretized(Spec("dependent-install")) pkg = spec.package PackageInstaller([pkg], explicit=True).install() @@ -273,7 +268,7 @@ def install_upstream(tmpdir_factory, gen_mock_layout, install_mockery): def _install_upstream(*specs): for spec_str in specs: - prepared_db.add(Spec(spec_str).concretized()) + prepared_db.add(spack.concretize.concretized(Spec(spec_str))) downstream_root = str(tmpdir_factory.mktemp("mock_downstream_db_root")) return downstream_root, upstream_layout @@ -286,8 +281,7 @@ def test_installed_upstream_external(install_upstream, mock_fetch): """ store_root, _ = install_upstream("externaltool") with spack.store.use_store(store_root): - dependent = Spec("externaltest") - dependent.concretize() + dependent = spack.concretize.concretized(Spec("externaltest")) new_dependency = dependent["externaltool"] assert new_dependency.external @@ -305,8 +299,8 @@ def test_installed_upstream(install_upstream, mock_fetch): """ store_root, upstream_layout = install_upstream("dependency-install") with spack.store.use_store(store_root): - dependency = Spec("dependency-install").concretized() - dependent = Spec("dependent-install").concretized() + dependency = spack.concretize.concretized(Spec("dependency-install")) + dependent = spack.concretize.concretized(Spec("dependent-install")) new_dependency = dependent["dependency-install"] assert new_dependency.installed_upstream @@ -320,7 +314,7 @@ def test_installed_upstream(install_upstream, mock_fetch): @pytest.mark.disable_clean_stage_check def test_partial_install_keep_prefix(install_mockery, mock_fetch, monkeypatch, working_env): - s = Spec("canfail").concretized() + s = spack.concretize.concretized(Spec("canfail")) # 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) @@ -337,7 +331,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): - s = Spec("canfail").concretized() + s = spack.concretize.concretized(Spec("canfail")) monkeypatch.setattr(spack.package_base.PackageBase, "remove_prefix", mock_remove_prefix) s.package.set_install_succeed() @@ -357,8 +351,8 @@ def test_install_prefix_collision_fails(config, mock_fetch, mock_packages, tmpdi projections = {"projections": {"all": "one-prefix-per-package-{name}"}} with spack.store.use_store(str(tmpdir), extra_data=projections): with spack.config.override("config:checksum", False): - pkg_a = Spec("libelf@0.8.13").concretized().package - pkg_b = Spec("libelf@0.8.12").concretized().package + pkg_a = spack.concretize.concretized(Spec("libelf@0.8.13")).package + pkg_b = spack.concretize.concretized(Spec("libelf@0.8.12")).package PackageInstaller([pkg_a], explicit=True, fake=True).install() with pytest.raises(InstallError, match="Install prefix collision"): @@ -366,14 +360,14 @@ def test_install_prefix_collision_fails(config, mock_fetch, mock_packages, tmpdi def test_store(install_mockery, mock_fetch): - spec = Spec("cmake-client").concretized() + spec = spack.concretize.concretized(Spec("cmake-client")) pkg = spec.package PackageInstaller([pkg], fake=True, explicit=True).install() @pytest.mark.disable_clean_stage_check def test_failing_build(install_mockery, mock_fetch, capfd): - spec = Spec("failing-build").concretized() + spec = spack.concretize.concretized(Spec("failing-build")) pkg = spec.package with pytest.raises(spack.build_environment.ChildError, match="Expected failure"): @@ -388,8 +382,7 @@ def test_uninstall_by_spec_errors(mutable_database): """Test exceptional cases with the uninstall command.""" # Try to uninstall a spec that has not been installed - spec = Spec("dependent-install") - spec.concretize() + spec = spack.concretize.concretized(Spec("dependent-install")) with pytest.raises(InstallError, match="is not installed"): PackageBase.uninstall_by_spec(spec) @@ -402,7 +395,7 @@ def test_uninstall_by_spec_errors(mutable_database): @pytest.mark.disable_clean_stage_check def test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages, capfd, ensure_debug): """Test install phases with the nosource package.""" - spec = Spec("nosource").concretized() + spec = spack.concretize.concretized(Spec("nosource")) pkg = spec.package # Make sure install works even though there is no associated code. @@ -419,7 +412,7 @@ def test_nosource_bundle_pkg_install( install_mockery, mock_fetch, mock_packages, capfd, ensure_debug ): """Test install phases with the nosource-bundle package.""" - spec = Spec("nosource-bundle").concretized() + spec = spack.concretize.concretized(Spec("nosource-bundle")) pkg = spec.package # Make sure install works even though there is no associated code. @@ -433,7 +426,7 @@ def test_nosource_bundle_pkg_install( def test_nosource_pkg_install_post_install(install_mockery, mock_fetch, mock_packages): """Test install phases with the nosource package with post-install.""" - spec = Spec("nosource-install").concretized() + spec = spack.concretize.concretized(Spec("nosource-install")) pkg = spec.package # Make sure both the install and post-install package methods work. @@ -450,14 +443,14 @@ def test_nosource_pkg_install_post_install(install_mockery, mock_fetch, mock_pac def test_pkg_build_paths(install_mockery): # Get a basic concrete spec for the trivial install package. - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) assert spec.package.log_path.endswith(_spack_build_logfile) assert spec.package.env_path.endswith(_spack_build_envfile) def test_pkg_install_paths(install_mockery): # Get a basic concrete spec for the trivial install package. - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) log_path = os.path.join(spec.prefix, ".spack", _spack_build_logfile + ".gz") assert spec.package.install_log_path == log_path @@ -494,7 +487,7 @@ def test_pkg_install_paths(install_mockery): def test_log_install_without_build_files(install_mockery): """Test the installer log function when no build files are present.""" # Get a basic concrete spec for the trivial install package. - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) # Attempt installing log without the build log file with pytest.raises(IOError, match="No such file or directory"): @@ -516,7 +509,7 @@ def _install(src, dest): monkeypatch.setattr(fs, "install", _install) - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) # Set up mock build files and try again to include archive failure log_path = spec.package.log_path @@ -588,7 +581,7 @@ def test_empty_install_sanity_check_prefix( monkeypatch, install_mockery, mock_fetch, mock_packages ): """Test empty install triggers sanity_check_prefix.""" - spec = Spec("failing-empty-install").concretized() + spec = spack.concretize.concretized(Spec("failing-empty-install")) with pytest.raises(spack.build_environment.ChildError, match="Nothing was installed"): PackageInstaller([spec.package], explicit=True).install() @@ -600,7 +593,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 because of the missing patch.""" # Create a spec s with non-existing patches - s = Spec("trivial-install-test-package").concretized() + s = spack.concretize.concretized(Spec("trivial-install-test-package")) patches = ["a" * 64] s_dict = s.to_dict() s_dict["spec"]["nodes"][0]["patches"] = patches diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py index 38bc1609821..ec00672e902 100644 --- a/lib/spack/spack/test/installer.py +++ b/lib/spack/spack/test/installer.py @@ -17,6 +17,7 @@ import llnl.util.tty as tty import spack.binary_distribution +import spack.concretize import spack.database import spack.deptypes as dt import spack.error @@ -82,7 +83,10 @@ def create_installer( ) -> inst.PackageInstaller: """Create an installer instance for a list of specs or package names that will be concretized.""" - _specs = [spack.spec.Spec(s).concretized() if isinstance(s, str) else s for s in specs] + _specs = [ + spack.concretize.concretized(spack.spec.Spec(s)) if isinstance(s, str) else s + for s in specs + ] _install_args = {} if install_args is None else install_args return inst.PackageInstaller([spec.package for spec in _specs], **_install_args) @@ -97,8 +101,7 @@ def test_hms(sec, result): def test_get_dependent_ids(install_mockery, mock_packages): # Concretize the parent package, which handle dependency too - spec = spack.spec.Spec("pkg-a") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("pkg-a")) assert spec.concrete pkg_id = inst.package_id(spec) @@ -134,8 +137,7 @@ def test_install_msg(monkeypatch): def test_install_from_cache_errors(install_mockery): """Test to ensure cover install from cache errors.""" - spec = spack.spec.Spec("trivial-install-test-package") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) assert spec.concrete # Check with cache-only @@ -154,8 +156,7 @@ def test_install_from_cache_errors(install_mockery): def test_install_from_cache_ok(install_mockery, monkeypatch): """Test to ensure cover _install_from_cache to the return.""" - spec = spack.spec.Spec("trivial-install-test-package") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) monkeypatch.setattr(inst, "_try_install_from_binary_cache", _true) monkeypatch.setattr(spack.hooks, "post_install", _noop) @@ -164,8 +165,7 @@ def test_install_from_cache_ok(install_mockery, monkeypatch): def test_process_external_package_module(install_mockery, monkeypatch, capfd): """Test to simply cover the external module message path.""" - spec = spack.spec.Spec("trivial-install-test-package") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) assert spec.concrete # Ensure take the external module path WITHOUT any changes to the database @@ -192,7 +192,7 @@ def _spec(spec, unsigned=False, mirrors_for_spec=None): # Skip database updates monkeypatch.setattr(spack.database.Database, "add", _noop) - spec = spack.spec.Spec("pkg-a").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("pkg-a")) assert inst._process_binary_cache_tarball(spec.package, explicit=False, unsigned=False) out = capfd.readouterr()[0] @@ -202,8 +202,7 @@ def _spec(spec, unsigned=False, mirrors_for_spec=None): def test_try_install_from_binary_cache(install_mockery, mock_packages, monkeypatch): """Test return false when no match exists in the mirror""" - spec = spack.spec.Spec("mpich") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("mpich")) result = inst._try_install_from_binary_cache(spec.package, False, False) assert not result @@ -275,7 +274,7 @@ def _mock_installed(self): def test_check_before_phase_error(install_mockery): - s = spack.spec.Spec("trivial-install-test-package").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) s.package.stop_before_phase = "beforephase" with pytest.raises(inst.BadInstallPhase) as exc_info: inst._check_last_phase(s.package) @@ -286,7 +285,7 @@ def test_check_before_phase_error(install_mockery): def test_check_last_phase_error(install_mockery): - s = spack.spec.Spec("trivial-install-test-package").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) s.package.stop_before_phase = None s.package.last_phase = "badphase" with pytest.raises(inst.BadInstallPhase) as exc_info: @@ -421,15 +420,13 @@ def test_package_id_err(install_mockery): def test_package_id_ok(install_mockery): - spec = spack.spec.Spec("trivial-install-test-package") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) assert spec.concrete assert spec.name in inst.package_id(spec) def test_fake_install(install_mockery): - spec = spack.spec.Spec("trivial-install-test-package") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")) assert spec.concrete pkg = spec.package @@ -441,7 +438,7 @@ def test_dump_packages_deps_ok(install_mockery, tmpdir, mock_packages): """Test happy path for dump_packages with dependencies.""" spec_name = "simple-inheritance" - spec = spack.spec.Spec(spec_name).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(spec_name)) inst.dump_packages(spec, str(tmpdir)) repo = mock_packages.repos[0] @@ -472,7 +469,7 @@ def _repoerr(repo, name): # the try-except block monkeypatch.setattr(spack.store.STORE.layout, "build_packages_path", bpp_path) - spec = spack.spec.Spec("simple-inheritance").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("simple-inheritance")) path = str(tmpdir) # The call to install_tree will raise the exception since not mocking @@ -582,7 +579,7 @@ def test_check_deps_status_install_failure(install_mockery): """Tests that checking the dependency status on a request to install 'a' fails, if we mark the dependency as failed. """ - s = spack.spec.Spec("pkg-a").concretized() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) for dep in s.traverse(root=False): spack.store.STORE.failure_tracker.mark(dep) @@ -655,8 +652,8 @@ def test_installer_init_requests(install_mockery): @pytest.mark.parametrize("transitive", [True, False]) def test_install_spliced(install_mockery, mock_fetch, monkeypatch, capsys, transitive): """Test installing a spliced spec""" - spec = spack.spec.Spec("splice-t").concretized() - dep = spack.spec.Spec("splice-h+foo").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("splice-t")) + dep = spack.concretize.concretized(spack.spec.Spec("splice-h+foo")) # Do the splice. out = spec.splice(dep, transitive) @@ -670,8 +667,8 @@ def test_install_spliced(install_mockery, mock_fetch, monkeypatch, capsys, trans @pytest.mark.parametrize("transitive", [True, False]) def test_install_spliced_build_spec_installed(install_mockery, capfd, mock_fetch, transitive): """Test installing a spliced spec with the build spec already installed""" - spec = spack.spec.Spec("splice-t").concretized() - dep = spack.spec.Spec("splice-h+foo").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("splice-t")) + dep = spack.concretize.concretized(spack.spec.Spec("splice-h+foo")) # Do the splice. out = spec.splice(dep, transitive) @@ -697,8 +694,8 @@ def test_install_splice_root_from_binary( ): """Test installing a spliced spec with the root available in binary cache""" # Test splicing and rewiring a spec with the same name, different hash. - original_spec = spack.spec.Spec(root_str).concretized() - spec_to_splice = spack.spec.Spec("splice-h+foo").concretized() + original_spec = spack.concretize.concretized(spack.spec.Spec(root_str)) + spec_to_splice = spack.concretize.concretized(spack.spec.Spec("splice-h+foo")) PackageInstaller([original_spec.package, spec_to_splice.package]).install() @@ -854,7 +851,7 @@ def _chgrp(path, group, follow_symlinks=True): monkeypatch.setattr(fs, "chgrp", _chgrp) build_task = create_build_task( - spack.spec.Spec("trivial-install-test-package").concretized().package + spack.concretize.concretized(spack.spec.Spec("trivial-install-test-package")).package ) spec = build_task.request.pkg.spec @@ -1025,7 +1022,8 @@ def test_install_fail_multi(install_mockery, mock_fetch, monkeypatch): def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys): """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.concretized(spack.spec.Spec("pkg-b")) + c = spack.concretize.concretized(spack.spec.Spec("pkg-c")) b_id, c_id = inst.package_id(b), inst.package_id(c) installer = create_installer([b, c], {"fail_fast": True}) @@ -1094,7 +1092,7 @@ def _requeued(installer, task, install_status): def test_install_lock_installed_requeue(install_mockery, monkeypatch, capfd): """Cover basic install handling for installed package.""" - b = spack.spec.Spec("pkg-b").concretized() + b = spack.concretize.concretized(spack.spec.Spec("pkg-b")) b_pkg_id = inst.package_id(b) installer = create_installer([b]) @@ -1280,7 +1278,7 @@ def test_term_status_line(): @pytest.mark.parametrize("explicit", [True, False]) def test_single_external_implicit_install(install_mockery, explicit): pkg = "trivial-install-test-package" - s = spack.spec.Spec(pkg).concretized() + s = spack.concretize.concretized(spack.spec.Spec(pkg)) s.external_path = "/usr" args = {"explicit": [s.dag_hash()] if explicit else []} create_installer([s], args).install() @@ -1289,7 +1287,7 @@ def test_single_external_implicit_install(install_mockery, explicit): def test_overwrite_install_does_install_build_deps(install_mockery, mock_fetch): """When overwrite installing something from sources, build deps should be installed.""" - s = spack.spec.Spec("dtrun3").concretized() + s = spack.concretize.concretized(spack.spec.Spec("dtrun3")) create_installer([s]).install() # Verify there is a pure build dep @@ -1311,7 +1309,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): """Confirm printing of install log skipped if not run/no failures.""" name = "trivial-install-test-package" - s = spack.spec.Spec(name).concretized() + s = spack.concretize.concretized(spack.spec.Spec(name)) pkg = s.package pkg.run_tests = run_tests @@ -1325,7 +1323,7 @@ def test_print_install_test_log_failures( ): """Confirm expected outputs when there are test failures.""" name = "trivial-install-test-package" - s = spack.spec.Spec(name).concretized() + s = spack.concretize.concretized(spack.spec.Spec(name)) pkg = s.package # Missing test log is an error diff --git a/lib/spack/spack/test/mirror.py b/lib/spack/spack/test/mirror.py index c44b96b3fc8..5fa9b1c1d2d 100644 --- a/lib/spack/spack/test/mirror.py +++ b/lib/spack/spack/test/mirror.py @@ -12,6 +12,7 @@ from llnl.util.symlink import resolve_link_target_relative_to_the_link import spack.caches +import spack.concretize import spack.config import spack.fetch_strategy import spack.mirrors.layout @@ -44,7 +45,7 @@ def set_up_package(name, repository, url_attr): 2. Point the package's version args at that repo. """ # Set up packages to point at mock repos. - s = Spec(name).concretized() + s = spack.concretize.concretized(Spec(name)) repos[name] = repository # change the fetch args of the first (only) version. @@ -61,7 +62,7 @@ def check_mirror(): mirrors = {"spack-mirror-test": url_util.path_to_file_url(mirror_root)} with spack.config.override("mirrors", mirrors): with spack.config.override("config:checksum", False): - specs = [Spec(x).concretized() for x in repos] + specs = [spack.concretize.concretized(Spec(x)) for x in repos] spack.mirrors.utils.create(mirror_root, specs) # Stage directory exists @@ -78,7 +79,7 @@ def check_mirror(): # Now try to fetch each package. for name, mock_repo in repos.items(): - spec = Spec(name).concretized() + spec = spack.concretize.concretized(Spec(name)) pkg = spec.package with spack.config.override("config:checksum", False): @@ -213,13 +214,13 @@ def test_invalid_json_mirror_collection(invalid_json, error_message): def test_mirror_archive_paths_no_version(mock_packages, mock_archive): - spec = Spec("trivial-install-test-package@=nonexistingversion").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package@=nonexistingversion")) fetcher = spack.fetch_strategy.URLFetchStrategy(url=mock_archive.url) spack.mirrors.layout.default_mirror_layout(fetcher, "per-package-ref", spec) def test_mirror_with_url_patches(mock_packages, monkeypatch): - spec = Spec("patch-several-dependencies").concretized() + spec = spack.concretize.concretized(Spec("patch-several-dependencies")) files_cached_in_mirror = set() def record_store(_class, fetcher, relative_dst, cosmetic_path=None): diff --git a/lib/spack/spack/test/modules/common.py b/lib/spack/spack/test/modules/common.py index c7f63f64b6d..a664f7440be 100644 --- a/lib/spack/spack/test/modules/common.py +++ b/lib/spack/spack/test/modules/common.py @@ -10,6 +10,7 @@ from llnl.util.symlink import readlink import spack.cmd.modules +import spack.concretize import spack.config import spack.error import spack.modules @@ -61,7 +62,7 @@ def mock_package_perms(monkeypatch): def test_modules_written_with_proper_permissions( mock_module_filename, mock_package_perms, mock_packages, config ): - spec = spack.spec.Spec("mpileaks").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("mpileaks")) # The code tested is common to all module types, but has to be tested from # one. Tcl picked at random @@ -75,7 +76,7 @@ def test_modules_written_with_proper_permissions( def test_modules_default_symlink( module_type, mock_packages, mock_module_filename, mock_module_defaults, config ): - spec = spack.spec.Spec("mpileaks@2.3").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.3")) mock_module_defaults(spec.format("{name}{@version}"), True) generator_cls = spack.modules.module_types[module_type] @@ -181,7 +182,7 @@ def test_get_module_upstream(): @pytest.mark.regression("14347") def test_load_installed_package_not_in_repo(install_mockery, mock_fetch, monkeypatch): """Test that installed packages that have been removed are still loadable""" - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) PackageInstaller([spec.package], explicit=True).install() spack.modules.module_types["tcl"](spec, "default", True).write() diff --git a/lib/spack/spack/test/modules/conftest.py b/lib/spack/spack/test/modules/conftest.py index 1feee7adcba..98fc24010e0 100644 --- a/lib/spack/spack/test/modules/conftest.py +++ b/lib/spack/spack/test/modules/conftest.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize import spack.modules.lmod import spack.modules.tcl import spack.spec @@ -19,7 +20,7 @@ def modulefile_content(request): def _impl(spec_like, module_set_name="default", explicit=True): if isinstance(spec_like, str): spec_like = spack.spec.Spec(spec_like) - spec = spec_like.concretized() + spec = spack.concretize.concretized(spec_like) generator = writer_cls(spec, module_set_name, explicit) generator.write(overwrite=True) written_module = pathlib.Path(generator.layout.filename) @@ -36,7 +37,7 @@ def factory(request, mock_modules_root): writer_cls = getattr(request.module, "writer_cls") def _mock(spec_string, module_set_name="default", explicit=True): - spec = spack.spec.Spec(spec_string).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(spec_string)) return writer_cls(spec, module_set_name, explicit), spec return _mock diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py index a985cb1b7e0..2cc035e205e 100644 --- a/lib/spack/spack/test/modules/lmod.py +++ b/lib/spack/spack/test/modules/lmod.py @@ -9,6 +9,7 @@ import archspec.cpu +import spack.concretize import spack.config import spack.environment as ev import spack.main @@ -436,7 +437,7 @@ def test_modules_relative_to_view( module_configuration("with_view") install("--add", "cmake") - spec = spack.spec.Spec("cmake").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("cmake")) content = modulefile_content("cmake") expected = e.default_view.get_projection_for_spec(spec) @@ -456,7 +457,7 @@ def test_hide_implicits(self, module_configuration, temporary_store): """Tests the addition and removal of hide command in modulerc.""" module_configuration("hide_implicits") - spec = spack.spec.Spec("mpileaks@2.3").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.3")) # mpileaks is defined as implicit, thus hide command should appear in modulerc writer = writer_cls(spec, "default", False) @@ -508,8 +509,8 @@ def test_hide_implicits(self, module_configuration, temporary_store): # three versions of mpileaks are implicit writer = writer_cls(spec, "default", False) writer.write(overwrite=True) - spec_alt1 = spack.spec.Spec("mpileaks@2.2").concretized() - spec_alt2 = spack.spec.Spec("mpileaks@2.1").concretized() + spec_alt1 = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.2")) + spec_alt2 = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.1")) writer_alt1 = writer_cls(spec_alt1, "default", False) writer_alt1.write(overwrite=True) writer_alt2 = writer_cls(spec_alt2, "default", False) diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index d2a8b18b67a..3a63d6b329d 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -9,6 +9,7 @@ import archspec.cpu +import spack.concretize import spack.modules.common import spack.modules.tcl import spack.spec @@ -394,8 +395,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 {mpileaks}" in x]) == 1 - spec = spack.spec.Spec("mpileaks") - spec.concretize() + spec = spack.concretize.concretized(spack.spec.Spec("mpileaks")) content = modulefile_content(spec["callpath"]) assert len([x for x in content if "setenv FOOBAR" in x]) == 1 @@ -469,14 +469,12 @@ def test_hide_implicits_with_arg(self, module_configuration): module_configuration("exclude_implicits") # mpileaks is defined as explicit with explicit argument set on writer - mpileaks_spec = spack.spec.Spec("mpileaks") - mpileaks_spec.concretize() + mpileaks_spec = spack.concretize.concretized(spack.spec.Spec("mpileaks")) writer = writer_cls(mpileaks_spec, "default", True) assert not writer.conf.excluded # callpath is defined as implicit with explicit argument set on writer - callpath_spec = spack.spec.Spec("callpath") - callpath_spec.concretize() + callpath_spec = spack.concretize.concretized(spack.spec.Spec("callpath")) writer = writer_cls(callpath_spec, "default", False) assert writer.conf.excluded @@ -511,7 +509,7 @@ def test_hide_implicits(self, module_configuration, temporary_store): """Tests the addition and removal of hide command in modulerc.""" module_configuration("hide_implicits") - spec = spack.spec.Spec("mpileaks@2.3").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.3")) # mpileaks is defined as implicit, thus hide command should appear in modulerc writer = writer_cls(spec, "default", False) @@ -558,8 +556,8 @@ def test_hide_implicits(self, module_configuration, temporary_store): # three versions of mpileaks are implicit writer = writer_cls(spec, "default", False) writer.write(overwrite=True) - spec_alt1 = spack.spec.Spec("mpileaks@2.2").concretized() - spec_alt2 = spack.spec.Spec("mpileaks@2.1").concretized() + spec_alt1 = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.2")) + spec_alt2 = spack.concretize.concretized(spack.spec.Spec("mpileaks@2.1")) writer_alt1 = writer_cls(spec_alt1, "default", False) writer_alt1.write(overwrite=True) writer_alt2 = writer_cls(spec_alt2, "default", False) diff --git a/lib/spack/spack/test/multimethod.py b/lib/spack/spack/test/multimethod.py index 7e5231ee936..53916c25b8e 100644 --- a/lib/spack/spack/test/multimethod.py +++ b/lib/spack/spack/test/multimethod.py @@ -7,6 +7,7 @@ import pytest +import spack.concretize import spack.config import spack.platforms import spack.spec @@ -29,7 +30,7 @@ def pkg_name(request): def test_no_version_match(pkg_name): - spec = spack.spec.Spec(pkg_name + "@2.0").concretized() + spec = spack.concretize.concretized(spack.spec.Spec(pkg_name + "@2.0")) with pytest.raises(NoSuchMethodError): spec.package.no_version_2() @@ -75,7 +76,7 @@ def test_multimethod_calls( with spack.config.override( "compilers", [compiler_factory(spec="apple-clang@9.1.0", operating_system="elcapitan")] ): - s = spack.spec.Spec(pkg_name + constraint_str).concretized() + s = spack.concretize.concretized(spack.spec.Spec(pkg_name + constraint_str)) msg = f"Method {method_name} from {s} is giving a wrong result" assert getattr(s.package, method_name)() == expected_result, msg @@ -84,10 +85,10 @@ def test_target_match(pkg_name): platform = spack.platforms.host() targets = list(platform.targets.values()) for target in targets[:-1]: - s = spack.spec.Spec(pkg_name + " target=" + target.name).concretized() + s = spack.concretize.concretized(spack.spec.Spec(pkg_name + " 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.concretized(spack.spec.Spec(pkg_name + " target=" + targets[-1].name)) if len(targets) == 1: assert s.package.different_by_target() == targets[-1].name else: @@ -117,5 +118,5 @@ def test_target_match(pkg_name): ], ) def test_multimethod_calls_and_inheritance(spec_str, method_name, expected_result): - s = spack.spec.Spec(spec_str).concretized() + s = spack.concretize.concretized(spack.spec.Spec(spec_str)) assert getattr(s.package, method_name)() == expected_result diff --git a/lib/spack/spack/test/optional_deps.py b/lib/spack/spack/test/optional_deps.py index 18fab35065c..4f5f28d22c4 100644 --- a/lib/spack/spack/test/optional_deps.py +++ b/lib/spack/spack/test/optional_deps.py @@ -5,6 +5,7 @@ import pytest +import spack.concretize from spack.spec import Spec @@ -73,14 +74,11 @@ def spec_and_expected(request): def test_default_variant(config, mock_packages): - spec = Spec("optional-dep-test-3") - spec.concretize() + spec = spack.concretize.concretized(Spec("optional-dep-test-3")) assert "pkg-a" in spec - spec = Spec("optional-dep-test-3~var") - spec.concretize() + spec = spack.concretize.concretized(Spec("optional-dep-test-3~var")) assert "pkg-a" in spec - spec = Spec("optional-dep-test-3+var") - spec.concretize() + spec = spack.concretize.concretized(Spec("optional-dep-test-3+var")) assert "pkg-b" in spec diff --git a/lib/spack/spack/test/package_class.py b/lib/spack/spack/test/package_class.py index 72eaa1f739b..4f0c942d4c0 100644 --- a/lib/spack/spack/test/package_class.py +++ b/lib/spack/spack/test/package_class.py @@ -18,6 +18,7 @@ import llnl.util.filesystem as fs import spack.compilers +import spack.concretize import spack.deptypes as dt import spack.error import spack.install_test @@ -167,8 +168,7 @@ def setup_install_test(source_paths, test_root): ) def test_cache_extra_sources(install_mockery, spec, sources, extras, expect): """Test the package's cache extra test sources helper function.""" - s = spack.spec.Spec(spec).concretized() - s.package.spec.concretize() + s = spack.concretize.concretized(spack.spec.Spec(spec)) source_path = s.package.stage.source_path srcs = [fs.join_path(source_path, src) for src in sources] @@ -206,8 +206,7 @@ def test_cache_extra_sources(install_mockery, spec, sources, extras, expect): def test_cache_extra_sources_fails(install_mockery): - s = spack.spec.Spec("pkg-a").concretized() - s.package.spec.concretize() + s = spack.concretize.concretized(spack.spec.Spec("pkg-a")) with pytest.raises(InstallError) as exc_info: spack.install_test.cache_extra_test_sources(s.package, ["/a/b", "no-such-file"]) diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py index ad4c797cf9d..88216539c4a 100644 --- a/lib/spack/spack/test/packages.py +++ b/lib/spack/spack/test/packages.py @@ -8,6 +8,7 @@ import pytest import spack.build_systems.cmake as cmake +import spack.concretize import spack.directives import spack.error import spack.fetch_strategy @@ -76,13 +77,13 @@ def test_inheritance_of_directives(self): assert len(pkg_cls.provided) == 2 # Check that Spec instantiation behaves as we expect - s = Spec("simple-inheritance").concretized() + s = spack.concretize.concretized(Spec("simple-inheritance")) assert "^cmake" in s assert "^openblas" in s assert "+openblas" in s assert "mpi" in s - s = Spec("simple-inheritance~openblas").concretized() + s = spack.concretize.concretized(Spec("simple-inheritance~openblas")) assert "^cmake" in s assert "^openblas" not in s assert "~openblas" in s @@ -90,9 +91,8 @@ def test_inheritance_of_directives(self): @pytest.mark.regression("11844") def test_inheritance_of_patches(self): - s = Spec("patch-inheritance") # Will error if inheritor package cannot find inherited patch files - s.concretize() + _ = spack.concretize.concretized(Spec("patch-inheritance")) def test_import_class_from_package(self): from spack.pkg.builtin.mock.mpich import Mpich # noqa: F401 @@ -116,7 +116,7 @@ def test_import_namespace_container_modules(self): def test_urls_for_versions(mock_packages, config): """Version directive without a 'url' argument should use default url.""" for spec_str in ("url_override@0.9.0", "url_override@1.0.0"): - s = Spec(spec_str).concretized() + s = spack.concretize.concretized(Spec(spec_str)) url = s.package.url_for_version("0.9.0") assert url == "http://www.anothersite.org/uo-0.9.0.tgz" @@ -138,7 +138,7 @@ def test_url_for_version_with_no_urls(mock_packages, config): def test_custom_cmake_prefix_path(mock_packages, config): - spec = Spec("depends-on-define-cmake-prefix-paths").concretized() + spec = spack.concretize.concretized(Spec("depends-on-define-cmake-prefix-paths")) assert cmake.get_cmake_prefix_path(spec.package) == [ spec["define-cmake-prefix-paths"].prefix.test @@ -146,7 +146,7 @@ def test_custom_cmake_prefix_path(mock_packages, config): def test_url_for_version_with_only_overrides(mock_packages, config): - s = Spec("url-only-override").concretized() + s = spack.concretize.concretized(Spec("url-only-override")) # 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" @@ -161,7 +161,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): - s = Spec("url-only-override-with-gaps").concretized() + s = spack.concretize.concretized(Spec("url-only-override-with-gaps")) # 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" diff --git a/lib/spack/spack/test/packaging.py b/lib/spack/spack/test/packaging.py index 1732c3e9906..a95e9c74efc 100644 --- a/lib/spack/spack/test/packaging.py +++ b/lib/spack/spack/test/packaging.py @@ -21,6 +21,7 @@ import spack.binary_distribution as bindist import spack.cmd.buildcache as buildcache +import spack.concretize import spack.config import spack.error import spack.fetch_strategy @@ -49,7 +50,7 @@ @pytest.mark.usefixtures("install_mockery", "mock_gnupghome") def test_buildcache(mock_archive, tmp_path, monkeypatch, mutable_config): # Install a test package - spec = Spec("trivial-install-test-package").concretized() + spec = spack.concretize.concretized(Spec("trivial-install-test-package")) monkeypatch.setattr(spec.package, "fetcher", URLFetchStrategy(url=mock_archive.url)) PackageInstaller([spec.package], explicit=True).install() pkghash = "/" + str(spec.dag_hash(7)) diff --git a/lib/spack/spack/test/patch.py b/lib/spack/spack/test/patch.py index 4b5f31b904a..099d4e461d5 100644 --- a/lib/spack/spack/test/patch.py +++ b/lib/spack/spack/test/patch.py @@ -13,6 +13,7 @@ from llnl.util.filesystem import mkdirp, touch, working_dir +import spack.concretize import spack.error import spack.fetch_strategy import spack.patch @@ -92,7 +93,7 @@ def mock_patch_stage(tmpdir_factory, monkeypatch): def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256, config): # Make a patch object url = url_util.path_to_file_url(filename) - s = Spec("patch").concretized() + s = spack.concretize.concretized(Spec("patch")) # make a stage with Stage(url) as stage: # TODO: url isn't used; maybe refactor Stage @@ -146,8 +147,7 @@ def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256, config): def test_patch_in_spec(mock_packages, config): """Test whether patches in a package appear in the spec.""" - spec = Spec("patch") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch")) assert "patches" in list(spec.variants.keys()) # Here the order is bar, foo, baz. Note that MV variants order @@ -165,18 +165,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 an x.y version. """ - spec1 = Spec("patch@1.0.1") - spec1.concretize() + spec1 = spack.concretize.concretized(Spec("patch@1.0.1")) assert biz_sha256 in spec1.variants["patches"].value - spec2 = Spec("patch@=1.0") - spec2.concretize() + spec2 = spack.concretize.concretized(Spec("patch@=1.0")) assert biz_sha256 not in spec2.variants["patches"].value def test_patch_order(mock_packages, config): - spec = Spec("dep-diamond-patch-top") - spec.concretize() + spec = spack.concretize.concretized(Spec("dep-diamond-patch-top")) mid2_sha256 = ( "mid21234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" @@ -234,8 +231,7 @@ def test_nested_directives(mock_packages): @pytest.mark.not_on_windows("Test requires Autotools") def test_patched_dependency(mock_packages, install_mockery, mock_fetch): """Test whether patched dependencies work.""" - spec = Spec("patch-a-dependency") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch-a-dependency")) assert "patches" in list(spec["libelf"].variants.keys()) # make sure the patch makes it into the dependency spec @@ -275,8 +271,7 @@ def test_patch_failure_develop_spec_exits_gracefully( ): """ensure that a failing patch does not trigger exceptions for develop specs""" - spec = Spec(f"patch-a-dependency ^libelf dev_path={tmpdir}") - spec.concretize() + spec = spack.concretize.concretized(Spec(f"patch-a-dependency ^libelf dev_path={tmpdir}")) libelf = spec["libelf"] assert "patches" in list(libelf.variants.keys()) pkg = libelf.package @@ -292,8 +287,7 @@ def test_patch_failure_restages(mock_packages, install_mockery, mock_fetch): ensure that a failing patch does not trigger exceptions for non-develop specs and the source gets restaged """ - spec = Spec("patch-a-dependency") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch-a-dependency")) pkg = spec["libelf"].package with pkg.stage: bad_patch_indicator = trigger_bad_patch(pkg) @@ -304,8 +298,7 @@ def test_patch_failure_restages(mock_packages, install_mockery, mock_fetch): def test_multiple_patched_dependencies(mock_packages, config): """Test whether multiple patched dependencies work.""" - spec = Spec("patch-several-dependencies") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch-several-dependencies")) # basic patch on libelf assert "patches" in list(spec["libelf"].variants.keys()) @@ -320,8 +313,7 @@ def test_multiple_patched_dependencies(mock_packages, config): def test_conditional_patched_dependencies(mock_packages, config): """Test whether conditional patched dependencies work.""" - spec = Spec("patch-several-dependencies @1.0") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch-several-dependencies @1.0")) # basic patch on libelf assert "patches" in list(spec["libelf"].variants.keys()) @@ -397,8 +389,7 @@ def get_patch(spec, ending): def test_conditional_patched_deps_with_conditions(mock_packages, config): """Test whether conditional patched dependencies with conditions work.""" - spec = Spec("patch-several-dependencies @1.0 ^libdwarf@20111030") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch-several-dependencies @1.0 ^libdwarf@20111030")) libelf = spec["libelf"] libdwarf = spec["libdwarf"] @@ -413,8 +404,7 @@ def test_write_and_read_sub_dags_with_patched_deps(mock_packages, config): """Test whether patched dependencies are still correct after writing and reading a sub-DAG of a concretized Spec. """ - spec = Spec("patch-several-dependencies @1.0 ^libdwarf@20111030") - spec.concretize() + spec = spack.concretize.concretized(Spec("patch-several-dependencies @1.0 ^libdwarf@20111030")) # write to YAML and read back in -- new specs will *only* contain # their sub-DAGs, and won't contain the dependent that patched them @@ -475,7 +465,7 @@ def test_equality(): def test_sha256_setter(mock_patch_stage, config): path = os.path.join(data_path, "foo.patch") - s = Spec("patch").concretized() + s = spack.concretize.concretized(Spec("patch")) patch = spack.patch.FilePatch(s.package, path, level=1, working_dir=".") patch.sha256 = "abc" diff --git a/lib/spack/spack/test/rewiring.py b/lib/spack/spack/test/rewiring.py index 9cf16ce6c27..d88e9ca7a61 100644 --- a/lib/spack/spack/test/rewiring.py +++ b/lib/spack/spack/test/rewiring.py @@ -9,6 +9,7 @@ import pytest +import spack.concretize import spack.deptypes as dt import spack.rewiring import spack.store @@ -39,8 +40,8 @@ def check_spliced_spec_prefixes(spliced_spec): @pytest.mark.parametrize("transitive", [True, False]) def test_rewire_db(mock_fetch, install_mockery, transitive): """Tests basic rewiring without binary executables.""" - spec = Spec("splice-t^splice-h~foo").concretized() - dep = Spec("splice-h+foo").concretized() + spec = spack.concretize.concretized(Spec("splice-t^splice-h~foo")) + dep = spack.concretize.concretized(Spec("splice-h+foo")) PackageInstaller([spec.package, dep.package], explicit=True).install() spliced_spec = spec.splice(dep, transitive=transitive) assert spec.dag_hash() != spliced_spec.dag_hash() @@ -63,8 +64,8 @@ def test_rewire_db(mock_fetch, install_mockery, transitive): @pytest.mark.parametrize("transitive", [True, False]) def test_rewire_bin(mock_fetch, install_mockery, transitive): """Tests basic rewiring with binary executables.""" - spec = Spec("quux").concretized() - dep = Spec("garply cflags=-g").concretized() + spec = spack.concretize.concretized(Spec("quux")) + dep = spack.concretize.concretized(Spec("garply cflags=-g")) PackageInstaller([spec.package, dep.package], explicit=True).install() spliced_spec = spec.splice(dep, transitive=transitive) @@ -92,8 +93,8 @@ def test_rewire_bin(mock_fetch, install_mockery, transitive): def test_rewire_writes_new_metadata(mock_fetch, install_mockery): """Tests that new metadata was written during a rewire. Accuracy of metadata is left to other tests.""" - spec = Spec("quux").concretized() - dep = Spec("garply cflags=-g").concretized() + spec = spack.concretize.concretized(Spec("quux")) + dep = spack.concretize.concretized(Spec("garply cflags=-g")) PackageInstaller([spec.package, dep.package], explicit=True).install() spliced_spec = spec.splice(dep, transitive=True) spack.rewiring.rewire(spliced_spec) @@ -136,8 +137,8 @@ def test_rewire_writes_new_metadata(mock_fetch, install_mockery): @pytest.mark.parametrize("transitive", [True, False]) def test_uninstall_rewired_spec(mock_fetch, install_mockery, transitive): """Test that rewired packages can be uninstalled as normal.""" - spec = Spec("quux").concretized() - dep = Spec("garply cflags=-g").concretized() + spec = spack.concretize.concretized(Spec("quux")) + dep = spack.concretize.concretized(Spec("garply cflags=-g")) PackageInstaller([spec.package, dep.package], explicit=True).install() spliced_spec = spec.splice(dep, transitive=transitive) spack.rewiring.rewire(spliced_spec) @@ -150,8 +151,8 @@ def test_uninstall_rewired_spec(mock_fetch, install_mockery, transitive): def test_rewire_not_installed_fails(mock_fetch, install_mockery): """Tests error when an attempt is made to rewire a package that was not previously installed.""" - spec = Spec("quux").concretized() - dep = Spec("garply cflags=-g").concretized() + spec = spack.concretize.concretized(Spec("quux")) + dep = spack.concretize.concretized(Spec("garply cflags=-g")) spliced_spec = spec.splice(dep, False) with pytest.raises( spack.rewiring.PackageNotInstalledError, @@ -165,8 +166,8 @@ def test_rewire_virtual(mock_fetch, install_mockery): dep = "splice-a" alt_dep = "splice-h" - spec = Spec(f"splice-vt^{dep}").concretized() - alt_spec = Spec(alt_dep).concretized() + spec = spack.concretize.concretized(Spec(f"splice-vt^{dep}")) + alt_spec = spack.concretize.concretized(Spec(alt_dep)) PackageInstaller([spec.package, alt_spec.package]).install() diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py index 05cc15f3dab..c16585d7cec 100644 --- a/lib/spack/spack/test/spec_dag.py +++ b/lib/spack/spack/test/spec_dag.py @@ -7,6 +7,7 @@ """ import pytest +import spack.concretize import spack.deptypes as dt import spack.error import spack.repo @@ -75,7 +76,7 @@ def test_test_deptype(tmpdir): builder.add_package("w", dependencies=[("x", "test", None), ("y", None, None)]) with spack.repo.use_repositories(builder.root): - spec = Spec("w").concretized(tests=("w",)) + spec = spack.concretize.concretized(Spec("w"), tests=("w",)) assert "x" in spec assert "z" not in spec @@ -107,8 +108,7 @@ def test_installed_deps(monkeypatch, mock_packages): # 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 # (concrete) installation. - c_spec = Spec(c) - c_spec.concretize() + c_spec = spack.concretize.concretized(Spec(c)) assert c_spec[d].version == spack.version.Version("2") installed_names = [s.name for s in c_spec.traverse()] @@ -123,7 +123,7 @@ def _mock_installed(self): # *if* we're doing a fresh installation. a_spec = Spec(a) a_spec._add_dependency(c_spec, depflag=dt.BUILD | dt.LINK, virtuals=()) - a_spec.concretize() + a_spec = spack.concretize.concretized(a_spec) assert spack.version.Version("2") == a_spec[c][d].version assert spack.version.Version("2") == a_spec[e].version assert spack.version.Version("3") == a_spec[b][d].version @@ -141,12 +141,12 @@ def test_specify_preinstalled_dep(tmpdir, monkeypatch): builder.add_package("pkg-a", dependencies=[("pkg-b", None, None)]) with spack.repo.use_repositories(builder.root): - b_spec = Spec("pkg-b").concretized() + b_spec = spack.concretize.concretized(Spec("pkg-b")) monkeypatch.setattr(Spec, "installed", property(lambda x: x.name != "pkg-a")) a_spec = Spec("pkg-a") a_spec._add_dependency(b_spec, depflag=dt.BUILD | dt.LINK, virtuals=()) - a_spec.concretize() + a_spec = spack.concretize.concretized(a_spec) assert {x.name for x in a_spec.traverse()} == {"pkg-a", "pkg-b", "pkg-c"} @@ -168,7 +168,7 @@ def test_conditional_dep_with_user_constraints(tmpdir, spec_str, expr_str, expec builder.add_package("x", dependencies=[("y", None, "x@2:")]) with spack.repo.use_repositories(builder.root): - spec = Spec(spec_str).concretized() + spec = spack.concretize.concretized(Spec(spec_str)) result = expr_str in spec assert result is expected, "{0} in {1}".format(expr_str, spec) @@ -182,10 +182,10 @@ def test_conflicting_package_constraints(self, set_dependency): spec = Spec("mpileaks ^mpich ^callpath ^dyninst ^libelf ^libdwarf") with pytest.raises(spack.error.UnsatisfiableSpecError): - spec.concretize() + spack.concretize.concretized(spec) def test_preorder_node_traversal(self): - dag = Spec("mpileaks ^zmpi").concretized() + dag = spack.concretize.concretized(Spec("mpileaks ^zmpi")) names = ["mpileaks", "callpath", "dyninst", "libdwarf", "libelf", "zmpi", "fake"] pairs = list(zip([0, 1, 2, 3, 4, 2, 3], names)) @@ -197,7 +197,7 @@ def test_preorder_node_traversal(self): assert [(x, y.name) for x, y in traversal] == pairs def test_preorder_edge_traversal(self): - dag = Spec("mpileaks ^zmpi").concretized() + dag = spack.concretize.concretized(Spec("mpileaks ^zmpi")) names = [ "mpileaks", @@ -219,7 +219,7 @@ def test_preorder_edge_traversal(self): assert [(x, y.name) for x, y in traversal] == pairs def test_preorder_path_traversal(self): - dag = Spec("mpileaks ^zmpi").concretized() + dag = spack.concretize.concretized(Spec("mpileaks ^zmpi")) names = [ "mpileaks", @@ -242,7 +242,7 @@ def test_preorder_path_traversal(self): assert [(x, y.name) for x, y in traversal] == pairs def test_postorder_node_traversal(self): - dag = Spec("mpileaks ^zmpi").concretized() + dag = spack.concretize.concretized(Spec("mpileaks ^zmpi")) names = ["libelf", "libdwarf", "dyninst", "fake", "zmpi", "callpath", "mpileaks"] pairs = list(zip([4, 3, 2, 3, 2, 1, 0], names)) @@ -254,7 +254,7 @@ def test_postorder_node_traversal(self): assert [(x, y.name) for x, y in traversal] == pairs def test_postorder_edge_traversal(self): - dag = Spec("mpileaks ^zmpi").concretized() + dag = spack.concretize.concretized(Spec("mpileaks ^zmpi")) names = [ "libelf", @@ -276,7 +276,7 @@ def test_postorder_edge_traversal(self): assert [(x, y.name) for x, y in traversal] == pairs def test_postorder_path_traversal(self): - dag = Spec("mpileaks ^zmpi").concretized() + dag = spack.concretize.concretized(Spec("mpileaks ^zmpi")) names = [ "libelf", @@ -311,8 +311,8 @@ def test_dependents_and_dependencies_are_correct(self): } ) check_links(spec) - spec.concretize() - check_links(spec) + concrete = spack.concretize.concretized(spec) + check_links(concrete) @pytest.mark.parametrize( "constraint_str,spec_str", @@ -329,7 +329,7 @@ def test_unsatisfiable_cases(self, set_dependency, constraint_str, spec_str): """ set_dependency("mpileaks", constraint_str) with pytest.raises(spack.error.UnsatisfiableSpecError): - Spec(spec_str).concretize() + spack.concretize.concretized(Spec(spec_str)) @pytest.mark.parametrize( "spec_str", ["libelf ^mpich", "libelf ^libdwarf", "mpich ^dyninst ^libelf"] @@ -337,7 +337,7 @@ def test_unsatisfiable_cases(self, set_dependency, constraint_str, spec_str): def test_invalid_dep(self, spec_str): spec = Spec(spec_str) with pytest.raises(spack.error.SpecError): - spec.concretize() + spack.concretize.concretized(spec) def test_equal(self): # Different spec structures to test for equality @@ -400,8 +400,7 @@ def test_copy_simple(self): assert not orig_ids.intersection(copy_ids) def test_copy_concretized(self): - orig = Spec("mpileaks") - orig.concretize() + orig = spack.concretize.concretized(Spec("mpileaks")) copy = orig.copy() check_links(copy) @@ -420,7 +419,7 @@ def test_copy_through_spec_build_interface(self): """Check that copying dependencies using id(node) as a fast identifier of the node works when the spec is wrapped in a SpecBuildInterface object. """ - s = Spec("mpileaks").concretized() + s = spack.concretize.concretized(Spec("mpileaks")) c0 = s.copy() assert c0 == s @@ -503,7 +502,7 @@ def test_copy_through_spec_build_interface(self): ], ) def test_deptype_traversal(self, spec_str, deptypes, expected): - dag = Spec(spec_str).concretized() + dag = spack.concretize.concretized(Spec(spec_str)) traversal = dag.traverse(deptype=deptypes) assert [x.name for x in traversal] == expected @@ -635,20 +634,18 @@ def check_diamond_normalized_dag(self, spec): def test_concretize_deptypes(self): """Ensure that dependency types are preserved after concretization.""" - s = Spec("dt-diamond") - s.concretize() + s = spack.concretize.concretized(Spec("dt-diamond")) self.check_diamond_deptypes(s) def test_copy_deptypes(self): """Ensure that dependency types are preserved by spec copy.""" - s1 = Spec("dt-diamond").concretized() + s1 = spack.concretize.concretized(Spec("dt-diamond")) self.check_diamond_deptypes(s1) s2 = s1.copy() self.check_diamond_deptypes(s2) def test_getitem_query(self): - s = Spec("mpileaks") - s.concretize() + s = spack.concretize.concretized(Spec("mpileaks")) # Check a query to a non-virtual package a = s["callpath"] @@ -678,8 +675,7 @@ def test_getitem_query(self): assert query.isvirtual def test_getitem_exceptional_paths(self): - s = Spec("mpileaks") - s.concretize() + s = spack.concretize.concretized(Spec("mpileaks")) # Needed to get a proxy object q = s["mpileaks"] @@ -750,7 +746,7 @@ def test_invalid_literal_spec(self): def test_spec_tree_respect_deptypes(self): # Version-test-root uses version-test-pkg as a build dependency - s = Spec("version-test-root").concretized() + s = spack.concretize.concretized(Spec("version-test-root")) out = s.tree(deptypes="all") assert "version-test-pkg" in out out = s.tree(deptypes=("link", "run")) @@ -834,9 +830,9 @@ def test_synthetic_construction_of_split_dependencies_from_same_package(mock_pac # # To demonstrate that a spec can now hold two direct # dependencies from the same package - root = Spec("pkg-b").concretized() - link_run_spec = Spec("pkg-c@=1.0").concretized() - build_spec = Spec("pkg-c@=2.0").concretized() + root = spack.concretize.concretized(Spec("pkg-b")) + link_run_spec = spack.concretize.concretized(Spec("pkg-c@=1.0")) + build_spec = spack.concretize.concretized(Spec("pkg-c@=2.0")) root.add_dependency_edge(link_run_spec, depflag=dt.LINK, virtuals=()) root.add_dependency_edge(link_run_spec, depflag=dt.RUN, virtuals=()) @@ -863,8 +859,8 @@ def test_synthetic_construction_bootstrapping(mock_packages, config): # | build # pkg-b@1.0 # - root = Spec("pkg-b@=2.0").concretized() - bootstrap = Spec("pkg-b@=1.0").concretized() + root = spack.concretize.concretized(Spec("pkg-b@=2.0")) + bootstrap = spack.concretize.concretized(Spec("pkg-b@=1.0")) root.add_dependency_edge(bootstrap, depflag=dt.BUILD, virtuals=()) @@ -881,8 +877,8 @@ def test_addition_of_different_deptypes_in_multiple_calls(mock_packages, config) # pkg-b@1.0 # # with three calls and check we always have a single edge - root = Spec("pkg-b@=2.0").concretized() - bootstrap = Spec("pkg-b@=1.0").concretized() + root = spack.concretize.concretized(Spec("pkg-b@=2.0")) + bootstrap = spack.concretize.concretized(Spec("pkg-b@=1.0")) for current_depflag in (dt.BUILD, dt.LINK, dt.RUN): root.add_dependency_edge(bootstrap, depflag=current_depflag, virtuals=()) @@ -909,9 +905,9 @@ def test_addition_of_different_deptypes_in_multiple_calls(mock_packages, config) def test_adding_same_deptype_with_the_same_name_raises( mock_packages, config, c1_depflag, c2_depflag ): - p = Spec("pkg-b@=2.0").concretized() - c1 = Spec("pkg-b@=1.0").concretized() - c2 = Spec("pkg-b@=2.0").concretized() + p = spack.concretize.concretized(Spec("pkg-b@=2.0")) + c1 = spack.concretize.concretized(Spec("pkg-b@=1.0")) + c2 = spack.concretize.concretized(Spec("pkg-b@=2.0")) p.add_dependency_edge(c1, depflag=c1_depflag, virtuals=()) with pytest.raises(spack.error.SpackError): diff --git a/lib/spack/spack/test/spec_list.py b/lib/spack/spack/test/spec_list.py index 295665ecfbd..72baf1189bd 100644 --- a/lib/spack/spack/test/spec_list.py +++ b/lib/spack/spack/test/spec_list.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize from spack.installer import PackageInstaller from spack.spec import Spec from spack.spec_list import SpecList @@ -199,8 +200,8 @@ def test_spec_list_matrix_exclude(self, mock_packages): 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. - mpich_1 = Spec("mpich+debug").concretized() - mpich_2 = Spec("mpich~debug").concretized() + mpich_1 = spack.concretize.concretized(Spec("mpich+debug")) + mpich_2 = spack.concretize.concretized(Spec("mpich~debug")) 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 diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index 6fcdcded151..af2ace50e48 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -7,6 +7,7 @@ import pytest +import spack.concretize import spack.deptypes as dt import spack.directives import spack.error @@ -590,8 +591,7 @@ def test_satisfies_single_valued_variant(self): https://github.com/spack/spack/pull/2386#issuecomment-282147639 is handled correctly. """ - a = Spec("pkg-a foobar=bar") - a.concretize() + a = spack.concretize.concretized(Spec("pkg-a foobar=bar")) assert a.satisfies("foobar=bar") assert a.satisfies("foobar=*") @@ -610,21 +610,18 @@ def test_satisfies_single_valued_variant(self): assert "^pkg-b" in a def test_unsatisfied_single_valued_variant(self): - a = Spec("pkg-a foobar=baz") - a.concretize() + a = spack.concretize.concretized(Spec("pkg-a foobar=baz")) assert "^pkg-b" not in a - mv = Spec("multivalue-variant") - mv.concretize() + mv = spack.concretize.concretized(Spec("multivalue-variant")) assert "pkg-a@1.0" not in mv def test_indirect_unsatisfied_single_valued_variant(self): - spec = Spec("singlevalue-variant-dependent") - spec.concretize() + spec = spack.concretize.concretized(Spec("singlevalue-variant-dependent")) assert "pkg-a@1.0" not in spec def test_satisfied_namespace(self): - spec = Spec("zlib").concretized() + spec = spack.concretize.concretized(Spec("zlib")) assert spec.satisfies("namespace=builtin.mock") assert not spec.satisfies("namespace=builtin") @@ -684,7 +681,7 @@ def test_unsatisfiable_multi_value_variant(self, default_mock_concretization): # ...but will fail during concretization if there are # values in the variant that are not allowed with pytest.raises(InvalidVariantValueError): - a.concretize() + spack.concretize.concretized(a) # This time we'll try to set a single-valued variant a = Spec('multivalue-variant fee="bar"') @@ -701,11 +698,10 @@ def test_unsatisfiable_multi_value_variant(self, default_mock_concretization): # ...but will fail during concretization if there are # multiple values set with pytest.raises(MultipleValuesInExclusiveVariantError): - a.concretize() + spack.concretize.concretized(a) def test_copy_satisfies_transitive(self): - spec = Spec("dttop") - spec.concretize() + spec = spack.concretize.concretized(Spec("dttop")) copy = spec.copy() for s in spec.traverse(): assert s.satisfies(copy[s.name]) @@ -728,7 +724,7 @@ def test_intersects_virtual_providers(self): def test_intersectable_concrete_specs_must_have_the_same_hash(self): """Ensure that concrete specs are matched *exactly* by hash.""" - s1 = Spec("mpileaks").concretized() + s1 = spack.concretize.concretized(Spec("mpileaks")) s2 = s1.copy() assert s1.satisfies(s2) @@ -768,17 +764,10 @@ def test_dep_index(self, default_mock_concretization): @pytest.mark.usefixtures("config") def test_virtual_index(self): - s = Spec("callpath") - s.concretize() - - s_mpich = Spec("callpath ^mpich") - s_mpich.concretize() - - s_mpich2 = Spec("callpath ^mpich2") - s_mpich2.concretize() - - s_zmpi = Spec("callpath ^zmpi") - s_zmpi.concretize() + s = spack.concretize.concretized(Spec("callpath")) + s_mpich = spack.concretize.concretized(Spec("callpath ^mpich")) + s_mpich2 = spack.concretize.concretized(Spec("callpath ^mpich2")) + s_zmpi = spack.concretize.concretized(Spec("callpath ^zmpi")) assert s["mpi"].name != "mpi" assert s_mpich["mpi"].name == "mpich" @@ -1048,7 +1037,7 @@ def test_abstract_spec_prefix_error(self): spec.prefix def test_forwarding_of_architecture_attributes(self): - spec = Spec("libelf target=x86_64").concretized() + spec = spack.concretize.concretized(Spec("libelf target=x86_64")) # Check that we can still access each member through # the architecture attribute @@ -1373,7 +1362,7 @@ def test_target_constraints(self, spec, constraint, expected_result): def test_error_message_unknown_variant(self): s = Spec("mpileaks +unknown") with pytest.raises(UnknownVariantError): - s.concretize() + spack.concretize.concretized(s) @pytest.mark.regression("18527") def test_satisfies_dependencies_ordered(self): @@ -1400,8 +1389,7 @@ def test_splice_swap_names_mismatch_virtuals(self, default_mock_concretization, def test_spec_override(self): init_spec = Spec("pkg-a foo=baz foobar=baz cflags=-O3 cxxflags=-O1") change_spec = Spec("pkg-a foo=fee cflags=-O2") - new_spec = Spec.override(init_spec, change_spec) - new_spec.concretize() + new_spec = spack.concretize.concretized(Spec.override(init_spec, change_spec)) assert "foo=fee" in new_spec # This check fails without concretizing: apparently if both specs are # abstract, then the spec will always be considered to satisfy @@ -1420,8 +1408,7 @@ def test_spec_override_with_nonexisting_variant(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") change_spec = Spec("pkg-a +bvv ~lorem_ipsum") - new_spec = Spec.override(init_spec, change_spec) - new_spec.concretize() + new_spec = spack.concretize.concretized(Spec.override(init_spec, change_spec)) assert "+bvv" in new_spec assert "~lorem_ipsum" in new_spec @@ -1514,7 +1501,7 @@ def test_virtual_deps_bindings(self, default_mock_concretization, spec_str, spec ) def test_unsatisfiable_virtual_deps_bindings(self, spec_str): with pytest.raises(spack.solver.asp.UnsatisfiableSpecError): - Spec(spec_str).concretized() + spack.concretize.concretized(Spec(spec_str)) @pytest.mark.parametrize( @@ -1612,7 +1599,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): # x is constructed directly from string, y from a # round-trip to dict representation - x = Spec(spec_str).concretized() + x = spack.concretize.concretized(Spec(spec_str)) y = Spec.from_dict(x.to_dict()) # Using 'y' since the round-trip make us lose build dependencies @@ -1713,7 +1700,7 @@ def test_call_dag_hash_on_old_dag_hash_spec(mock_packages, default_mock_concreti def test_spec_trim(mock_packages, config): - top = Spec("dt-diamond").concretized() + top = spack.concretize.concretized(Spec("dt-diamond")) top.trim("dt-diamond-left") remaining = set(x.name for x in top.traverse()) assert set(["dt-diamond", "dt-diamond-right", "dt-diamond-bottom"]) == remaining @@ -1726,7 +1713,7 @@ def test_spec_trim(mock_packages, config): @pytest.mark.regression("30861") def test_concretize_partial_old_dag_hash_spec(mock_packages, config): # create an "old" spec with no package hash - bottom = Spec("dt-diamond-bottom").concretized() + bottom = spack.concretize.concretized(Spec("dt-diamond-bottom")) delattr(bottom, "_package_hash") dummy_hash = "zd4m26eis2wwbvtyfiliar27wkcv3ehk" @@ -1737,7 +1724,7 @@ def test_concretize_partial_old_dag_hash_spec(mock_packages, config): top.add_dependency_edge(bottom, depflag=0, virtuals=()) # concretize with the already-concrete dependency - top.concretize() + top = spack.concretize.concretized(top) for spec in top.traverse(): assert spec.concrete @@ -1955,7 +1942,7 @@ def test_edge_equality_does_not_depend_on_virtual_order(): def test_old_format_strings_trigger_error(default_mock_concretization): - s = Spec("pkg-a").concretized() + s = spack.concretize.concretized(Spec("pkg-a")) with pytest.raises(SpecFormatStringError): s.format("${PACKAGE}-${VERSION}-${HASH}") diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py index 22942862ebb..7c5a0928329 100644 --- a/lib/spack/spack/test/spec_syntax.py +++ b/lib/spack/spack/test/spec_syntax.py @@ -11,6 +11,7 @@ import spack.binary_distribution import spack.cmd +import spack.concretize import spack.parser import spack.platforms.test import spack.repo @@ -774,7 +775,7 @@ def test_spec_by_hash_tokens(text, tokens): @pytest.mark.db def test_spec_by_hash(database, monkeypatch, config): mpileaks = database.query_one("mpileaks ^zmpi") - b = spack.spec.Spec("pkg-b").concretized() + b = spack.concretize.concretized(spack.spec.Spec("pkg-b")) monkeypatch.setattr(spack.binary_distribution, "update_cache_and_get_specs", lambda: [b]) hash_str = f"/{mpileaks.dag_hash()}" @@ -871,7 +872,7 @@ def test_ambiguous_hash(mutable_database): In the past this ambiguity error would happen during parse time.""" # This is a very sketchy as manually setting hashes easily breaks invariants - x1 = spack.spec.Spec("pkg-a").concretized() + x1 = spack.concretize.concretized(spack.spec.Spec("pkg-a")) x2 = x1.copy() x1._hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" x1._process_hash = "xyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" @@ -945,8 +946,8 @@ def test_nonexistent_hash(database, config): ], ) def test_disambiguate_hash_by_spec(spec1, spec2, constraint, mock_packages, monkeypatch, config): - spec1_concrete = spack.spec.Spec(spec1).concretized() - spec2_concrete = spack.spec.Spec(spec2).concretized() + spec1_concrete = spack.concretize.concretized(spack.spec.Spec(spec1)) + spec2_concrete = spack.concretize.concretized(spack.spec.Spec(spec2)) spec1_concrete._hash = "spec1" spec2_concrete._hash = "spec2" @@ -1137,7 +1138,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 # message that mentions we might've meant a file. with pytest.raises(spack.repo.UnknownEntityError) as exc_info: - spec.concretize() + spack.concretize.concretized(spec) assert exc_info.value.long_message assert ( "Did you mean to specify a filename with './libelf.yaml'?" in exc_info.value.long_message @@ -1145,7 +1146,7 @@ def test_parse_filename_missing_slash_as_spec(specfile_for, tmpdir, filename): # make sure that only happens when the spec ends in yaml with pytest.raises(spack.repo.UnknownPackageError) as exc_info: - SpecParser("builtin.mock.doesnotexist").next_spec().concretize() + spack.concretize.concretized(SpecParser("builtin.mock.doesnotexist").next_spec()) assert not exc_info.value.long_message or ( "Did you mean to specify a filename with" not in exc_info.value.long_message ) diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py index 79f128e9483..7e029119a57 100644 --- a/lib/spack/spack/test/spec_yaml.py +++ b/lib/spack/spack/test/spec_yaml.py @@ -21,6 +21,7 @@ import pytest import ruamel.yaml +import spack.concretize import spack.hash_types as ht import spack.paths import spack.repo @@ -108,8 +109,7 @@ def test_roundtrip_concrete_specs(abstract_spec, default_mock_concretization): def test_yaml_subdag(config, mock_packages): - spec = Spec("mpileaks^mpich+debug") - spec.concretize() + spec = spack.concretize.concretized(Spec("mpileaks^mpich+debug")) yaml_spec = Spec.from_yaml(spec.to_yaml()) json_spec = Spec.from_json(spec.to_json()) @@ -154,8 +154,7 @@ def test_ordered_read_not_required_for_consistent_dag_hash(config, mock_packages """ specs = ["mpileaks ^zmpi", "dttop", "dtuse"] for spec in specs: - spec = Spec(spec) - spec.concretize() + spec = spack.concretize.concretized(Spec(spec)) # # Dict & corresponding YAML & JSON from the original spec. @@ -215,11 +214,11 @@ def test_ordered_read_not_required_for_consistent_dag_hash(config, mock_packages assert spec.dag_hash() == round_trip_reversed_json_spec.dag_hash() # dag_hash is equal after round-trip by dag_hash - spec.concretize() - round_trip_yaml_spec.concretize() - round_trip_json_spec.concretize() - round_trip_reversed_yaml_spec.concretize() - round_trip_reversed_json_spec.concretize() + spec = spack.concretize.concretized(spec) + round_trip_yaml_spec = spack.concretize.concretized(round_trip_yaml_spec) + round_trip_json_spec = spack.concretize.concretized(round_trip_json_spec) + round_trip_reversed_yaml_spec = spack.concretize.concretized(round_trip_reversed_yaml_spec) + round_trip_reversed_json_spec = spack.concretize.concretized(round_trip_reversed_json_spec) 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_reversed_yaml_spec.dag_hash() @@ -323,7 +322,7 @@ def test_save_dependency_spec_jsons_subset(tmpdir, config): builder.add_package("pkg-a", dependencies=[("pkg-b", None, None), ("pkg-c", None, None)]) with spack.repo.use_repositories(builder.root): - spec_a = Spec("pkg-a").concretized() + spec_a = spack.concretize.concretized(Spec("pkg-a")) b_spec = spec_a["pkg-b"] c_spec = spec_a["pkg-c"] @@ -390,7 +389,7 @@ def test_legacy_yaml(tmpdir, install_mockery, mock_packages): build_hash: iaapywazxgetn6gfv2cfba353qzzqvhy """ spec = Spec.from_yaml(yaml) - concrete_spec = spec.concretized() + concrete_spec = spack.concretize.concretized(spec) assert concrete_spec.eq_dag(spec) diff --git a/lib/spack/spack/test/svn_fetch.py b/lib/spack/spack/test/svn_fetch.py index de47864fc24..b5e6cc3e057 100644 --- a/lib/spack/spack/test/svn_fetch.py +++ b/lib/spack/spack/test/svn_fetch.py @@ -9,6 +9,7 @@ from llnl.util.filesystem import mkdirp, touch, working_dir +import spack.concretize import spack.config from spack.fetch_strategy import SvnFetchStrategy from spack.spec import Spec @@ -41,7 +42,7 @@ def test_fetch(type_of_test, secure, mock_svn_repository, config, mutable_mock_r h = mock_svn_repository.hash # Construct the package under test - s = Spec("svn-test").concretized() + s = spack.concretize.concretized(Spec("svn-test")) monkeypatch.setitem(s.package.versions, Version("svn"), t.args) # Enter the stage directory and check some properties diff --git a/lib/spack/spack/test/test_suite.py b/lib/spack/spack/test/test_suite.py index 3ed4e30d42c..ae65695b551 100644 --- a/lib/spack/spack/test/test_suite.py +++ b/lib/spack/spack/test/test_suite.py @@ -10,6 +10,7 @@ from llnl.util.filesystem import join_path, mkdirp, touch +import spack.concretize import spack.config import spack.install_test import spack.spec @@ -40,7 +41,7 @@ def ensure_results(filename, expected, present=True): def test_test_log_name(mock_packages, config): """Ensure test log path is reasonable.""" - spec = spack.spec.Spec("libdwarf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libdwarf")) test_name = "test_name" @@ -53,7 +54,7 @@ def test_test_log_name(mock_packages, config): def test_test_ensure_stage(mock_test_stage, mock_packages): """Make sure test stage directory is properly set up.""" - spec = spack.spec.Spec("libdwarf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libdwarf")) test_name = "test_name" @@ -66,7 +67,7 @@ def test_test_ensure_stage(mock_test_stage, mock_packages): def test_write_test_result(mock_packages, mock_test_stage): """Ensure test results written to a results file.""" - spec = spack.spec.Spec("libdwarf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libdwarf")) result = "TEST" test_name = "write-test" @@ -86,7 +87,7 @@ def test_write_test_result(mock_packages, 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.""" - spec = spack.spec.Spec("trivial-smoke-test").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) test_suite = spack.install_test.TestSuite([spec]) test_suite() @@ -103,7 +104,7 @@ def test_test_external( mock_packages, install_mockery, mock_test_stage, monkeypatch, arguments, status, msg ): name = "trivial-smoke-test" - spec = spack.spec.Spec(name).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(name)) spec.external_path = "/path/to/external/{0}".format(name) monkeypatch.setattr(spack.spec.Spec, "installed", _true) @@ -124,7 +125,7 @@ def ensure_current_cache_fail(test_suite): with pytest.raises(spack.install_test.TestSuiteSpecError): _ = test_suite.current_test_data_dir - spec = spack.spec.Spec("libelf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libelf")) test_suite = spack.install_test.TestSuite([spec], "test-cache") # Check no current specs yield failure @@ -142,7 +143,7 @@ def ensure_current_cache_fail(test_suite): def test_test_spec_run_once(mock_packages, install_mockery, mock_test_stage): - spec = spack.spec.Spec("libelf").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("libelf")) test_suite = spack.install_test.TestSuite([spec], "test-dups") (test_suite.specs[0]).package.test_suite = test_suite @@ -152,7 +153,7 @@ def test_test_spec_run_once(mock_packages, install_mockery, mock_test_stage): @pytest.mark.not_on_windows("Cannot find echo executable") def test_test_spec_passes(mock_packages, install_mockery, mock_test_stage, monkeypatch): - spec = spack.spec.Spec("simple-standalone-test").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("simple-standalone-test")) monkeypatch.setattr(spack.spec.Spec, "installed", _true) test_suite = spack.install_test.TestSuite([spec]) test_suite() @@ -178,7 +179,7 @@ def test_get_test_suite_too_many(mock_packages, mock_test_stage): name = "duplicate-alias" def add_suite(package): - spec = spack.spec.Spec(package).concretized() + spec = spack.concretize.concretized(spack.spec.Spec(package)) suite = spack.install_test.TestSuite([spec], name) suite.ensure_stage() spack.install_test.write_test_suite_file(suite) @@ -200,7 +201,7 @@ def add_suite(package): ) def test_test_function_names(mock_packages, install_mockery, virtuals, expected): """Confirm test_function_names works as expected with/without virtuals.""" - spec = spack.spec.Spec("mpich").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("mpich")) tests = spack.install_test.test_function_names(spec.package, add_virtuals=virtuals) assert sorted(tests) == sorted(expected) @@ -213,7 +214,7 @@ def test_test_functions_fails(): def test_test_functions_pkgless(mock_packages, install_mockery, ensure_debug, capsys): """Confirm works for package providing a package-less virtual.""" - spec = spack.spec.Spec("simple-standalone-test").concretized() + spec = spack.concretize.concretized(spack.spec.Spec("simple-standalone-test")) fns = spack.install_test.test_functions(spec.package, add_virtuals=True) out = capsys.readouterr() assert len(fns) == 2, "Expected two test functions" @@ -296,7 +297,7 @@ def test_process_test_parts(mock_packages): def test_test_part_fail(tmpdir, install_mockery, mock_fetch, mock_test_stage): """Confirm test_part with a ProcessError results in FAILED status.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package pkg.tester.test_log_file = str(tmpdir.join("test-log.txt")) touch(pkg.tester.test_log_file) @@ -312,7 +313,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): """Confirm test_part that succeeds results in PASSED status.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package name = "test_echo" @@ -331,7 +332,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): """Confirm test_part that raises SkipTest results in test status SKIPPED.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package name = "test_skip" @@ -345,7 +346,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): """Confirm test_part with fail fast enabled raises exception.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package pkg.tester.test_log_file = str(tmpdir.join("test-log.txt")) touch(pkg.tester.test_log_file) @@ -366,7 +367,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): """Confirm test_part with missing executable fails.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package pkg.tester.test_log_file = str(tmpdir.join("test-log.txt")) touch(pkg.tester.test_log_file) @@ -402,7 +403,7 @@ def test_embedded_test_part_status( ): """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.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package base_name = "test_example" part_name = f"{pkg.__class__.__name__}::{base_name}" @@ -429,7 +430,7 @@ def test_write_tested_status( 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.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package for i, status in enumerate(statuses): pkg.tester.test_parts[f"test_{i}"] = status @@ -445,7 +446,7 @@ def test_write_tested_status( @pytest.mark.regression("37840") 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.""" - s = spack.spec.Spec("trivial-smoke-test").concretized() + s = spack.concretize.concretized(spack.spec.Spec("trivial-smoke-test")) pkg = s.package statuses = [TestStatus.PASSED, TestStatus.PASSED] for i, status in enumerate(statuses): diff --git a/lib/spack/spack/test/url_fetch.py b/lib/spack/spack/test/url_fetch.py index f103244a106..3fda1a24a39 100644 --- a/lib/spack/spack/test/url_fetch.py +++ b/lib/spack/spack/test/url_fetch.py @@ -14,6 +14,7 @@ import llnl.util.tty as tty from llnl.util.filesystem import is_exe, working_dir +import spack.concretize import spack.config import spack.error import spack.fetch_strategy as fs @@ -193,7 +194,7 @@ def test_from_list_url(mock_packages, config, spec, url, digest, _fetch_method): have checksums in the package. """ with spack.config.override("config:url_fetch_method", _fetch_method): - s = Spec(spec).concretized() + s = spack.concretize.concretized(Spec(spec)) fetch_strategy = fs.from_list_url(s.package) assert isinstance(fetch_strategy, fs.URLFetchStrategy) assert os.path.basename(fetch_strategy.url) == url @@ -219,7 +220,7 @@ def test_new_version_from_list_url( ): """Test non-specific URLs from the url-list-test package.""" with spack.config.override("config:url_fetch_method", _fetch_method): - s = Spec(f"url-list-test @{requested_version}").concretized() + s = spack.concretize.concretized(Spec(f"url-list-test @{requested_version}")) fetch_strategy = fs.from_list_url(s.package) assert isinstance(fetch_strategy, fs.URLFetchStrategy) @@ -233,7 +234,7 @@ def test_new_version_from_list_url( def test_nosource_from_list_url(mock_packages, config): """This test confirms BundlePackages do not have list url.""" - s = Spec("nosource").concretized() + s = spack.concretize.concretized(Spec("nosource")) fetch_strategy = fs.from_list_url(s.package) assert fetch_strategy is None diff --git a/lib/spack/spack/test/util/package_hash.py b/lib/spack/spack/test/util/package_hash.py index cfadae40be3..606b1d3310a 100644 --- a/lib/spack/spack/test/util/package_hash.py +++ b/lib/spack/spack/test/util/package_hash.py @@ -8,6 +8,7 @@ import pytest +import spack.concretize import spack.directives import spack.directives_meta import spack.paths @@ -92,8 +93,8 @@ def test_all_same_but_install(mock_packages, config): def test_content_hash_all_same_but_patch_contents(mock_packages, config): - spec1 = Spec("hash-test1@1.1").concretized() - spec2 = Spec("hash-test2@1.1").concretized() + spec1 = spack.concretize.concretized(Spec("hash-test1@1.1")) + spec2 = spack.concretize.concretized(Spec("hash-test2@1.1")) compare_hash_sans_name(False, spec1, spec2) @@ -118,8 +119,8 @@ def test_content_hash_not_concretized(mock_packages, config): def test_content_hash_different_variants(mock_packages, config): - spec1 = Spec("hash-test1@1.2 +variantx").concretized() - spec2 = Spec("hash-test2@1.2 ~variantx").concretized() + spec1 = spack.concretize.concretized(Spec("hash-test1@1.2 +variantx")) + spec2 = spack.concretize.concretized(Spec("hash-test2@1.2 ~variantx")) compare_hash_sans_name(True, spec1, spec2) @@ -133,19 +134,19 @@ def test_content_hash_cannot_get_details_from_ast(mock_packages, config): differ where Spack includes a phase on account of AST-examination failure. """ - spec3 = Spec("hash-test1@1.7").concretized() - spec4 = Spec("hash-test3@1.7").concretized() + spec3 = spack.concretize.concretized(Spec("hash-test1@1.7")) + spec4 = spack.concretize.concretized(Spec("hash-test3@1.7")) compare_hash_sans_name(False, spec3, spec4) def test_content_hash_all_same_but_archive_hash(mock_packages, config): - spec1 = Spec("hash-test1@1.3").concretized() - spec2 = Spec("hash-test2@1.3").concretized() + spec1 = spack.concretize.concretized(Spec("hash-test1@1.3")) + spec2 = spack.concretize.concretized(Spec("hash-test2@1.3")) compare_hash_sans_name(False, spec1, spec2) def test_content_hash_parse_dynamic_function_call(mock_packages, config): - spec = Spec("hash-test4").concretized() + spec = spack.concretize.concretized(Spec("hash-test4")) spec.package.content_hash() diff --git a/lib/spack/spack/test/variant.py b/lib/spack/spack/test/variant.py index 518110d5253..3acc27a5051 100644 --- a/lib/spack/spack/test/variant.py +++ b/lib/spack/spack/test/variant.py @@ -6,6 +6,7 @@ import pytest +import spack.concretize import spack.error import spack.repo import spack.spec @@ -691,7 +692,7 @@ def test_concrete(self, mock_packages, config) -> None: assert not vm.concrete # concrete if associated spec is concrete - spec.concretize() + spec = spack.concretize.concretized(spec) assert vm.concrete # concrete if all variants are present (even if spec not concrete) @@ -911,7 +912,7 @@ def test_concretize_variant_default_with_multiple_defs( pkg = spack.repo.PATH.get_pkg_class(pkg_name) pkg_defs = [vdef for _, vdef in pkg.variant_definitions("v")] - spec = spack.spec.Spec(f"{pkg_name}{spec}").concretized() + spec = spack.concretize.concretized(spack.spec.Spec(f"{pkg_name}{spec}")) assert spec.satisfies(satisfies) assert spec.package.get_variant("v") is pkg_defs[def_id] diff --git a/lib/spack/spack/test/versions.py b/lib/spack/spack/test/versions.py index 4c5081e8d17..3ae555e5ddc 100644 --- a/lib/spack/spack/test/versions.py +++ b/lib/spack/spack/test/versions.py @@ -14,6 +14,7 @@ from llnl.util.filesystem import working_dir +import spack.concretize import spack.package_base import spack.spec import spack.version @@ -708,7 +709,7 @@ def test_git_hash_comparisons( 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.concretized(spack.spec.Spec(f"git-test-commit@{commits[commit_idx]}")) for item in expected_satisfies: assert spec.satisfies(item) @@ -724,15 +725,13 @@ def test_git_ref_comparisons(mock_git_version_info, install_mockery, mock_packag ) # Spec based on tag v1.0 - spec_tag = spack.spec.Spec("git-test-commit@git.v1.0") - spec_tag.concretize() + spec_tag = spack.concretize.concretized(spack.spec.Spec("git-test-commit@git.v1.0")) assert spec_tag.satisfies("@1.0") assert not spec_tag.satisfies("@1.1:") assert str(spec_tag.version) == "git.v1.0=1.0" # Spec based on branch 1.x - spec_branch = spack.spec.Spec("git-test-commit@git.1.x") - spec_branch.concretize() + spec_branch = spack.concretize.concretized(spack.spec.Spec("git-test-commit@git.1.x")) assert spec_branch.satisfies("@1.2") assert spec_branch.satisfies("@1.1:1.3") assert str(spec_branch.version) == "git.1.x=1.2" @@ -1031,7 +1030,7 @@ def test_git_version_repo_attached_after_serialization( monkeypatch.setattr( 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.concretized(spack.spec.Spec(f"git-test-commit@{commits[-2]}")) # Before serialization, the repo is attached assert spec.satisfies("@1.0") @@ -1051,7 +1050,7 @@ def test_resolved_git_version_is_shown_in_str( spack.package_base.PackageBase, "git", "file://%s" % repo_path, raising=False ) commit = commits[-3] - spec = spack.spec.Spec(f"git-test-commit@{commit}").concretized() + spec = spack.concretize.concretized(spack.spec.Spec(f"git-test-commit@{commit}")) assert spec.version.satisfies(ver("1.0")) assert str(spec.version) == f"{commit}=1.0-git.1" diff --git a/lib/spack/spack/test/views.py b/lib/spack/spack/test/views.py index 2a62d04312b..9b25b5f21bd 100644 --- a/lib/spack/spack/test/views.py +++ b/lib/spack/spack/test/views.py @@ -7,6 +7,7 @@ import pytest +import spack.concretize from spack.directory_layout import DirectoryLayout from spack.filesystem_view import SimpleFilesystemView, YamlFilesystemView from spack.installer import PackageInstaller @@ -17,7 +18,7 @@ def test_remove_extensions_ordered(install_mockery, mock_fetch, tmpdir): view_dir = str(tmpdir.join("view")) layout = DirectoryLayout(view_dir) view = YamlFilesystemView(view_dir, layout) - e2 = Spec("extension2").concretized() + e2 = spack.concretize.concretized(Spec("extension2")) PackageInstaller([e2.package], explicit=True).install() view.add_specs(e2)