diff --git a/lib/spack/spack/bootstrap/core.py b/lib/spack/spack/bootstrap/core.py index 65e4db6c9fc..5f40159a8c9 100644 --- a/lib/spack/spack/bootstrap/core.py +++ b/lib/spack/spack/bootstrap/core.py @@ -292,7 +292,12 @@ def try_import(self, module: str, abstract_spec_str: str) -> bool: # Install the spec that should make the module importable with spack.config.override(self.mirror_scope): - PackageInstaller([concrete_spec.package], fail_fast=True).install() + PackageInstaller( + [concrete_spec.package], + fail_fast=True, + package_use_cache=False, + dependencies_use_cache=False, + ).install() if _try_import_from_store(module, query_spec=concrete_spec, query_info=info): self.last_search = info @@ -362,6 +367,7 @@ def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str] for current_config in bootstrapping_sources(): if not source_is_enabled(current_config): continue + with exception_handler.forward(current_config["name"], Exception): if create_bootstrapper(current_config).try_import(module, abstract_spec): return diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index 9649cea1baa..eb9bfb1d511 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -12,6 +12,7 @@ import spack.phase_callbacks import spack.spec import spack.util.prefix +from spack.directives import depends_on from .cmake import CMakeBuilder, CMakePackage @@ -371,6 +372,10 @@ class CachedCMakePackage(CMakePackage): CMakeBuilder = CachedCMakeBuilder + # These dependencies are assumed in the builder + depends_on("c", type="build") + depends_on("cxx", type="build") + def flag_handler(self, name, flags): if name in ("cflags", "cxxflags", "cppflags", "fflags"): return None, None, None # handled in the cmake cache diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py index c6c32fa5a6b..bc567adf5b7 100644 --- a/lib/spack/spack/build_systems/oneapi.py +++ b/lib/spack/spack/build_systems/oneapi.py @@ -142,7 +142,7 @@ def setup_run_environment(self, env): $ source {prefix}/{component}/{version}/env/vars.sh """ # Only if environment modifications are desired (default is +envmods) - if "~envmods" not in self.spec: + if "+envmods" in self.spec: env.extend( EnvironmentModifications.from_sourcing_file( self.component_prefix.env.join("vars.sh"), *self.env_script_args diff --git a/lib/spack/spack/cmd/unit_test.py b/lib/spack/spack/cmd/unit_test.py index 5635ff560a6..eadd45ba824 100644 --- a/lib/spack/spack/cmd/unit_test.py +++ b/lib/spack/spack/cmd/unit_test.py @@ -216,7 +216,7 @@ def unit_test(parser, args, unknown_args): # Ensure clingo is available before switching to the # mock configuration used by unit tests with spack.bootstrap.ensure_bootstrap_configuration(): - spack.bootstrap.ensure_core_dependencies() + spack.bootstrap.ensure_clingo_importable_or_raise() if pytest is None: spack.bootstrap.ensure_environment_dependencies() import pytest diff --git a/lib/spack/spack/detection/path.py b/lib/spack/spack/detection/path.py index d0c642225b4..f96a0276a35 100644 --- a/lib/spack/spack/detection/path.py +++ b/lib/spack/spack/detection/path.py @@ -243,7 +243,7 @@ def prefix_from_path(self, *, path: str) -> str: raise NotImplementedError("must be implemented by derived classes") def detect_specs( - self, *, pkg: Type["spack.package_base.PackageBase"], paths: List[str] + self, *, pkg: Type["spack.package_base.PackageBase"], paths: Iterable[str] ) -> List["spack.spec.Spec"]: """Given a list of files matching the search patterns, returns a list of detected specs. diff --git a/lib/spack/spack/hooks/resolve_shared_libraries.py b/lib/spack/spack/hooks/resolve_shared_libraries.py index c10fe3ca788..4eef63d338d 100644 --- a/lib/spack/spack/hooks/resolve_shared_libraries.py +++ b/lib/spack/spack/hooks/resolve_shared_libraries.py @@ -66,6 +66,8 @@ "libudev.so.*", # cuda driver "libcuda.so.*", + # intel-oneapi-runtime + "libur_loader.so.*", ] diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index 045236f66ff..802e96f00bc 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -177,7 +177,7 @@ def build_report_for_package(self, report_dir, package, duration): # something went wrong pre-cdash "configure" phase b/c we have an exception and only # "update" was encounterd. # dump the report in the configure line so teams can see what the issue is - if len(phases_encountered) == 1 and package["exception"]: + if len(phases_encountered) == 1 and package.get("exception"): # TODO this mapping is not ideal since these are pre-configure errors # we need to determine if a more appropriate cdash phase can be utilized # for now we will add a message to the log explaining this diff --git a/lib/spack/spack/test/cmd/build_env.py b/lib/spack/spack/test/cmd/build_env.py index 576292de49d..88c51a460b1 100644 --- a/lib/spack/spack/test/cmd/build_env.py +++ b/lib/spack/spack/test/cmd/build_env.py @@ -12,7 +12,7 @@ build_env = SpackCommand("build-env") -@pytest.mark.parametrize("pkg", [("zlib",), ("zlib", "--")]) +@pytest.mark.parametrize("pkg", [("pkg-c",), ("pkg-c", "--")]) @pytest.mark.usefixtures("config", "mock_packages", "working_env") def test_it_just_runs(pkg): build_env(*pkg) @@ -38,7 +38,7 @@ def test_build_env_requires_a_spec(args): @pytest.mark.usefixtures("config", "mock_packages", "working_env") def test_dump(shell_as, shell, tmpdir): with tmpdir.as_cwd(): - build_env("--dump", _out_file, "zlib") + build_env("--dump", _out_file, "pkg-c") with open(_out_file, encoding="utf-8") as f: if shell == "pwsh": assert any(line.startswith("$Env:PATH") for line in f.readlines()) @@ -51,7 +51,7 @@ def test_dump(shell_as, shell, tmpdir): @pytest.mark.usefixtures("config", "mock_packages", "working_env") def test_pickle(tmpdir): with tmpdir.as_cwd(): - build_env("--pickle", _out_file, "zlib") + build_env("--pickle", _out_file, "pkg-c") environment = pickle.load(open(_out_file, "rb")) assert isinstance(environment, dict) assert "PATH" in environment diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py index 52d2616cd68..83e99459219 100644 --- a/lib/spack/spack/test/cmd/buildcache.py +++ b/lib/spack/spack/test/cmd/buildcache.py @@ -148,7 +148,7 @@ def test_update_key_index( s = spack.concretize.concretize_one("libdwarf") # Install a package - install(s.name) + install("--fake", s.name) # Put installed package in the buildcache, which, because we're signing # it, should result in the public key getting pushed to the buildcache @@ -178,7 +178,7 @@ def test_buildcache_autopush(tmp_path, install_mockery, mock_fetch): s = spack.concretize.concretize_one("libdwarf") # Install and generate build cache index - PackageInstaller([s.package], explicit=True).install() + PackageInstaller([s.package], fake=True, explicit=True).install() metadata_file = spack.binary_distribution.tarball_name(s, ".spec.json") @@ -220,7 +220,7 @@ def verify_mirror_contents(): # Install a package and put it in the buildcache s = spack.concretize.concretize_one(out_env_pkg) - install(s.name) + install("--fake", s.name) buildcache("push", "-u", "-f", src_mirror_url, s.name) env("create", "test") diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index 452cd804b92..c6851634f37 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -1062,7 +1062,7 @@ def test_ci_rebuild_index( with open(tmp_path / "spec.json", "w", encoding="utf-8") as f: f.write(concrete_spec.to_json(hash=ht.dag_hash)) - install_cmd("--add", "-f", str(tmp_path / "spec.json")) + install_cmd("--fake", "--add", "-f", str(tmp_path / "spec.json")) buildcache_cmd("push", "-u", "-f", mirror_url, "callpath") ci_cmd("rebuild-index") diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py index c30e8b3d7b4..52e4065ecf4 100644 --- a/lib/spack/spack/test/cmd/config.py +++ b/lib/spack/spack/test/cmd/config.py @@ -335,7 +335,7 @@ def test_config_add_override_leaf_from_file(mutable_empty_config, tmpdir): def test_config_add_update_dict_from_file(mutable_empty_config, tmpdir): - config("add", "packages:all:compiler:[gcc]") + config("add", "packages:all:require:['%gcc']") # contents to add to file contents = """spack: @@ -357,7 +357,7 @@ def test_config_add_update_dict_from_file(mutable_empty_config, tmpdir): expected = """packages: all: target: [x86_64] - compiler: [gcc] + require: ['%gcc'] """ assert expected == output @@ -606,7 +606,6 @@ def test_config_prefer_upstream( packages = syaml.load(open(cfg_file, encoding="utf-8"))["packages"] # Make sure only the non-default variants are set. - assert packages["all"] == {"compiler": ["gcc@=10.2.1"]} assert packages["boost"] == {"variants": "+debug +graph", "version": ["1.63.0"]} assert packages["dependency-install"] == {"version": ["2.0"]} # Ensure that neither variant gets listed for hdf5, since they conflict diff --git a/lib/spack/spack/test/cmd/deprecate.py b/lib/spack/spack/test/cmd/deprecate.py index 68994a5c33b..76fc6aa50c7 100644 --- a/lib/spack/spack/test/cmd/deprecate.py +++ b/lib/spack/spack/test/cmd/deprecate.py @@ -17,16 +17,16 @@ def test_deprecate(mock_packages, mock_archive, mock_fetch, install_mockery): - install("libelf@0.8.13") - install("libelf@0.8.10") + install("--fake", "libelf@0.8.13") + install("--fake", "libelf@0.8.10") - all_installed = spack.store.STORE.db.query() + all_installed = spack.store.STORE.db.query("libelf") assert len(all_installed) == 2 deprecate("-y", "libelf@0.8.10", "libelf@0.8.13") - non_deprecated = spack.store.STORE.db.query() - all_available = spack.store.STORE.db.query(installed=InstallRecordStatus.ANY) + non_deprecated = spack.store.STORE.db.query("libelf") + all_available = spack.store.STORE.db.query("libelf", installed=InstallRecordStatus.ANY) assert all_available == all_installed assert non_deprecated == spack.store.STORE.db.query("libelf@0.8.13") @@ -39,24 +39,24 @@ def test_deprecate_fails_no_such_package(mock_packages, mock_archive, mock_fetch output = deprecate("-y", "libelf@0.8.10", "libelf@0.8.13", fail_on_error=False) assert "Spec 'libelf@0.8.10' matches no installed packages" in output - install("libelf@0.8.10") + install("--fake", "libelf@0.8.10") output = deprecate("-y", "libelf@0.8.10", "libelf@0.8.13", fail_on_error=False) assert "Spec 'libelf@0.8.13' matches no installed packages" in output -def test_deprecate_install(mock_packages, mock_archive, mock_fetch, install_mockery): - """Tests that the ```-i`` option allows us to deprecate in favor of a spec - that is not yet installed.""" - install("libelf@0.8.10") - - to_deprecate = spack.store.STORE.db.query() +def test_deprecate_install(mock_packages, mock_archive, mock_fetch, install_mockery, monkeypatch): + """Tests that the -i option allows us to deprecate in favor of a spec + that is not yet installed. + """ + install("--fake", "libelf@0.8.10") + to_deprecate = spack.store.STORE.db.query("libelf") assert len(to_deprecate) == 1 deprecate("-y", "-i", "libelf@0.8.10", "libelf@0.8.13") - non_deprecated = spack.store.STORE.db.query() - deprecated = spack.store.STORE.db.query(installed=InstallRecordStatus.DEPRECATED) + non_deprecated = spack.store.STORE.db.query("libelf") + deprecated = spack.store.STORE.db.query("libelf", installed=InstallRecordStatus.DEPRECATED) assert deprecated == to_deprecate assert len(non_deprecated) == 1 assert non_deprecated[0].satisfies("libelf@0.8.13") @@ -64,8 +64,8 @@ def test_deprecate_install(mock_packages, mock_archive, mock_fetch, install_mock def test_deprecate_deps(mock_packages, mock_archive, mock_fetch, install_mockery): """Test that the deprecate command deprecates all dependencies properly.""" - install("libdwarf@20130729 ^libelf@0.8.13") - install("libdwarf@20130207 ^libelf@0.8.10") + install("--fake", "libdwarf@20130729 ^libelf@0.8.13") + install("--fake", "libdwarf@20130207 ^libelf@0.8.10") new_spec = spack.concretize.concretize_one("libdwarf@20130729^libelf@0.8.13") old_spec = spack.concretize.concretize_one("libdwarf@20130207^libelf@0.8.10") @@ -81,14 +81,14 @@ def test_deprecate_deps(mock_packages, mock_archive, mock_fetch, install_mockery assert all_available == all_installed assert sorted(all_available) == sorted(deprecated + non_deprecated) - assert sorted(non_deprecated) == sorted(list(new_spec.traverse())) - assert sorted(deprecated) == sorted(list(old_spec.traverse())) + assert sorted(non_deprecated) == sorted(new_spec.traverse()) + assert sorted(deprecated) == sorted([old_spec, old_spec["libelf"]]) def test_uninstall_deprecated(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that we can still uninstall deprecated packages.""" - install("libelf@0.8.13") - install("libelf@0.8.10") + install("--fake", "libelf@0.8.13") + install("--fake", "libelf@0.8.10") deprecate("-y", "libelf@0.8.10", "libelf@0.8.13") @@ -104,9 +104,9 @@ def test_uninstall_deprecated(mock_packages, mock_archive, mock_fetch, install_m def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that we can re-deprecate a spec to change its deprecator.""" - install("libelf@0.8.13") - install("libelf@0.8.12") - install("libelf@0.8.10") + install("--fake", "libelf@0.8.13") + install("--fake", "libelf@0.8.12") + install("--fake", "libelf@0.8.10") deprecated_spec = spack.concretize.concretize_one("libelf@0.8.10") @@ -117,8 +117,8 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, i deprecate("-y", "libelf@0.8.10", "libelf@0.8.13") - non_deprecated = spack.store.STORE.db.query() - all_available = spack.store.STORE.db.query(installed=InstallRecordStatus.ANY) + non_deprecated = spack.store.STORE.db.query("libelf") + all_available = spack.store.STORE.db.query("libelf", installed=InstallRecordStatus.ANY) assert len(non_deprecated) == 2 assert len(all_available) == 3 @@ -129,9 +129,9 @@ def test_deprecate_already_deprecated(mock_packages, mock_archive, mock_fetch, i def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that when a deprecator spec is deprecated, its deprecatee specs are updated to point to the new deprecator.""" - install("libelf@0.8.13") - install("libelf@0.8.12") - install("libelf@0.8.10") + install("--fake", "libelf@0.8.13") + install("--fake", "libelf@0.8.12") + install("--fake", "libelf@0.8.10") first_deprecated_spec = spack.concretize.concretize_one("libelf@0.8.10") second_deprecated_spec = spack.concretize.concretize_one("libelf@0.8.12") @@ -144,8 +144,8 @@ def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_m deprecate("-y", "libelf@0.8.12", "libelf@0.8.13") - non_deprecated = spack.store.STORE.db.query() - all_available = spack.store.STORE.db.query(installed=InstallRecordStatus.ANY) + non_deprecated = spack.store.STORE.db.query("libelf") + all_available = spack.store.STORE.db.query("libelf", installed=InstallRecordStatus.ANY) assert len(non_deprecated) == 1 assert len(all_available) == 3 @@ -158,8 +158,8 @@ def test_deprecate_deprecator(mock_packages, mock_archive, mock_fetch, install_m def test_concretize_deprecated(mock_packages, mock_archive, mock_fetch, install_mockery): """Tests that the concretizer throws an error if we concretize to a deprecated spec""" - install("libelf@0.8.13") - install("libelf@0.8.10") + install("--fake", "libelf@0.8.13") + install("--fake", "libelf@0.8.10") deprecate("-y", "libelf@0.8.10", "libelf@0.8.13") diff --git a/lib/spack/spack/test/cmd/dev_build.py b/lib/spack/spack/test/cmd/dev_build.py index 84f3fc5acb5..0cb048f26b4 100644 --- a/lib/spack/spack/test/cmd/dev_build.py +++ b/lib/spack/spack/test/cmd/dev_build.py @@ -127,16 +127,15 @@ def test_dev_build_before_until(tmpdir, install_mockery): assert not_installed in out -def print_spack_cc(*args): - # Eat arguments and print environment variable to test - print(os.environ.get("CC", "")) +def _print_spack_short_spec(*args): + print(f"SPACK_SHORT_SPEC={os.environ['SPACK_SHORT_SPEC']}") def test_dev_build_drop_in(tmpdir, mock_packages, monkeypatch, install_mockery, working_env): - monkeypatch.setattr(os, "execvp", print_spack_cc) + monkeypatch.setattr(os, "execvp", _print_spack_short_spec) with tmpdir.as_cwd(): output = dev_build("-b", "edit", "--drop-in", "sh", "dev-build-test-install@0.0.0") - assert os.path.join("lib", "spack", "env") in output + assert "SPACK_SHORT_SPEC=dev-build-test-install@0.0.0" in output def test_dev_build_fails_already_installed(tmpdir, install_mockery): diff --git a/lib/spack/spack/test/cmd/diff.py b/lib/spack/spack/test/cmd/diff.py index 9ef9acacc9f..c077e49af14 100644 --- a/lib/spack/spack/test/cmd/diff.py +++ b/lib/spack/spack/test/cmd/diff.py @@ -194,7 +194,7 @@ def test_diff_cmd(install_mockery, mock_fetch, mock_archive, mock_packages): def test_load_first(install_mockery, mock_fetch, mock_archive, mock_packages): """Test with and without the --first option""" - install_cmd("mpileaks") + install_cmd("--fake", "mpileaks") # Only one version of mpileaks will work diff_cmd("mpileaks", "mpileaks") diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index 9460b060207..c79ec42d62d 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -1750,7 +1750,10 @@ def check_stage(spec): spec = spack.concretize.concretize_one(spec) for dep in spec.traverse(): stage_name = f"{stage_prefix}{dep.name}-{dep.version}-{dep.dag_hash()}" - assert os.path.isdir(os.path.join(root, stage_name)) + if dep.external: + assert not os.path.exists(os.path.join(root, stage_name)) + else: + assert os.path.isdir(os.path.join(root, stage_name)) check_stage("mpileaks") check_stage("zmpi") @@ -3075,11 +3078,10 @@ def test_stack_view_activate_from_default( assert "FOOBAR=mpileaks" in shell -def test_envvar_set_in_activate(tmpdir, mock_fetch, mock_packages, mock_archive, install_mockery): - filename = str(tmpdir.join("spack.yaml")) - with open(filename, "w", encoding="utf-8") as f: - f.write( - """\ +def test_envvar_set_in_activate(tmp_path, mock_packages, install_mockery): + spack_yaml = tmp_path / "spack.yaml" + spack_yaml.write_text( + """ spack: specs: - cmake%gcc @@ -3087,21 +3089,21 @@ def test_envvar_set_in_activate(tmpdir, mock_fetch, mock_packages, mock_archive, set: ENVAR_SET_IN_ENV_LOAD: "True" """ - ) - with tmpdir.as_cwd(): - env("create", "test", "./spack.yaml") - with ev.read("test"): - install() + ) - test_env = ev.read("test") - output = env("activate", "--sh", "test") + env("create", "test", str(spack_yaml)) + with ev.read("test"): + install("--fake") - assert "ENVAR_SET_IN_ENV_LOAD=True" in output + test_env = ev.read("test") + output = env("activate", "--sh", "test") - with test_env: - with spack.util.environment.set_env(ENVAR_SET_IN_ENV_LOAD="True"): - output = env("deactivate", "--sh") - assert "unset ENVAR_SET_IN_ENV_LOAD" in output + assert "ENVAR_SET_IN_ENV_LOAD=True" in output + + with test_env: + with spack.util.environment.set_env(ENVAR_SET_IN_ENV_LOAD="True"): + output = env("deactivate", "--sh") + assert "unset ENVAR_SET_IN_ENV_LOAD" in output def test_stack_view_no_activate_without_default( diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py index 26e62ffc106..9b2f2c9c773 100644 --- a/lib/spack/spack/test/cmd/find.py +++ b/lib/spack/spack/test/cmd/find.py @@ -233,21 +233,27 @@ def test_display_json_deps(database, capsys): @pytest.mark.db def test_find_format(database, config): output = find("--format", "{name}-{^mpi.name}", "mpileaks") - assert set(output.strip().split("\n")) == set( - ["mpileaks-zmpi", "mpileaks-mpich", "mpileaks-mpich2"] - ) + assert set(output.strip().split("\n")) == { + "mpileaks-zmpi", + "mpileaks-mpich", + "mpileaks-mpich2", + } output = find("--format", "{name}-{version}-{compiler.name}-{^mpi.name}", "mpileaks") assert "installed package" not in output - assert set(output.strip().split("\n")) == set( - ["mpileaks-2.3-gcc-zmpi", "mpileaks-2.3-gcc-mpich", "mpileaks-2.3-gcc-mpich2"] - ) + assert set(output.strip().split("\n")) == { + "mpileaks-2.3-gcc-zmpi", + "mpileaks-2.3-gcc-mpich", + "mpileaks-2.3-gcc-mpich2", + } output = find("--format", "{name}-{^mpi.name}-{hash:7}", "mpileaks") elements = output.strip().split("\n") - assert set(e[:-7] for e in elements) == set( - ["mpileaks-zmpi-", "mpileaks-mpich-", "mpileaks-mpich2-"] - ) + assert set(e[:-7] for e in elements) == { + "mpileaks-zmpi-", + "mpileaks-mpich-", + "mpileaks-mpich2-", + } # hashes are in base32 for e in elements: @@ -348,7 +354,7 @@ def test_find_prefix_in_env( """Test `find` formats requiring concrete specs work in environments.""" env("create", "test") with ev.read("test"): - install("--add", "mpileaks") + install("--fake", "--add", "mpileaks") find("-p") find("-l") find("-L")