-
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
Packages can tune the list of files to be archived at the end of install #7760
Packages can tune the list of files to be archived at the end of install #7760
Conversation
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.
One variable name nitpick and failing to archive files should only happen in very rare cases... I'm not sure if we should suppress the exception.
But don't consider these remarks blocking
lib/spack/spack/package.py
Outdated
with working_dir(self.stage.source_path): | ||
for glob_expr in self.archive_files: | ||
files = glob.glob(glob_expr) | ||
for file in files: |
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.
typically we try to avoid overriding builtin functions. Not sure how critical this is though...
lib/spack/spack/package.py
Outdated
# Here try to be conservative, and avoid discarding | ||
# the whole install procedure because of copying a | ||
# single file failed | ||
tty.warn("FAILED ARCHIVE: {0}".format(file)) |
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.
failing to copy a file to a place we control means that something bad happened... maybe this should be a configurable option?
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 this should get recorded in the .spack
directory rather than spit out as a warning. Maybe keep track of what was missing and spit out one warning and write .spack/missing.txt
at the end?
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 am detecting two kinds of errors:
- Glob expressions that are relative to folders outside the source path
- Errors when copying a matching file
They'll be recorded in .spack/archived-files/errors.txt
. In case there's any error, we print a warning and point the user to that file.
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.
Oh wait, shouldn't these prepend self.build_directory
? There are quite a few packages that override the defaultbuild_directory
:
$ grep -l build_directory */package.py | xargs grep -l AutotoolsPackage
adios/package.py
autoconf/package.py
automake/package.py
berkeley-db/package.py
bison/package.py
coreutils/package.py
datamash/package.py
elpa/package.py
gawk/package.py
gcc/package.py
gmake/package.py
gnutls/package.py
guile/package.py
hpx5/package.py
ipopt/package.py
libtool/package.py
log4cxx/package.py
m4/package.py
mosh/package.py
mozjs/package.py
patch/package.py
python/package.py
swig/package.py
tcl/package.py
wget/package.py
yambo/package.py
$ grep -l build_directory */package.py | xargs grep -l CMakePackage
catalyst/package.py
cbtf-argonavis/package.py
cbtf-krell/package.py
cbtf-lanl/package.py
cbtf/package.py
clamr/package.py
funhpc/package.py
googletest/package.py
llvm/package.py
metis/package.py
openspeedshop/package.py
pfunit/package.py
phist/package.py
py-espressopp/package.py
qmcpack/package.py
rr/package.py
simulationio/package.py
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.
Some nitpicks.
lib/spack/spack/package.py
Outdated
# Here try to be conservative, and avoid discarding | ||
# the whole install procedure because of copying a | ||
# single file failed | ||
tty.warn("FAILED ARCHIVE: {0}".format(file)) |
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 this should get recorded in the .spack
directory rather than spit out as a warning. Maybe keep track of what was missing and spit out one warning and write .spack/missing.txt
at the end?
@@ -94,6 +94,9 @@ class AutotoolsPackage(PackageBase): | |||
#: Options to be passed to autoreconf when using the default implementation | |||
autoreconf_extra_args = [] | |||
|
|||
#: Files to archive for packages based on autotools | |||
archive_files = ['config.log'] |
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.
This will be wrong for some packages because config.log is typically relative to where configure runs. But we know that -AutotoolsPackage has vars for it. Should we allow substitutions?
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.
@adamjstewart @tgamblin Absolutely right. I have extended this behavior, and now defaults should be treated correctly even for packages that override build_directory
@adamjstewart @tgamblin The non-exceptional paths should be hit during the build tests on Travis. Was wondering if:
Let me know what do you think. |
@tgamblin ping |
To be clear, are you saying that it could print an error message if config.log isn't found where it is expected? That would be useful but not required.
IMO this would be worthwhile as long as it is simple: you could add a mock package definition to the test package repo (and the |
fixes spack#2781 This PR introduces a new attribute for packages that contains a list of glob expressions. Any file that matches will be archived in the `<prefix>/.spack/archived-files` directory. `AutotoolsPackage` and `CMakePackage` provide a sensible default override for this attribute.
The glob expressions that can be used in the `archive_files` list now are also allowed to be absolute. The errors that may occur when archiving custom files are collected and reported in a file named `errors.txt`.
ce8580f
to
d084326
Compare
This ensures that errors when archiving files are recorded into .spack/archived-files/errors.txt
@tgamblin @scheibelp I added unit tests, let me know if you think other cases should be tested or if there are other changes to be done in this PR. |
@@ -54,6 +54,10 @@ class A(AutotoolsPackage): | |||
|
|||
depends_on('b', when='foobar=bar') | |||
|
|||
@property |
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.
@alalazo I really appreciate the addition of the unit test. In my opinion though it would be worthwhile to create a new mock package for testing. Although this creates some redundancy, I think it avoids potential issues with confusing the purpose of unit tests when multiple tests use the same mock package. If that seems sensible to you then I'll wait for this to be separated out; otherwise let me know and I'll check with other folks internally to see if there's a general consensus (if most folks disagree with me I'll accept this as is).
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.
@scheibelp I'll create a new mock package, no worries. Usually I reuse what's there because adding new mock packages requires more lines than I would like.
If that seems sensible to you then I'll wait for this to be separated out;
👍
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.
@scheibelp done
Thanks! |
fixes #2781
This PR introduces a new attribute for packages that contains a list of glob expressions. Any file that matches will be archived in the
<prefix>/.spack/archived-files
directory.AutotoolsPackage
andCMakePackage
provide a sensible default override for this attribute.