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

Added customization for make targets in 'build' and 'install' phases for CMakePackage #2742

Merged
merged 12 commits into from
Jan 16, 2017

Conversation

adamjstewart
Copy link
Member

Does the exact same thing as #2464 but for CMakePackage.

In #2602, @fedepad asked how to run custom build targets in CMakePackage. This PR adds that functionality. For espressopp, I believe this would look like:

build_targets = ['all', 'docs']

@adamjstewart
Copy link
Member Author

adamjstewart commented Jan 4, 2017

Also allows AutotoolsPackages to be built in a different directory. Some packages like mozjs require this. All 3 build systems should be much more uniform now.

Copy link
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

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

I'll have time later in the day to try this PR, but at a first glance I agree with all the changes.

@adamjstewart
Copy link
Member Author

Things may need to be made a little more robust. There are two situations I envision:

  1. configure exists in the root directory, but must be run from a different directory
  2. configure exists in a sub-directory, like src

We should make sure that both work.

@alalazo
Copy link
Member

alalazo commented Jan 5, 2017

@adamjstewart Do you know any relevant package that does 2? Because from this to have multiple configure in the same tarball the step is tiny...

@adamjstewart
Copy link
Member Author

tk is a good example of 2. The configure script is located in the unix directory.

@adamjstewart
Copy link
Member Author

@alalazo I got the tk/tcl example working. Just had to do some minor tweaks. Confirmed that "normal" packages like zlib still work. All changes are attached to this PR so you can see what it would look like for other packages.

@adamjstewart
Copy link
Member Author

adamjstewart commented Jan 8, 2017

This introduces a strange new bug. When I configure m4, it creates a GNUMakefile file, which is a symlink to itself. make calls this file:

