-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResourceStage: use expanded archive name by default #11688
ResourceStage: use expanded archive name by default #11688
Conversation
…source files are placed. For resources, it is desirable to use the expanded archive name as the default; therefore this stores the expanded archive name and uses it as the default for 'placement'
…der to allow resources to choose a sensible default name
@@ -520,7 +526,16 @@ def archive(self, destination, **kwargs): | |||
tar.add_default_arg('--exclude=%s' % p) | |||
|
|||
with working_dir(self.stage.path): | |||
tar('-czf', destination, os.path.basename(self.stage.source_path)) | |||
if self.stage.srcdir: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change addressing potential naming conflicts? Or ensuring any surviving archive has a meaningful name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter: srcdir
stores whatever meaningful name can be extracted (e.g. the basename of the URL). If one cannot be extracted, then we resort to creating a tarball that expands to spack-src/
.
if not spack.config.get('config:debug'): | ||
args.insert(1, '--quiet') | ||
git(*args) | ||
debug = spack.config.get('config:debug') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the git destination option here (as Todd wanted)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm not familiar with that (the option or the context) - is this from a discussion in #11528?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see #11528 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the question is "why not check out the repository out directly to the spack-src
directory?". The issue with that is that when we do that, we lose the repository name: for example if we do git clone https://github.com/spack
then we get a directory called spack
; this is useful when choosing a directory name for the archive in two cases:
- This avoids putting resources named
spack-src
into a root stage - This avoids caching an SCM package into a directory called
spack-src
(i.e. when placed invar/spack/cache/
)
Does that seem reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Thanks for the clarification.
# Yet more efficiency, only download a 1-commit deep tree | ||
if self.git_version >= ver('1.7.1'): | ||
try: | ||
git(*(args + ['--depth', '1', self.url])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above wrt using the git destination option.
@@ -828,8 +853,13 @@ def fetch(self): | |||
args = ['checkout', '--force', '--quiet'] | |||
if self.revision: | |||
args += ['-r', self.revision] | |||
args.extend([self.url, self.stage.source_path]) | |||
self.svn(*args) | |||
args.extend([self.url]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about using svn
path
(or destination) option as requested by Todd.
@@ -937,8 +967,13 @@ def fetch(self): | |||
if self.revision: | |||
args.extend(['-r', self.revision]) | |||
|
|||
args.extend([self.url, self.stage.source_path]) | |||
self.hg(*args) | |||
args.extend([self.url]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question wrt hg
destination option as for git
and svn
.
For resources, it is desirable to use the expanded archive name of the resource as the name of the directory when adding it to the root staging area. spack#11528 established 'spack-src' as the universal directory where source files are placed, which also affected the behavior of resources managed with Stages. This adds a new property ('srcdir') to Stage to remember the name of the expanded source directory, and uses this as the default name when placing a resource directory in the root staging area. This also: * Ensures that downloaded sources are archived using the expanded archive name (otherwise Spack will not be able to determine the original directory name when using a cached archive). * Updates working_dir context manager to guarantee restoration of original working directory when an exception occurs * Adds a "temp_cwd" context manager which creates a temporary directory and sets it as the working directory
Fixes spack#11816 Allow packages to refer to non-expanded downloads (e.g. a single script) using Stage.archive_file. This addresses a regression from spack#11688 and adds a unit test for it.
For resources, it is desirable to use the expanded archive name of the resource as the name of the directory when adding it to the root staging area. spack#11528 established 'spack-src' as the universal directory where source files are placed, which also affected the behavior of resources managed with Stages. This adds a new property ('srcdir') to Stage to remember the name of the expanded source directory, and uses this as the default name when placing a resource directory in the root staging area. This also: * Ensures that downloaded sources are archived using the expanded archive name (otherwise Spack will not be able to determine the original directory name when using a cached archive). * Updates working_dir context manager to guarantee restoration of original working directory when an exception occurs * Adds a "temp_cwd" context manager which creates a temporary directory and sets it as the working directory
Fixes spack#11816 Allow packages to refer to non-expanded downloads (e.g. a single script) using Stage.archive_file. This addresses a regression from spack#11688 and adds a unit test for it.
For resources, it is desirable to use the expanded archive name of the resource as the name of the directory when adding it to the root staging area.
#11528 established 'spack-src' as the universal directory where source files are placed, which also affected the behavior of resources managed with Stages.
This adds a new property to Stage to remember the name of the expanded source directory, and uses this as the default name when placing a resource directory in the root staging area.
This also:
Tests handling of exploding tarballs(Edit 6/19: this was already handled)TODOS:
Note: this does not support resources using the
go
fetch strategy, butgo
fetching logic is currently in flux anyhow and no packages currently usego
-based resources.Note: this undoes some changes from #11676 and #11667 that accommodated the behavior changes from #11528. Those changes are compatible with this PR but I removed them because they are not strictly required (and in general the purpose of this PR was to reduce the amount of work required to use resources). In terms of staging, this PR would work with the logic for
hpcviewer
before or after #11676, but thehpcviewer
changes are not undone because that PR updated the directory structure for that package build.