From 577194a02836f5a09f8c9d50d9e66a4d51daa8e2 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 24 Jan 2024 23:38:29 -0700 Subject: [PATCH 1/4] first iteration of plugin enabled spackage --- .../packages/singularity-eos/package.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index ac8bd9f44e..de3d0077db 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -5,7 +5,25 @@ import os +from spack.error import SpackError from spack.package import * +from spack.directives import directive + + +@directive("singularity_eos_plugins") +def singularity_eos_plugin(name, path): + def _execute_register(pkg): + pkg.plugins[name] = path + + return _execute_register + + +def plugin_validator(pkg_name, variant_name, values): + if values == ("none",): + return + for v in values: + if v not in SingularityEos.plugins: + raise SpackError(f"Unknown Singularity-EOS plugin '{v}'") class SingularityEos(CMakePackage, CudaPackage): @@ -63,6 +81,19 @@ class SingularityEos(CMakePackage, CudaPackage): variant("closure", default=True, description="Build closure module") + plugins = {} + + singularity_eos_plugin("dust", "example/plugin") + + variant( + "plugins", + multi=True, + default="none", + validator=plugin_validator, + description="list of plugins to build", + ) + variant("variant", default="default", description="include path used for variant header") + # building/testing/docs depends_on("cmake@3.19:") depends_on("catch2@3.0.1:", when="@main +tests") @@ -183,6 +214,15 @@ def cmake_args(self): self.define("SINGULARITY_USE_EOSPAC", "^eospac" in self.spec), ] + if "none" not in self.spec.variants["plugins"].value: + pdirs = [] + for p in self.spec.variants["plugins"].value: + pdirs.append(join_path(self.stage.source_path, self.plugins[p])) + args.append(self.define("SINGULARITY_PLUGINS", ";".join(pdirs))) + + if self.spec.variants["variant"].value != "default": + args.append(self.define_from_variant("SINGULARITY_VARIANT", "variant")) + #TODO: do we need this? if "+kokkos+cuda" in self.spec: args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx)) From 132bac2524001a7ce6b80aa94ce6db3915badf79 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 26 Jan 2024 09:47:40 -0700 Subject: [PATCH 2/4] Rename spack repo to singularity_eos --- spack-repo/repo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spack-repo/repo.yaml b/spack-repo/repo.yaml index 9e4c10e980..d580ee9103 100644 --- a/spack-repo/repo.yaml +++ b/spack-repo/repo.yaml @@ -3,4 +3,4 @@ # ### repo: - namespace: singularity-eos + namespace: singularity_eos From f9158b208c119af7d3b01ed3a6e56d3b319338b3 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 26 Jan 2024 11:58:03 -0700 Subject: [PATCH 3/4] Simplify spackage --- spack-repo/packages/singularity-eos/package.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index de3d0077db..1b99b0087c 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -215,9 +215,7 @@ def cmake_args(self): ] if "none" not in self.spec.variants["plugins"].value: - pdirs = [] - for p in self.spec.variants["plugins"].value: - pdirs.append(join_path(self.stage.source_path, self.plugins[p])) + pdirs = [join_path(self.stage.source_path, self.plugins[p]) for p in self.spec.variants["plugins"].value] args.append(self.define("SINGULARITY_PLUGINS", ";".join(pdirs))) if self.spec.variants["variant"].value != "default": From a4a756c32388cc149c5ff7bbca2c40231950a148 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 29 Jan 2024 16:18:05 -0700 Subject: [PATCH 4/4] spack: only enable plugin support for @main --- spack-repo/packages/singularity-eos/package.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index 1b99b0087c..5d5c58617e 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -91,8 +91,9 @@ class SingularityEos(CMakePackage, CudaPackage): default="none", validator=plugin_validator, description="list of plugins to build", + when="@main" ) - variant("variant", default="default", description="include path used for variant header") + variant("variant", default="default", description="include path used for variant header", when="@main") # building/testing/docs depends_on("cmake@3.19:") @@ -214,12 +215,13 @@ def cmake_args(self): self.define("SINGULARITY_USE_EOSPAC", "^eospac" in self.spec), ] - if "none" not in self.spec.variants["plugins"].value: - pdirs = [join_path(self.stage.source_path, self.plugins[p]) for p in self.spec.variants["plugins"].value] - args.append(self.define("SINGULARITY_PLUGINS", ";".join(pdirs))) + if self.spec.satisfies("@main"): + if "none" not in self.spec.variants["plugins"].value: + pdirs = [join_path(self.stage.source_path, self.plugins[p]) for p in self.spec.variants["plugins"].value] + args.append(self.define("SINGULARITY_PLUGINS", ";".join(pdirs))) - if self.spec.variants["variant"].value != "default": - args.append(self.define_from_variant("SINGULARITY_VARIANT", "variant")) + if self.spec.variants["variant"].value != "default": + args.append(self.define_from_variant("SINGULARITY_VARIANT", "variant")) #TODO: do we need this? if "+kokkos+cuda" in self.spec: