Skip to content

Commit 2164fab

Browse files
committed
remove gcc from system spack config - inject into env/packages.yaml
1 parent e807e8e commit 2164fab

File tree

5 files changed

+70
-57
lines changed

5 files changed

+70
-57
lines changed

stackinator/builder.py

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -298,24 +298,15 @@ def generate(self, recipe):
298298
# that are defined for the target cluster.
299299
config_path = self.path / "config"
300300
config_path.mkdir(exist_ok=True)
301-
system_config_path = pathlib.Path(recipe.system_config_path)
302-
303-
# Copy the yaml files to the spack config path
304-
for f_config in system_config_path.iterdir():
305-
# print warning if mirrors.yaml is found
306-
if f_config.name in ["mirrors.yaml"]:
307-
self._logger.error(
308-
"mirrors.yaml have been removed from cluster configurations,"
309-
" use the --cache option on stack-config instead."
310-
)
311-
raise RuntimeError("Unsupported mirrors.yaml file in cluster configuration.")
301+
packages_path = config_path / "packages.yaml"
312302

313-
# construct full file path
314-
src = system_config_path / f_config.name
315-
dst = config_path / f_config.name
316-
# copy only files
317-
if src.is_file():
318-
shutil.copy(src, dst)
303+
# the packages.yaml configuration that will be used when building all environments
304+
# - the system packages.yaml with gcc removed
305+
# - plus additional packages provided by the recipe
306+
global_packages_yaml = yaml.dump(recipe.packages["global"])
307+
global_packages_path = config_path / "packages.yaml"
308+
with global_packages_path.open("w") as fid:
309+
fid.write(global_packages_yaml)
319310

320311
# generate a mirrors.yaml file if build caches have been configured
321312
if recipe.mirror:
@@ -324,21 +315,6 @@ def generate(self, recipe):
324315
with dst.open("w") as fid:
325316
fid.write(cache.generate_mirrors_yaml(recipe.mirror))
326317

327-
# append recipe packages to packages.yaml
328-
if recipe.packages:
329-
system_packages = system_config_path / "packages.yaml"
330-
packages_data = {}
331-
if system_packages.is_file():
332-
# load system yaml
333-
with system_packages.open() as fid:
334-
raw = yaml.load(fid, Loader=yaml.Loader)
335-
packages_data = raw["packages"]
336-
packages_data.update(recipe.packages["packages"])
337-
packages_yaml = yaml.dump({"packages": packages_data})
338-
packages_path = config_path / "packages.yaml"
339-
with packages_path.open("w") as fid:
340-
fid.write(packages_yaml)
341-
342318
# Add custom spack package recipes, configured via Spack repos.
343319
# Step 1: copy Spack repos to store_path where they will be used to
344320
# build the stack, and then be part of the upstream provided
@@ -362,7 +338,7 @@ def generate(self, recipe):
362338
repos.append(recipe.spack_repo)
363339

364340
# look for repos.yaml file in the system configuration
365-
repo_yaml = system_config_path / "repos.yaml"
341+
repo_yaml = recipe.system_config_path / "repos.yaml"
366342
if repo_yaml.exists() and repo_yaml.is_file():
367343
# open repos.yaml file and reat the list of repos
368344
with repo_yaml.open() as fid:
@@ -373,7 +349,7 @@ def generate(self, recipe):
373349

374350
# test each path
375351
for rel_path in P:
376-
repo_path = (system_config_path / rel_path).resolve()
352+
repo_path = (recipe.system_config_path / rel_path).resolve()
377353
if spack_util.is_repo(repo_path):
378354
repos.append(repo_path)
379355
self._logger.debug(f"adding site spack package repo: {repo_path}")
@@ -453,11 +429,12 @@ def generate(self, recipe):
453429
with (compiler_path / "Makefile").open(mode="w") as f:
454430
f.write(compiler_files["makefile"])
455431

456-
for name, yml in compiler_files["config"].items():
432+
for name, files in compiler_files["config"].items():
457433
compiler_config_path = compiler_path / name
458434
compiler_config_path.mkdir(exist_ok=True)
459-
with (compiler_config_path / "spack.yaml").open(mode="w") as f:
460-
f.write(yml)
435+
for file, raw in files.items():
436+
with (compiler_config_path / file).open(mode="w") as f:
437+
f.write(raw)
461438

462439
# generate the makefile and spack.yaml files that describe the environments
463440
environment_files = recipe.environment_files
@@ -479,14 +456,17 @@ def generate(self, recipe):
479456
generate_config_path.mkdir(exist_ok=True)
480457

481458
# write generate-config/Makefile
459+
# TODO: we differentiate between all and release compilers in order to generate modules
460+
# we have to do better, no?
482461
all_compilers = [x for x in recipe.compilers.keys()]
483-
release_compilers = [x for x in all_compilers if x != "bootstrap"]
462+
#release_compilers = [x for x in all_compilers if x != "bootstrap"]
484463
with (generate_config_path / "Makefile").open("w") as f:
485464
f.write(
486465
make_config_template.render(
487466
build_path=self.path.as_posix(),
488467
all_compilers=all_compilers,
489-
release_compilers=release_compilers,
468+
#release_compilers=release_compilers,
469+
release_compilers=all_compilers,
490470
verbose=False,
491471
)
492472
)

stackinator/main.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import argparse
2-
import hashlib
32
import logging
4-
import os
5-
import platform
63
import sys
7-
import time
84
import traceback
95

106
from . import VERSION, root_logger
@@ -13,9 +9,9 @@
139

1410

