From 5d2151ed645f853a083cd445ae8631f9ed987559 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Thu, 31 Mar 2016 10:20:55 -0700 Subject: [PATCH] reworked to deal with stage.path as property This version actually pulls the path through the package to deliver it to each stage on creation when passed through the command. This is necessary due to the new StageComposite class that makes setting the path directly on the stage impractical, it also takes the logic out of package for the most part, which seems like an improvement. --- lib/spack/spack/cmd/stage.py | 5 ++--- lib/spack/spack/package.py | 15 +++++++-------- lib/spack/spack/stage.py | 7 +++++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/spack/spack/cmd/stage.py b/lib/spack/spack/cmd/stage.py index 749fa90868..975bb54ef7 100644 --- a/lib/spack/spack/cmd/stage.py +++ b/lib/spack/spack/cmd/stage.py @@ -54,6 +54,5 @@ def stage(parser, args): for spec in specs: package = spack.repo.get(spec) if args.path: - package.do_stage(path=args.path) - else: - package.do_stage() + package.path = args.path + package.do_stage() diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index ce314b7b0a..9dcfbee661 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -335,6 +335,9 @@ def __init__(self, spec): if '.' in self.name: self.name = self.name[self.name.rindex('.') + 1:] + # Allow custom staging paths for packages + self.path=None + # Sanity check attributes required by Spack directives. spack.directives.ensure_dicts(type(self)) @@ -445,7 +448,8 @@ def _make_resource_stage(self, root_stage, fetcher, resource): resource_stage_folder = self._resource_stage(resource) resource_mirror = join_path(self.name, os.path.basename(fetcher.url)) stage = ResourceStage(resource.fetcher, root=root_stage, resource=resource, - name=resource_stage_folder, mirror_path=resource_mirror) + name=resource_stage_folder, mirror_path=resource_mirror, + path=self.path) return stage def _make_root_stage(self, fetcher): @@ -455,7 +459,7 @@ def _make_root_stage(self, fetcher): s = self.spec stage_name = "%s-%s-%s" % (s.name, s.version, s.dag_hash()) # Build the composite stage - stage = Stage(fetcher, mirror_path=mp, name=stage_name) + stage = Stage(fetcher, mirror_path=mp, name=stage_name, path=self.path) return stage def _make_stage(self): @@ -709,18 +713,13 @@ def do_fetch(self, mirror_only=False): if spack.do_checksum and self.version in self.versions: self.stage.check() - def do_stage(self, mirror_only=False, path=None): + def do_stage(self, mirror_only=False): """Unpacks the fetched tarball, then changes into the expanded tarball directory.""" - if not self.spec.concrete: raise ValueError("Can only stage concrete packages.") self.do_fetch(mirror_only) - - if path is not None: - self.stage.path = path - self.stage.expand_archive() self.stage.chdir_to_source() diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py index f88f82fc2d..d711752c20 100644 --- a/lib/spack/spack/stage.py +++ b/lib/spack/spack/stage.py @@ -89,7 +89,7 @@ class Stage(object): """ def __init__(self, url_or_fetch_strategy, - name=None, mirror_path=None, keep=False): + name=None, mirror_path=None, keep=False, path=None): """Create a stage object. Parameters: url_or_fetch_strategy @@ -135,7 +135,10 @@ def __init__(self, url_or_fetch_strategy, # Try to construct here a temporary name for the stage directory # If this is a named stage, then construct a named path. - self.path = join_path(spack.stage_path, self.name) + if path is not None: + self.path = path + else: + self.path = join_path(spack.stage_path, self.name) # Flag to decide whether to delete the stage folder on exit or not self.keep = keep