Skip to content

Commit

Permalink
Merge pull request #706 from douglasjacobsen/spack-stack-externals
Browse files Browse the repository at this point in the history
Allow spack-stack to define external packages that should be automatically detected
  • Loading branch information
rfbgo authored Oct 21, 2024
2 parents 5523b87 + 16911f3 commit 7f40b12
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion var/ramble/repos/builtin/applications/spack-stack/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SpackStack(ExecutableApplication):
"create",
executables=[
"builtin::remove_env_files",
"builtin::find_externals",
"configure",
"install",
"builtin::remove_packages",
Expand All @@ -68,11 +69,18 @@ class SpackStack(ExecutableApplication):

workload_variable(
"install_flags",
default="",
default="--fail-fast",
description="Flags to use for `spack install`",
workloads=["create"],
)

workload_variable(
"external_packages",
default=[],
description="List of packages to `spack external find` and mark not buildable",
workloads=["create"],
)

workload_variable(
"removed_packages",
default=[],
Expand Down Expand Up @@ -146,6 +154,28 @@ def remove_env_files(self):
cmds = ["rm -f {env_path}/spack.lock", "rm -rf {env_path}/.spack-env"]
return cmds

register_builtin("find_externals", required=False)

def find_externals(self):
"""Inject commands to find external non buildable packages
This allows spack find external system packages before building,
to ensure system packages are used for some dependencies.
"""
cmds = []

# Package finding is only supported in bash or sh
if ramble.config.get("config:shell") in ["sh", "bash"]:
# Do not expand the `external_packages` variable, so it will not be
# used to render experiments.
external_packages = self.expander.expand_var_name(
"external_packages", merge_used_stage=False, typed=True
)
self.expander.flush_used_variable_stage()
for pkg in external_packages:
cmds.append(f"spack external find --not-buildable {pkg}")
return cmds

register_builtin("remove_packages", required=False)

def remove_packages(self):
Expand Down

0 comments on commit 7f40b12

Please sign in to comment.