summaryrefslogtreecommitdiff
path: root/lib/spack/spack/binary_distribution.py
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2023-02-16 15:08:49 +0100
committerGitHub <noreply@github.com>2023-02-16 14:08:49 +0000
commit44ed0de8c077630148c213d3c7f40a8965eb6f94 (patch)
treeab1046d357d684f6c803a10ed526ff9939e78979 /lib/spack/spack/binary_distribution.py
parent09eb86e077d1273412862d773c169e03822adb82 (diff)
downloadspack-44ed0de8c077630148c213d3c7f40a8965eb6f94.tar.gz
spack-44ed0de8c077630148c213d3c7f40a8965eb6f94.tar.bz2
spack-44ed0de8c077630148c213d3c7f40a8965eb6f94.tar.xz
spack-44ed0de8c077630148c213d3c7f40a8965eb6f94.zip
spack buildcache create: push all deps / cleanup (#34860)
Diffstat (limited to 'lib/spack/spack/binary_distribution.py')
-rw-r--r--lib/spack/spack/binary_distribution.py52
1 files changed, 20 insertions, 32 deletions
diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py
index 074e3e6490..1e1085707e 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -40,6 +40,7 @@ import spack.platforms
import spack.relocate as relocate
import spack.repo
import spack.store
+import spack.traverse as traverse
import spack.util.file_cache as file_cache
import spack.util.gpg
import spack.util.spack_json as sjson
@@ -1308,57 +1309,44 @@ def _build_tarball(
return None
-def nodes_to_be_packaged(specs, include_root=True, include_dependencies=True):
+def nodes_to_be_packaged(specs, root=True, 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
- include_root (bool): include the root of each spec in the nodes
- include_dependencies (bool): include the dependencies of each
+ root (bool): include the root of each spec in the nodes
+ dependencies (bool): include the dependencies of each
spec in the nodes
"""
- if not include_root and not include_dependencies:
- return set()
-
- def skip_node(current_node):
- if current_node.external or current_node.virtual:
- return True
- return spack.store.db.query_one(current_node) is None
-
- expanded_set = set()
- for current_spec in specs:
- if not include_dependencies:
- nodes = [current_spec]
- else:
- nodes = [
- n
- for n in current_spec.traverse(
- order="post", root=include_root, deptype=("link", "run")
- )
- ]
+ if not root and not dependencies:
+ return []
+ elif dependencies:
+ nodes = traverse.traverse_nodes(specs, root=root, deptype="all")
+ else:
+ nodes = set(specs)
- for node in nodes:
- if not skip_node(node):
- expanded_set.add(node)
+ # Limit to installed non-externals.
+ packageable = lambda n: not n.external and n.installed
- return expanded_set
+ # Mass install check
+ with spack.store.db.read_transaction():
+ return list(filter(packageable, nodes))
-def push(specs, push_url, specs_kwargs=None, **kwargs):
+def push(specs, push_url, include_root=True, include_dependencies=True, **kwargs):
"""Create a binary package for each of the specs passed as input and push them
to a given push URL.
Args:
specs (List[spack.spec.Spec]): installed specs to be packaged
push_url (str): url where to push the binary package
- specs_kwargs (dict): dictionary with two possible boolean keys, "include_root"
- and "include_dependencies", which determine which part of each spec is
- packaged and pushed to the mirror
+ include_root (bool): include the root of each spec in the nodes
+ include_dependencies (bool): include the dependencies of each
+ spec in the nodes
**kwargs: TODO
"""
- specs_kwargs = specs_kwargs or {"include_root": True, "include_dependencies": True}
- nodes = nodes_to_be_packaged(specs, **specs_kwargs)
+ nodes = nodes_to_be_packaged(specs, root=include_root, dependencies=include_dependencies)
# TODO: This seems to be an easy target for task
# TODO: distribution using a parallel pool