From c1665567a5ef2d4b7870fc7a039f61a2ae8a1d27 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Tue, 6 Feb 2024 13:48:49 -0800 Subject: [PATCH] address code review comments --- lib/spack/spack/compilers/__init__.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 34c3d72196b..67438aaf38d 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -167,24 +167,18 @@ def _compiler_config_from_external(config): compiler_class = class_for_compiler_name(compiler_spec.name) paths = extra_attributes.get("paths", {}) compiler_langs = ["cc", "cxx", "fc", "f77"] - for compiler in compiler_langs: - if paths.setdefault(compiler, None): + for lang in compiler_langs: + if paths.setdefault(lang, None): continue if not prefix: continue - bindir = prefix - if os.path.basename(prefix) != "bin": - bindir = os.path.join(prefix, "bin") - # Check for files that satisfy the naming scheme for this compiler - for file, regexp in itertools.product( - os.listdir(bindir), compiler_class.search_regexps(compiler) - ): - match = regexp.match(file) - if match: - paths[compiler] = os.path.join(bindir, file) + bindir = os.path.join(prefix, "bin") + for f, regex in itertools.product(os.listdir(bindir), compiler_class.search_regexps(lang)): + if regex.match(f): + paths[lang] = os.path.join(bindir, f) if all(v is None for v in paths.values()): return None @@ -209,7 +203,7 @@ def _compiler_config_from_external(config): "spec": str(compiler_spec), "paths": paths, "flags": extra_attributes.get("flags", {}), - "operating_system": operating_system, + "operating_system": str(operating_system), "target": str(target.family), "modules": config.get("modules", []), "environment": extra_attributes.get("environment", {}),