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

RPATH with Python and virtualenv #2076

Open
rjeschmi opened this issue Jan 5, 2017 · 21 comments
Open

RPATH with Python and virtualenv #2076

rjeschmi opened this issue Jan 5, 2017 · 21 comments
Milestone

Comments

@rjeschmi
Copy link
Contributor

rjeschmi commented Jan 5, 2017

One use case I'd like to see work is to have a version of Python that works properly with virtualenv without

after compiling Python with --rpath I can see that RPATH is set with readelf:

0x000000000000000f (RPATH) Library rpath: [$ORIGIN/../lib:$ORIGIN/../lib64:/software/software/Core/GCCcore/4.9.3/lib64:/software/software/Core/GCCcore/4.9.3/lib:/software/software/Compiler/GCC/4.9.3-2.25/OpenBLAS/0.2.15-LAPACK-3.6.0/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/ScaLAPACK/2.0.2-OpenBLAS-0.2.15-LAPACK-3.6.0/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/FFTW/3.3.4/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/bzip2/1.0.6/lib:/software/software/Core/zlib/1.2.8/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/libreadline/6.3/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/ncurses/6.0/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/SQLite/3.9.2/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/Tk/8.6.4-no-X11/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/GMP/6.1.0/lib:/software/software/Core/GCCcore/4.9.3/lib64/../lib64:/software/software/Core/GCCcore/4.9.3/lib/../lib64:/software/software/Core/GCCcore/4.9.3/lib/gcc/x86_64-unknown-linux-gnu/4.9.3:/software/software/Core/GCCcore/4.9.3/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/../../../../lib64:/software/software/Core/binutils/2.25/lib:/software/software/MPI/GCC/4.9.3-2.25/OpenMPI/1.10.2/Tcl/8.6.4/lib:/software/software/Compiler/GCC/4.9.3-2.25/OpenMPI/1.10.2/lib:/software/software/Compiler/GCC/4.9.3-2.25/hwloc/1.11.2/lib:/software/software/Compiler/GCC/4.9.3-2.25/numactl/2.0.11/lib:/software/software/Core/GCCcore/4.9.3/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/../../..]


[rob@ottbioinfo venv]$ ./py-eb/bin/python --version
Python 2.7.5
[rob@ottbioinfo venv]$ ldd py-eb/bin/python
linux-vdso.so.1 => (0x00007ffc017b3000)
libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007efdd4b32000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007efdd492d000)
libm.so.6 => /lib64/libm.so.6 (0x00007efdd462b000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007efdd440f000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007efdd420b000)
libc.so.6 => /lib64/libc.so.6 (0x00007efdd3e49000)
/lib64/ld-linux-x86-64.so.2 (0x00007efdd4f02000)

@boegel boegel added this to the 3.1.0 milestone Jan 7, 2017
@boegel
Copy link
Member

boegel commented Jan 7, 2017

@rjeschmi What kind of specific errors are you running into with virtualenv when a Python that includes an RPATH on $ORIGIN/../lib and $ORIGIN/../lib64?

I think the only way around this is to avoid using $ORIGIN, and just inject the actual installation prefix + /lib in there instead.

Interestingly, Spack is actually considering switching to $ORIGIN (rather than hardcoding the installation prefix) to make installations easier to relocate, see spack/spack#640 .

@boegel
Copy link
Member

boegel commented Jan 7, 2017

@pescobar You should be aware of this... (virtualenv is broken when Python was installed with RPATH the way it is implemented now)

@pescobar
Copy link
Member

pescobar commented Jan 9, 2017

@rjeschmi thanks for pointing this.

This is a blocker for me because my users do heavy usage of virtualenvs. I am thinking if I should totally stop using rpath or just use the rpath skip-out option to build python.

I guess a similar issue can happen if users install R packages to their home folder and R has been linked with rpath, isn't it?

@rjeschmi
Copy link
Contributor Author

rjeschmi commented Jan 9, 2017

@pescobar after talking online with you I don't think it changes the behaviour for you vs regular easybuild right now.

I don't think it will effect any other packages either. It is just a relocation peculiarity and if you have LD_LIBRARY_PATH set, it will still work fine (just RPATH isn't doing the work)

@pescobar
Copy link
Member

pescobar commented Jan 9, 2017

@rjeschmi thanks for the explanation in the irc channel ;)

As you mention, this issue would not affect my specific use case because I still define LD_LIBRARY_PATH in my modules but I agree that getting virtualenvs to work without needing any extra env var would be nice

@boegel
Copy link
Member

boegel commented Jan 9, 2017

