Skip to content
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

Merged

Conversation

alalazo
Copy link
Member

@alalazo alalazo commented Apr 14, 2018

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 and CMakePackage provide a sensible default override for this attribute.

Copy link
Contributor

@healther healther left a 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

with working_dir(self.stage.source_path):
for glob_expr in self.archive_files:
files = glob.glob(glob_expr)
for file in files:
Copy link
Contributor

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...

# 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))
Copy link
Contributor

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?

Copy link
Member

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?

Copy link
Member Author

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:

  1. Glob expressions that are relative to folders outside the source path
  2. 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.

Copy link
Member

@adamjstewart adamjstewart left a 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

Copy link
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks.

# 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))
Copy link
Member

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']
Copy link
Member

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?

Copy link
Member Author

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

@alalazo
Copy link
Member Author

alalazo commented Apr 15, 2018

@adamjstewart @tgamblin The non-exceptional paths should be hit during the build tests on Travis. Was wondering if:

  1. We should add a check there to ensure that config.log and CMakeLists.txt are in the correct place
  2. We should add tests (how?) also for the exceptional paths

Let me know what do you think.

@alalazo
Copy link
Member Author

alalazo commented Apr 20, 2018

@tgamblin ping

@scheibelp
Copy link
Member

was wondering if...
We should add a check there to ensure that config.log and CMakeLists.txt are in the correct place

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.

We should add tests (how?) also for the exceptional paths

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 install method could create the test files which need to be moved). Beyond line coverage I think that would be useful to add a test which confirms that the archive_files specified by a package are saved when they are available. Let me know if that seems like more effort than it's worth or unclear.

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`.
@alalazo alalazo force-pushed the features/copy_config_log_in_prefix branch from ce8580f to d084326 Compare May 5, 2018 13:22
This ensures that errors when archiving files are recorded into
.spack/archived-files/errors.txt
@alalazo
Copy link
Member Author

alalazo commented May 5, 2018

@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
Copy link
Member

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).

Copy link
Member Author

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;

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scheibelp done

@scheibelp scheibelp dismissed tgamblin’s stale review May 9, 2018 00:32

Requests are now addressed

@scheibelp scheibelp merged commit b4859e1 into spack:develop May 9, 2018
@scheibelp
Copy link
Member

Thanks!

@alalazo alalazo deleted the features/copy_config_log_in_prefix branch May 9, 2018 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy config.log to install directory
6 participants