summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/installer.py28
-rw-r--r--lib/spack/spack/test/installer.py20
2 files changed, 47 insertions, 1 deletions
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index 620f489c77..62770d0349 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -803,8 +803,34 @@ class PackageInstaller(object):
"""
packages = _packages_needed_to_bootstrap_compiler(compiler, architecture, pkgs)
for (comp_pkg, is_compiler) in packages:
- if package_id(comp_pkg) not in self.build_tasks:
+ pkgid = package_id(comp_pkg)
+ if pkgid not in self.build_tasks:
self._add_init_task(comp_pkg, request, is_compiler, all_deps)
+ elif is_compiler:
+ # ensure it's queued as a compiler
+ self._modify_existing_task(pkgid, "compiler", True)
+
+ def _modify_existing_task(self, pkgid, attr, value):
+ """
+ Update a task in-place to modify its behavior.
+
+ Currently used to update the ``compiler`` field on tasks
+ that were originally created as a dependency of a compiler,
+ but are compilers in their own right.
+
+ For example, ``intel-oneapi-compilers-classic`` depends on
+ ``intel-oneapi-compilers``, which can cause the latter to be
+ queued first as a non-compiler, and only later as a compiler.
+ """
+ for i, tup in enumerate(self.build_pq):
+ key, task = tup
+ if task.pkg_id == pkgid:
+ tty.debug(
+ "Modifying task for {0} to treat it as a compiler".format(pkgid),
+ level=2,
+ )
+ setattr(task, attr, value)
+ self.build_pq[i] = (key, task)
def _add_init_task(self, pkg, request, is_compiler, all_deps):
"""
diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py
index 363d92fe1f..8a713ca704 100644
--- a/lib/spack/spack/test/installer.py
+++ b/lib/spack/spack/test/installer.py
@@ -467,6 +467,26 @@ def test_packages_needed_to_bootstrap_compiler_packages(install_mockery, monkeyp
assert packages
+def test_update_tasks_for_compiler_packages_as_compiler(mock_packages, config, monkeypatch):
+ spec = spack.spec.Spec("trivial-install-test-package").concretized()
+ installer = inst.PackageInstaller([(spec.package, {})])
+
+ # Add a task to the queue
+ installer._add_init_task(spec.package, installer.build_requests[0], False, {})
+
+ # monkeypatch to make the list of compilers be what we test
+ def fake_package_list(compiler, architecture, pkgs):
+ return [(spec.package, True)]
+
+ monkeypatch.setattr(inst, "_packages_needed_to_bootstrap_compiler", fake_package_list)
+
+ installer._add_bootstrap_compilers("fake", "fake", "fake", None, {})
+
+ # Check that the only task is now a compiler task
+ assert len(installer.build_pq) == 1
+ assert installer.build_pq[0][1].compiler
+
+
def test_dump_packages_deps_ok(install_mockery, tmpdir, mock_packages):
"""Test happy path for dump_packages with dependencies."""