@rjeschmi Do you see any reason to just stop using $ORIGIN and just hard-code the installation path instead?

Especially w.r.t. Spack considering to move to $ORIGIN...

@boegel
Copy link
Member

boegel commented Jan 10, 2017

Relevant to this discussion is @ocaisa's comment in easybuilders/easybuild#282 (comment)

@rjeschmi
Copy link
Contributor Author

The only reason to use $ORIGIN is if you are going to support relocation. I don't mind it in theory, but it should be a further experimental option.

@ocaisa
Copy link
Member

ocaisa commented Jan 27, 2017

Isn't the installation step itself usually a relocation? What if the application requires loading of it's own .so libraries (like Qt does)? If installation is a relocation then you can only ensure they are loaded correctly by using $ORIGIN

@boegel
Copy link
Member

boegel commented Jan 27, 2017

So, that would mean building Qt with --rpath would be broken if we switch from $ORIGIN/../lib to RPATH'ing <prefix>/lib instead?

@ocaisa
Copy link
Member

ocaisa commented Jan 27, 2017

No it wouldn't most likely...but that's assuming that your choice of location is actually the correct one

@boegel
Copy link
Member

boegel commented Jan 27, 2017

@tgamblin Any thoughts on this on the benefits over RPATH'ing $ORIGIN/../lib vs <prefix>/lib?
Especially w.r.t. spack/spack#640

@ocaisa
Copy link
Member

ocaisa commented Jan 27, 2017

To me, one for the other is a straight swap so I say go with hard-coding as the default but allow people to switch to $ORIGIN if they want (or as needed).

@tgamblin
Copy link

I'd just use prefix here. If you look at the RPATH on the Python binary, it has tons of absolute paths to dependencies anyway, so $ORIGIN isn't buying you relocatability. You'd have to change all those other non-ORIGIN RPATHs too if you wanted to move your EB installation.

I am not sure we'll move to relative RPATHs soon because it's hard to get right. You have to know a lot about how your build is laid out -- e.g., how many levels deep in the prefix is the library? It looks like you assume one-level deep libs here ($prefix/lib[64]), but what if your binary is in a subdirectory of lib? Then you need to know to do $ORIGIN/../.. and not just $ORIGIN/... It is hard to know the right thing to do at build time because you don't actually know where the lib will be installed.

Because it's so hard to do this in a general way, Spack probably won't move to relative RPATHs any time soon. I am thinking we could allow relocation more easily with patchelf than with $ORIGIN. See spack/spack#445.

@boegel
Copy link
Member

boegel commented Jan 27, 2017

Thanks a lot for the feedback @tgamblin! 👍

@rjeschmi
Copy link
Contributor Author

Yeah you have the advantage too that $ORIGIN/../libs will probably fit in the same space as $prefix (but less likely the other way) so patchelf should be a lot easier that direction. Also the patchelf should be relatively easy.

Definitely worth thinking about long_fake_prefix that is easy to search for as an option with a patchelf finish step (and this is all easier if the prefix is just there in the RPATH).

@tgamblin
Copy link

I believe parchelf works fine with variable-length/longer RPATHs. It's older cousin chrpath doesn't.

@boegel boegel modified the milestones: 3.1.0, 3.2.0 Jan 30, 2017
@boegel boegel modified the milestones: 3.2.0, 3.3.0 May 2, 2017
@boegel boegel modified the milestones: 3.3.0, 3.x Jun 22, 2017
@boegel boegel removed this from the 3.3.0 milestone Jun 22, 2017
@jdonners
Copy link

I agree with @tgamblin that using the absolute paths is better for libs that are installed in deeper hierarchies (I'm thinking especially shared objects for python packages here). However, I'd suggest to include $ORIGIN itself as well. E.g. ParaView installs libraries in lib/paraview-$version, which wouldn't be found otherwise.

@mzpqnxow
Copy link

I had success making this work by symlinking to lib/lib64 directories some time back, but this was done with a tool that wrapped virtualenv, not in virtualenv itself...

@morrisonlevi
Copy link

morrisonlevi commented May 8, 2018

Drive-by comment: I think $ORIGIN ought to be supported but then again I'm just a passer-by with no additional info other than it seems odd that the "better practice" doesn't work. Perhaps it ought to be considered an upstream bug, though.

@boegel
Copy link
Member

boegel commented May 8, 2018

@pescobar Is this actually still a problem? Isn't this fixed with the change made in #2358 (which is part of EasyBuild v3.5.0 & newer)?

@boegel boegel modified the milestones: 3.x, 4.x Feb 20, 2020
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

No branches or pull requests

8 participants