==> 'make' '-j4'
make: GNUmakefile: Too many levels of symbolic links
make: stat: GNUmakefile: Too many levels of symbolic links
make: *** No rule to make target `GNUmakefile'.  Stop.

Looks like it was something in the 782d8b9 commit that caused this change. The only difference in the log file is that it now runs /absolute/path/to/configure instead of ./configure, but I can't reproduce the bug by doing that outside of Spack.

EDIT: I think the problem is that the build directory is a symlink, and it's trying to create a symlink from there, and it's running into an infinite loop of recursion. No idea how to prevent that. I'm surprised my change caused such a serious problem.

EDIT: According to http://gumstix.8.x6.nabble.com/GNUmakefile-too-many-levels-symbolic-links-td665281.html, the problem may be because we are building in a symlinked directory:

Is your tmp directory a symbolic link or have you manually created any symbolic links within tmp? Regrettably, it is not possible to have a symbolically linked tmp directory; this is a known bug with the OpenEmbedded build system.

@adamjstewart adamjstewart changed the title Added customization for make targets in 'build' and 'install' phases for CMakePackage [WIP] Added customization for make targets in 'build' and 'install' phases for CMakePackage Jan 8, 2017
@adamjstewart
Copy link
Member Author

Ok, I backed out the changes that allowed you to run a configure script in a different directory. I don't think absolute paths will work if the directory is symlinked, so we could possibly get away with relative paths, but I decided we don't need it enough right now.

Confirmed that tcl and tk build with these changes. Building espressopp now.

@adamjstewart adamjstewart removed the WIP label Jan 9, 2017
@adamjstewart adamjstewart changed the title [WIP] Added customization for make targets in 'build' and 'install' phases for CMakePackage Added customization for make targets in 'build' and 'install' phases for CMakePackage Jan 9, 2017
@adamjstewart
Copy link
Member Author

Tried building espressopp +ug +pdf +dg but it crashed with the following error message:

Running Sphinx v1.4.5
making output directory...
Warning: numpy module not available
WARNING: sphinx.ext.pngmath has been deprecated. Please use sphinx.ext.imgmath instead.

Extension error:
Could not import extension matplotlib.sphinxext.only_directives (exception: No module named matplotlib.sphinxext.only_directives)

I don't think this is related to my changes. @fedepad @junghans Any idea what is causing this to fail?

@fedepad
Copy link

fedepad commented Jan 9, 2017

@adamjstewart but the package itself is compiled ok (no doc)? Since what you report regards building of the doc, in particular the user doc. I never seen this on my machine but this sphinx-doc/sphinx#1684 seems to mention matplotlib should be installed since one of sphinx extension is using it...in this case we should add matplotlib as a dependencies when building user doc... @junghans Ideas? We could try that...

@fedepad
Copy link

fedepad commented Jan 9, 2017

@adamjstewart would you try adding the following lines:
depends_on('py-matplotlib', when="+ug")
depends_on('py-matplotlib', when="+pdf")
and see what happens? I'm not sure about the type of this dependency and not sure we need the second line I wrote.

@fedepad
Copy link

fedepad commented Jan 9, 2017

@junghans and because of the warning on numpy I wonder whether we need numpy too...

@adamjstewart
Copy link
Member Author

I'll try that now. Btw, the changes I made require me to run the entire installation in serial, not just the documentation building steps. I'm not sure if that makes this change worth it for this particular package. Thoughts?

@junghans
Copy link
Contributor

junghans commented Jan 9, 2017

Yes, numpy is used in the tutorial and src/external in the docker container, we install it, too:
https://github.com/espressopp/buildenv/blob/master/ubuntu#L3
to build the documentation.

@citibeth
Copy link
Member

citibeth commented Jan 9, 2017 via email

@fedepad
Copy link

fedepad commented Jan 9, 2017

@adamjstewart I've experienced that building espressopp is usually kind of slow so I usually turn on a parallel build, which I highly suggest, so I'm not sure if it makes sense in this case, but maybe @junghans had other experience...

@junghans Ok, then we need to update and add those dependencies I mentioned for building the docs ;)

@junghans
Copy link
Contributor

junghans commented Jan 9, 2017

@fedepad: Yeah, parallel builds work in espresso++. Shouldn't spack build everything in parallel by default?

@adamjstewart
Copy link
Member Author

Shouldn't spack build everything in parallel by default?

Yes, but my changes replaced your build override with a list of build targets. Since I could no longer specify parallel=False per-build, I had to specify it for the entire package.

I'll back out that particular change. I agree that building in parallel is way faster. I was able to confirm that my new build_targets list does work as expected though, so that's good.

@fedepad
Copy link

fedepad commented Jan 9, 2017

@junghans you can configure it, whether parallel or serial. What @adamjstewart was referring to is that bringing the changes proposed in this PR to Espresso++ (with the modification proposed in one of the commits) will require to run a serial build. Did I understood correctly?

@adamjstewart
Copy link
Member Author

Ok, with the latest commit, the package now builds in parallel. I added the numpy and matplotlib dependencies, and it gets farther in the documentation building steps, but now crashes with:

! Package keyval Error: pdfencoding undefined.

See the keyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.2238 \ProcessKeyvalOptions{Hyp}

Must be some LaTeX package that's missing as a dependency.

I think this PR is safe to merge now. I'll let @fedepad and @junghans work out the details of the documentation builds in another PR.

@fedepad
Copy link

fedepad commented Jan 9, 2017

@adamjstewart @junghans I might have an idea of what's going on. It might be doxygen using the new key pdfencoding in the hyperref latex package. So a probable solution might be to have an updated texlive and requiring the live version (the only one in spack).
@adamjstewart Can you tell me if you ran it on your local machine and which version of texlive and doxygen you had? Highly appreciated, thanks!

@adamjstewart
Copy link
Member Author

So a probable solution might be to have an updated texlive and requiring the live version (the only one in spack).

Aren't texlive and doxygen already dependencies of espressopp? Shouldn't it be picking them up from the PATH?

@adamjstewart Can you tell me if you ran it on your local machine and which version of texlive and doxygen you had?

I ran this on our cluster.

$ tex --version
TeX 3.141592 (Web2C 7.5.6)
kpathsea version 3.5.6
Copyright 2007 D.E. Knuth.
Kpathsea is copyright 2007 Karl Berry and Olaf Weber.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the TeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the TeX source.
Primary author of TeX: D.E. Knuth.
Kpathsea written by Karl Berry, Olaf Weber, and others.

$ doxygen --version
1.6.1

@adamjstewart
Copy link
Member Author

Ping @tgamblin

"""
return []

def cmake(self, spec, prefix):
"""Run cmake in the build directory"""
options = [self.root_cmakelists_dir()] + self.std_cmake_args + \
self.cmake_args()
create = not os.path.exists(self.build_directory())
with working_dir(self.build_directory(), create=create):
with working_dir(self.build_directory(), create=True):
Copy link
Member

Choose a reason for hiding this comment

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

@adamjstewart Will this work in case the build directory already exists?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I believe so. I'll have to check how we define working_dir, but if I remember correctly it only creates the directory if it doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like it calls mkdirp, which does indeed check to see whether or not the directory exists first, so we can set create=True and not worry.

@adamjstewart
Copy link
Member Author

Ping ping @tgamblin

@tgamblin tgamblin merged commit f480e34 into spack:develop Jan 16, 2017
@adamjstewart adamjstewart deleted the features/cmake-build-targets branch January 20, 2017 15:05
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.

None yet

6 participants