py-cdat-lite: ensure that RPATH includes netcdf#4521
py-cdat-lite: ensure that RPATH includes netcdf#4521adamjstewart merged 1 commit intospack:developfrom
Conversation
adamjstewart
left a comment
There was a problem hiding this comment.
You should also consider using import_tests. That way, when you run spack install --run-tests py-cdat-lite, it will try to import cdms2 and crash if RPATH wasn't working properly. There's a bug where if you override phases you have to redefine tests, but I can help you with that.
| """Install everything from build directory.""" | ||
| install_args = self.install_args(spec, prefix) | ||
| # Combine all phases into a single setup.py command, | ||
| # otherwise extensions are rebuilt without rpath by install phase: |
There was a problem hiding this comment.
Wait, really? I wouldn't expect that behavior. Maybe I'll have to test this one.
Btw, could this routine theoretically be used to install any Python package? Like in PythonPackage can we always run this sequence of commands, and is --rpath always available? If that is the case, we could solve the problem you've been seeing by always adding link dependencies to the --rpath.
There was a problem hiding this comment.
Hi @adamjstewart , I think the need to combine phases is limited to this package. I didn't have the same trouble with py-pillow.
I think the --rpath option is part of py-setuptools, but it is only available for the build_ext phase. So to use it generally, we would have to include the build_ext phase by default.
Perhaps the more general solution would be to rely on the spack compiler wrappers to set rpath. But the wrappers are deliberately replaced by references to the real compilers during the python installation procedure. The reason seems to be to allow users to install their own packages without spack.
I am wondering if we need a way to run actual compiler versions outside of spack while still making use of the spack wrappers to define rpath correctly. For example, when a package like python is installed, the associated compiler could be represented by a wrapper script inside the python package. Then when python extensions are installed, the python compiler would invoke the correct compiler via the spack compiler wrappers, so that rpath and other search paths would always be set correctly. Does that idea make any sense?
There was a problem hiding this comment.
otherwise extensions are rebuilt without rpath by install phase:
I figured out how to prevent this:
$ python setup.py install --skip-build
I'll add this to the default install phase.
There was a problem hiding this comment.
Hmm, I don't know if --skip-build does what I think it does. According to the help message:
$ python setup.py install --help
...
--skip-build skip rebuilding everything (for
testing/debugging)
I figured that this meant I could run:
$ python setup.py build
$ python setup.py install --skip-build
and separate out the logic, but this doesn't work at all for py-numpy. The build phase doesn't actually do much of anything, and the install phase crashes when I use --skip-build. So I won't be adding --skip-build. Guess I'll have to investigate this a bit more.
|
Hi again @adamjstewart , one other issue I came across was that the |
|
@mjwoods I'll fix the missing prefix for install_lib, etc. I'll have to do some major testing, but I think running the build_ext phase by default is a good idea. Another idea would be to unfilter the Python compiler wrappers every time a package is installed and re-filter them after, but I don't know how to do this within the current confines of Spack. |
|
@mjwoods It looks like all Python packages accept I looked at |
|
I was looking for a way to specify the compiler to use but I think distutils chooses the compiler Python was built with no matter what you do. The closest thing I could find was: but that doesn't seem to accept paths, only the name of the compiler family: |
|
Re: #4521 (comment) I found lists of options for each install method by running commands like I considered using the separate installation methods when I found that |
|
Re: #4521 (comment) I think that refiltering the python compiler wrappers would be difficult to do reliably. For example, multiple packages could be installed simultaneously, leading to a race-condition. And we would need to restore the wrappers after various interruptions too. |
|
#4545 is taking longer than I would like so I'm going to merge this PR in the meantime. |
In py-cdat-lite, the netcdf library was not being found during
import cdms2(unless a suitable library was installed in a system directory). I now set the RPATH explicitly in the install method of the package.