Skip to content

Commit

Permalink
Fix compiler sorting/looping logic in spack-ext/lib/jcsda-emc/spack-s…
Browse files Browse the repository at this point in the history
…tack/stack/meta_modules.py
  • Loading branch information
climbfuji committed Aug 23, 2024
1 parent 99aa58d commit 871fd3d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions spack-ext/lib/jcsda-emc/spack-stack/stack/meta_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def module_prereq_command(module_choice, module):

def modulepath_prepend_command(module_choice, modulepath):
if module_choice == "lmod":
return 'prepend_path("MODULEPATH", "{})\n'.format(modulepath)
return 'prepend_path("MODULEPATH", "{}")\n'.format(modulepath)
else:
return "prepend-path {{MODULEPATH}} {{{}}}\n".format(modulepath)

Expand Down Expand Up @@ -384,14 +384,23 @@ def custom_sort_key(entry):
# Create compiler modules
logging.info("Creating compiler modules ...")
compiler_config = spack.config.get("compilers")
# Collecti and save modulepaths for the preferred compiler
# Collect and save modulepaths for the preferred compiler
MODULEPATHS_SAVE = []
for compiler in compiler_config:
# On macOS, since July 2023, spack compiler find creates 'apple-clang@=14.0.0' etc.
compiler_spec = compiler["compiler"]["spec"].replace("@=", "@")
if compiler_spec in sorted_flattened_compiler_list:
(compiler_name, compiler_version) = compiler_spec.split("@")
for compiler_identifier in sorted_flattened_compiler_list:
(compiler_name, compiler_version) = compiler_identifier.replace("@=","@").split("@")
# Loop through all configured compilers and find the correct match
compiler = False
for candidate_compiler in compiler_config:
if compiler_identifier.replace("@=","@") == \
candidate_compiler["compiler"]["spec"].replace("@=", "@"):
compiler = candidate_compiler
break
if not compiler:
raise Exception("No matching compiler for {} found in spack compiler config".format(compiler))
continue

# This is only to keep the current level of indentation for easier reviewing
if True:
modulepath_save = os.path.join(module_dir, compiler_name, compiler_version)
if not os.path.isdir(modulepath_save):
os.makedirs(modulepath_save)
Expand Down

0 comments on commit 871fd3d

Please sign in to comment.