summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2024-10-23 23:17:40 +0200
committerGitHub <noreply@github.com>2024-10-23 21:17:40 +0000
commit79ad6f6b48303b455d892a99dee7bbc927ca75d0 (patch)
tree16f9b0ff8ff6afbd197de269daa1800a298b7e00 /lib
parent632099340935950f16c993fe03a0193af110ef89 (diff)
downloadspack-79ad6f6b48303b455d892a99dee7bbc927ca75d0.tar.gz
spack-79ad6f6b48303b455d892a99dee7bbc927ca75d0.tar.bz2
spack-79ad6f6b48303b455d892a99dee7bbc927ca75d0.tar.xz
spack-79ad6f6b48303b455d892a99dee7bbc927ca75d0.zip
env: continue to mark non-roots as implicitly installed on partial env installs (#47183)
Fixes a change in behavior/bug in 70412612c79af495fb2b2223edac4bd5a70a813a, where partial environment installs would mark the selected spec as explicitly installed, even if it was not a root of the environment. The desired behavior is that roots by definition are the to be explicitly installed specs. The specs on the `spack -e ... install x` command line are just filters for partial installs, so leave them implicitly installed if they aren't roots.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment/environment.py21
-rw-r--r--lib/spack/spack/test/env.py14
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py
index 8837e2cecd..b00405b5d1 100644
--- a/lib/spack/spack/environment/environment.py
+++ b/lib/spack/spack/environment/environment.py
@@ -1956,17 +1956,16 @@ class Environment:
specs = specs if specs is not None else roots
# Extend the set of specs to overwrite with modified dev specs and their parents
- overwrite: Set[str] = set()
- overwrite.update(install_args.get("overwrite", []), self._dev_specs_that_need_overwrite())
- install_args["overwrite"] = overwrite
-
- explicit: Set[str] = set()
- explicit.update(
- install_args.get("explicit", []),
- (s.dag_hash() for s in specs),
- (s.dag_hash() for s in roots),
- )
- install_args["explicit"] = explicit
+ install_args["overwrite"] = {
+ *install_args.get("overwrite", ()),
+ *self._dev_specs_that_need_overwrite(),
+ }
+
+ # Only environment roots are marked explicit
+ install_args["explicit"] = {
+ *install_args.get("explicit", ()),
+ *(s.dag_hash() for s in roots),
+ }
PackageInstaller([spec.package for spec in specs], **install_args).install()
diff --git a/lib/spack/spack/test/env.py b/lib/spack/spack/test/env.py
index 682540361f..3f2183f5e2 100644
--- a/lib/spack/spack/test/env.py
+++ b/lib/spack/spack/test/env.py
@@ -892,3 +892,17 @@ spack:
with pytest.raises(Exception):
with ev.Environment(tmp_path) as e:
e.concretize()
+
+
+def test_only_roots_are_explicitly_installed(tmp_path, mock_packages, config, temporary_store):
+ """When installing specific non-root specs from an environment, we continue to mark them
+ as implicitly installed. What makes installs explicit is that they are root of the env."""
+ env = ev.create_in_dir(tmp_path)
+ env.add("mpileaks")
+ env.concretize()
+ mpileaks = env.concrete_roots()[0]
+ callpath = mpileaks["callpath"]
+ env.install_specs([callpath], fake=True)
+ assert callpath in temporary_store.db.query(explicit=False)
+ env.install_specs([mpileaks], fake=True)
+ assert temporary_store.db.query(explicit=True) == [mpileaks]