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

Fix the Python config #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bnikolic
Copy link
Contributor

The previous code relied on flags set at Python configuration time
rather than install time. The current flags seem to work better with
non-standard Python installations

Check with your python builds before merging

The previous code relied on flags set at Python configuration time
rather than install time. The current flags seem to work better with
non-standard Python installations
@j-woz
Copy link
Contributor

j-woz commented Jul 25, 2017

Thanks- let me think about this...

@bd4
Copy link

bd4 commented Jul 25, 2017

I tested with several python 2.7 and 3.X manual python builds - can you elaborate on which python versions and what build flags it is not working with? In particular, the output of python-config.py and how it differs from your lines would be helpful.

@bnikolic
Copy link
Contributor Author

bnikolic commented Jul 25, 2017 via email

@bd4
Copy link

bd4 commented Oct 22, 2018

I think the best solution to this issue is allow manually specifying the individual paths to override what python-config.py returns. The platinclude used by the patch has a different purpose than include - it's for platform specific header files. In most cases it is the same as include, but may not always be. I have no idea why it is somehow based on the moved location while include is not. It could be an idiosyncrasy and/or bug of the third part application, or specific to the way sysconfig works in certain versions of python. It's definitely not clearly documented anywhere, so this behavior could change. Rather than trying to support each exotic case that comes up, I think we should just provide a manual python setup that can support anything.

@bd4
Copy link

bd4 commented Oct 22, 2018

Hmm actually it looks like sysconfig.get_paths() may reliably give the correct values with/without relocation across versions. Works in 2.7.15 and 3.4.9 at least. Further testing is needed, but this may be achievable with simple changes to the python-config.py script.

bd4 added a commit to bd4/swift-t that referenced this pull request Oct 23, 2018
@bd4
Copy link

bd4 commented Oct 23, 2018

Note that the official python-config script does not adapt to the installation being relocated, at least not in 2.7.15 and 3.4.9. I can't remember the exact reason I wrote a custom config rather than use the official script - I think it may have been related to ease of finding the python executable from within spack (which AFAIK does not have a config value for the path to the desired python-config script), and possibly because of inconsistencies between versions / distributions.

@bd4
Copy link

bd4 commented Oct 23, 2018

@bnikolic sorry for the delay on this. Do you still have access to the application with it's own python? I'd be interested to see the out put of ldd on the python executable. I'm trying to understand how relocatable pythons are typically built, in my testing so far you have to pass the right LDFLAGS rpath to make it work without setting LD_LIBRARY_PATH - do you need to set LD_LIBRARY_PATH for the turbine build to work?

For reference, I configured python like this:

./configure --prefix=/opt/python/2.7.15 --enable-shared LDFLAGS=-Wl,-rpath,\'\$\$ORIGIN/../lib\'

getting the escaping right was tricky. A static rpath, e.g. /opt/python/2.7.15/lib, should work too, but would break when relocated, hence the $ORIGIN hack with the lovely multi level escaping.

@bnikolic
Copy link
Contributor Author

bnikolic commented Oct 24, 2018 via email

@bnikolic
Copy link
Contributor Author

bnikolic commented Oct 24, 2018 via email

@bd4
Copy link

bd4 commented Oct 24, 2018

Thanks, adding --enable-new-dtags to linker flags appears to switch from RPATH to RUNPATH, so I can build similar python binaries to test with:

./configure --prefix=/opt/python/3.4.9 --enable-shared LDFLAGS=-Wl,-rpath,\'$$ORIGIN/../lib\',--enable-new-dtags

@bnikolic
Copy link
Contributor Author

bnikolic commented Nov 11, 2018

I can confirm this builds correctly now (and runs)

@bd4
Copy link

bd4 commented Nov 12, 2018

Great thanks for checking @bnikolic , we'll go ahead and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants