summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/compilers/__init__.py7
-rw-r--r--lib/spack/spack/cray_manifest.py6
-rw-r--r--lib/spack/spack/test/cray_manifest.py27
3 files changed, 33 insertions, 7 deletions
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 17f65e6409..a57ca6ac55 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -252,6 +252,13 @@ def find_new_compilers(path_hints=None, scope=None):
merged configuration.
"""
compilers = find_compilers(path_hints)
+ return select_new_compilers(compilers, scope)
+
+
+def select_new_compilers(compilers, scope=None):
+ """Given a list of compilers, remove those that are already defined in
+ the configuration.
+ """
compilers_not_in_config = []
for c in compilers:
arch_spec = spack.spec.ArchSpec((None, c.operating_system, c.target))
diff --git a/lib/spack/spack/cray_manifest.py b/lib/spack/spack/cray_manifest.py
index eba29ed9dd..62da9bc868 100644
--- a/lib/spack/spack/cray_manifest.py
+++ b/lib/spack/spack/cray_manifest.py
@@ -39,10 +39,6 @@ def translated_compiler_name(manifest_compiler_name):
elif manifest_compiler_name in spack.compilers.supported_compilers():
return manifest_compiler_name
else:
- # Try to fail quickly. This can occur in two cases: (1) the compiler
- # definition (2) a spec can specify a compiler that doesn't exist; the
- # first will be caught when creating compiler definition. The second
- # will result in Specs with associated undefined compilers.
raise spack.compilers.UnknownCompilerError(
"Manifest parsing - unknown compiler: {0}"
.format(manifest_compiler_name))
@@ -186,6 +182,8 @@ def read(path, apply_updates):
tty.debug("{0}: {1} compilers read from manifest".format(
path,
str(len(compilers))))
+ # Filter out the compilers that already appear in the configuration
+ compilers = spack.compilers.select_new_compilers(compilers)
if apply_updates and compilers:
spack.compilers.add_compilers_to_config(
compilers, init_config=False)
diff --git a/lib/spack/spack/test/cray_manifest.py b/lib/spack/spack/test/cray_manifest.py
index 6a92848539..f8e86607f9 100644
--- a/lib/spack/spack/test/cray_manifest.py
+++ b/lib/spack/spack/test/cray_manifest.py
@@ -33,7 +33,7 @@ example_x_json_str = """\
},
"compiler": {
"name": "gcc",
- "version": "10.2.0"
+ "version": "10.2.0.cray"
},
"dependencies": {
"packagey": {
@@ -157,7 +157,7 @@ _common_arch = JsonArchEntry(
# Intended to match example_compiler_entry above
_common_compiler = JsonCompilerEntry(
name='gcc',
- version='10.2.0',
+ version='10.2.0.cray',
arch={
"os": "centos8",
"target": "x86_64"
@@ -319,7 +319,7 @@ def create_manifest_content():
"cpe-version": "22.06"
},
'specs': list(x.to_dict() for x in generate_openmpi_entries()),
- 'compilers': []
+ 'compilers': [_common_compiler.compiler_json()]
}
@@ -347,6 +347,27 @@ def test_read_cray_manifest(
assert concretized_specs[0]['hwloc'].dag_hash() == 'hwlocfakehashaaa'
+def test_read_cray_manifest_twice_no_compiler_duplicates(
+ tmpdir, mutable_config, mock_packages, mutable_database):
+ if spack.config.get('config:concretizer') == 'clingo':
+ pytest.skip("The ASP-based concretizer is currently picky about "
+ " OS matching and will fail.")
+
+ with tmpdir.as_cwd():
+ test_db_fname = 'external-db.json'
+ with open(test_db_fname, 'w') as db_file:
+ json.dump(create_manifest_content(), db_file)
+
+ # Read the manifest twice
+ cray_manifest.read(test_db_fname, True)
+ cray_manifest.read(test_db_fname, True)
+
+ compilers = spack.compilers.all_compilers()
+ filtered = list(c for c in compilers if
+ c.spec == spack.spec.CompilerSpec('gcc@10.2.0.cray'))
+ assert(len(filtered) == 1)
+
+
def test_read_old_manifest_v1_2(
tmpdir, mutable_config, mock_packages, mutable_database):
"""Test reading a file using the older format