You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:40:20 UTC
[buildstream] 01/02: _stream.py: Load the appropriate
PipelineSelection in checkout
This is an automated email from the ASF dual-hosted git repository.
root pushed a commit to branch jennis/pull_implicitly_in_checkout
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 1c4fc0277245a6d1fa206aa03ff32bce7041ea77
Author: James Ennis <ja...@codethink.co.uk>
AuthorDate: Wed Sep 11 17:48:49 2019 +0100
_stream.py: Load the appropriate PipelineSelection in checkout
This patch ensures checkout behaves like the rest of our
commands which support --deps options. That is, we carry
the "deps" string through to the Stream and load the
corresponding PipelineSelection.
---
src/buildstream/_frontend/cli.py | 5 +----
src/buildstream/_stream.py | 18 +++++++++---------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 1fdbbdc..6f40916 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1066,8 +1066,6 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
When this command is executed from a workspace directory, the default
is to checkout the artifact of the workspace element.
"""
- from ..element import Scope
-
if hardlinks and tar:
click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
sys.exit(-1)
@@ -1107,11 +1105,10 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
if not target:
raise AppError('Missing argument "ELEMENT".')
- scope = {'run': Scope.RUN, 'build': Scope.BUILD, 'none': Scope.NONE}
app.stream.checkout(target,
location=location,
force=force,
- scope=scope[deps],
+ deps=deps,
integrate=True if integrate is None else integrate,
hardlinks=hardlinks,
pull=pull_,
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 293ba05..feb3efe 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -536,21 +536,20 @@ class Stream():
def checkout(self, target, *,
location=None,
force=False,
- scope=Scope.RUN,
+ deps='run',
integrate=True,
hardlinks=False,
compression='',
pull=False,
tar=False):
- # if pulling we need to ensure dependency artifacts are also pulled
- selection = PipelineSelection.RUN if pull else PipelineSelection.NONE
- elements, _ = self._load((target,), (), selection=selection, use_artifact_config=True, load_refs=True)
- target = elements[-1]
+ elements, _ = self._load((target,), (), selection=deps, use_artifact_config=True, load_refs=True)
- # Verify that --deps run has not been specified for an ArtifactElement
- if isinstance(target, ArtifactElement) and scope == Scope.RUN:
- raise StreamError("Unable to determine the runtime dependencies of an ArtifactElement")
+ # self.targets contains a list of the loaded target objects
+ # if we specify --deps build, Stream._load() will return a list
+ # of build dependency objects, however, we need to prepare a sandbox
+ # with the target (which has had its appropriate dependencies loaded)
+ target = self.targets[0]
self._check_location_writable(location, force=force, tar=tar)
@@ -563,7 +562,8 @@ class Stream():
self._run()
try:
- with target._prepare_sandbox(scope=scope, directory=None,
+ scope = {'run': Scope.RUN, 'build': Scope.BUILD, 'none': Scope.NONE}
+ with target._prepare_sandbox(scope=scope[deps], directory=None,
integrate=integrate) as sandbox:
# Copy or move the sandbox to the target directory
virdir = sandbox.get_virtual_directory()