Skip to content

Commit

Permalink
Add the ability to push specific dependency types to BuildCache. (spa…
Browse files Browse the repository at this point in the history
  • Loading branch information
greenc-FNAL authored Oct 26, 2022
1 parent b849f55 commit f92137f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/spack/spack/binary_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import spack.cmd
import spack.config as config
import spack.database as spack_db
import spack.dependency as dep
import spack.hooks
import spack.hooks.sbang
import spack.mirror
Expand Down Expand Up @@ -1225,11 +1226,12 @@ def _build_tarball(
return None


def nodes_to_be_packaged(specs, include_root=True, include_dependencies=True):
def nodes_to_be_packaged(specs, deptype, include_root=True, include_dependencies=True):
"""Return the list of nodes to be packaged, given a list of specs.
Args:
specs (List[spack.spec.Spec]): list of root specs to be processed
deptype: dependency types to package
include_root (bool): include the root of each spec in the nodes
include_dependencies (bool): include the dependencies of each
spec in the nodes
Expand All @@ -1248,10 +1250,7 @@ def skip_node(current_node):
nodes = [current_spec]
else:
nodes = [
n
for n in current_spec.traverse(
order="post", root=include_root, deptype=("link", "run")
)
n for n in current_spec.traverse(order="post", root=include_root, deptype=deptype)
]

for node in nodes:
Expand All @@ -1274,7 +1273,11 @@ def push(specs, push_url, specs_kwargs=None, **kwargs):
**kwargs: TODO
"""
specs_kwargs = specs_kwargs or {"include_root": True, "include_dependencies": True}
specs_kwargs = specs_kwargs or {
"include_root": True,
"include_dependencies": True,
"deptype": dep.default_deptype,
}
nodes = nodes_to_be_packaged(specs, **specs_kwargs)

# TODO: This seems to be an easy target for task
Expand Down
17 changes: 16 additions & 1 deletion lib/spack/spack/cmd/buildcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.config
import spack.dependency as dep
import spack.environment as ev
import spack.hash_types as ht
import spack.mirror
Expand All @@ -29,13 +30,26 @@
from spack.error import SpecError
from spack.spec import Spec, save_dependency_specfiles
from spack.stage import Stage
from spack.util.pattern import Args
from spack.util.string import plural

description = "create, download and install binary packages"
section = "packaging"
level = "long"


@arguments.arg
def deptype_default_default_deptype():
return Args(
"--deptype",
action=arguments.DeptypeAction,
metavar="deptype",
default=dep.default_deptype,
help="comma-separated list of deptypes to traverse\ndefault=%s"
% ",".join(dep.default_deptype),
)


def setup_parser(subparser):
setup_parser.parser = subparser
subparsers = subparser.add_subparsers(help="buildcache sub-commands")
Expand Down Expand Up @@ -110,7 +124,7 @@ def setup_parser(subparser):
" or only the dependencies"
),
)
arguments.add_common_arguments(create, ["specs"])
arguments.add_common_arguments(create, ["specs", "deptype_default_default_deptype"])
create.set_defaults(func=create_fn)

install = subparsers.add_parser("install", help=install_fn.__doc__)
Expand Down Expand Up @@ -369,6 +383,7 @@ def create_fn(args):
specs_kwargs = {
"include_root": "package" in args.things_to_install,
"include_dependencies": "dependencies" in args.things_to_install,
"deptype": args.deptype,
}
kwargs = {
"key": args.key,
Expand Down

0 comments on commit f92137f

Please sign in to comment.