1511
def generate_logfile_name(name=""):
16-
#idstr = f"{time.localtime()}{os.getpid}{platform.uname()}"
17-
#return f"log{name}_{hashlib.md5(idstr.encode('utf-8')).hexdigest()}"
18-
return f"stackinator_log"
12+
# idstr = f"{time.localtime()}{os.getpid}{platform.uname()}"
13+
# return f"log{name}_{hashlib.md5(idstr.encode('utf-8')).hexdigest()}"
14+
return "stackinator_log"
1915

2016

2117
def configure_logging(logfile):

stackinator/recipe.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,40 @@ def __init__(self, args):
130130
with packages_path.open() as fid:
131131
self.packages = yaml.load(fid, Loader=yaml.Loader)
132132

133+
self._logger.debug("creating packages")
134+
135+
# load recipe/packages.yaml -> recipe_packages (if it exists)
136+
recipe_packages = {}
137+
recipe_packages_path = self.path / "packages.yaml"
138+
if recipe_packages_path.is_file():
139+
with recipe_packages_path.open() as fid:
140+
raw = yaml.load(fid, Loader=yaml.Loader)
141+
recipe_packages = raw["packages"]
142+
143+
# load system/packages.yaml -> system_packages (if it exists)
144+
system_packages = {}
145+
system_packages_path = self.system_config_path / "packages.yaml"
146+
if system_packages_path.is_file():
147+
# load system yaml
148+
with system_packages_path.open() as fid:
149+
raw = yaml.load(fid, Loader=yaml.Loader)
150+
system_packages = raw["packages"]
151+
152+
# extract gcc_packages from system packages
153+
# remove gcc from packages afterwards
154+
if system_packages["gcc"]:
155+
gcc_packages = {"gcc": system_packages["gcc"]}
156+
del system_packages["gcc"]
157+
else:
158+
raise RuntimeError("The system packages.yaml file does not provide gcc")
159+
160+
self.packages = {
161+
# the package definition used in every environment
162+
"global": {"packages": system_packages | recipe_packages},
163+
# the package definition used to build gcc (requires system gcc to bootstrap)
164+
"gcc": {"packages": system_packages | gcc_packages | recipe_packages},
165+
}
166+
133167
# optional mirror configurtion
134168
mirrors_path = self.path / "mirrors.yaml"
135169
if mirrors_path.is_file():
@@ -405,10 +439,9 @@ def generate_compiler_specs(self, raw):
405439
# gcc["packages"] = {
406440
# "external": [ "perl", "m4", "autoconf", "automake", "libtool", "gawk", "python", "texinfo", "gawk", ],
407441
# }
408-
409442
gcc["specs"] = [raw["gcc"]["spec"] + " +bootstrap"]
410-
411443
gcc["exclude_from_cache"] = ["cuda", "nvhpc", "perl"]
444+
412445
compilers["gcc"] = gcc
413446

414447
# TODO: fix up using gcc as an upstream of nvhpc
@@ -475,11 +508,15 @@ def compiler_files(self):
475508
spack_version=self.spack_version,
476509
)
477510

478-
# generate compilers/<compiler>/spack.yaml
479511
files["config"] = {}
480512
for compiler, config in self.compilers.items():
481513
spack_yaml_template = env.get_template(f"compilers.{compiler}.spack.yaml")
482-
files["config"][compiler] = spack_yaml_template.render(config=config)
514+
files["config"][compiler] = {}
515+
# compilers/<compiler>/spack.yaml
516+
files["config"][compiler]["spack.yaml"] = spack_yaml_template.render(config=config)
517+
# compilers/gcc/packages.yaml
518+
if compiler == "gcc":
519+
files["config"][compiler]["packages.yaml"] = yaml.dump(self.packages["gcc"])
483520

484521
return files
485522

stackinator/templates/Makefile.compilers

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ llvm/packages.yaml: gcc/generated/env
4646
$(SPACK) compiler find --scope=user $(call compiler_bin_dirs, $$($(SPACK_HELPER) -e ./gcc find --explicit --format '{prefix}' {{ compilers.llvm.requires }}))
4747
{% endif %}
4848

49+
{% if compilers.nvhpc %}
50+
nvhpc/packages.yaml: gcc/generated/env
51+
$(SPACK) compiler find --scope=user $(call compiler_bin_dirs, $$($(SPACK_HELPER) -e ./gcc find --explicit --format '{prefix}' {{ compilers.nvhpc.requires }}))
52+
{% endif %}
53+
4954

5055
include ../Make.inc
5156

stackinator/templates/Makefile.environments

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,11 @@ all:{% for env in environments %} {{ env }}/generated/build_cache{% endfor %}
4949

5050
{{ env }}/packages.yaml:
5151
$(SPACK) compiler find --scope=user $(call compiler_bin_dirs, $({{ env }}_PREFIX))
52-
53-
{% endfor %}
54-
55-
# Configure external system dependencies for each compiler toolchain
56-
{% for env, config in environments.items() %}
5752
{% if config.packages %}
58-
{{ env }}/packages.yaml:
5953
$(SPACK) external find --not-buildable --scope=user {% for package in config.packages %} {{package}}{% endfor %}
54+
{% endif %}
6055

6156

62-
{% endif %}
6357
{% endfor %}
6458

6559
-include ../Make.inc
@@ -69,3 +63,4 @@ ifeq (,$(filter clean,$(MAKECMDGOALS)))
6963
include {{ env }}/Makefile
7064
{% endfor %}
7165
endif
66+

0 commit comments

Comments
 (0)