python-bindings
python-bindings copied to clipboard
Installing with pip requires call to ldconfig if preCICE is built from source
I built preCICE from source yesterday (on Linux Mint, with parameters suggested here) and installed it succesfully, but then, running pip install --user pyprecice
generates an error libprecice.so.2 not found
. Running sudo ldconfig
before running pip is enough to fix it.
The issue doesn't appear if we install a .deb
package for libprecice. I noticed that the post-installation script of the .deb does include a call to sudo ldconfig
, which explains a lot.
Suggested fix : Either add a call to ldconfig in the installation instructions (on the website) or the the install script (probably hard, since ldconfig requires superuser, it would break install into a user-chosen path without superuser). Unless something is wrong on the binding side, but I doubt it.
@BenjaminRodenberg Is this an installation procedure we missed? I normally install all (preCICE + bindings) from source. I do this either by hand or via Spack and never ran into this problem so far.
I do have to manually call ldconfig
too when I install preCICE in our container stack. If you need a reproducer, this dockerfile could be trimmed further.
@boris-martin when building any library from source (i.e., not installing it via a system package manager, such as APT), the system needs to know where to find it. There are a few ways to do that:
- Copy the library to a path known by the system to contain libraries (i.e., installing it). Usually these are paths that require root access to write to, hence the
sudo
. - Tell the system (the linker,
ld
), that there are additional places to look for libraries.
The linker looks for libraries in specific paths, using ldconfig
. There is a list of these paths in /etc/ld.so.conf
(or starting from that). When installing a system package, we usually call ldconfig
(as root) to update the cache of what libraries are available where. However, this is not really possible in systems without root access, where package managers such as Spack become very useful.
The linker also looks in paths defined by LD_LIBRARY_PATH
and this is one of the options we give to the user to link to preCICE. Some resources argue that this is not a very good practice, but it is quite common and works.
I always build preCICE from source (on Ubuntu, which should be the same as Mint) and I never need to manually run ldconfig
, becuase I extend my LD_LIBRARY_PATH
in my ~/.bashrc
. How and where have you defined these variables?
My bad, never read that part of the documentation. Replacing the call to ldconfig by something like export LD_LIBRARY_PATH=/usr/local/lib/
does work as intended. My bad !
However the documentation for linking shows this as troubleshooting while it would happend every time, so maybe it should be more visible ?
Or maybe put on the binding doc that correct linking is required ?
@boris-martin: If you have a more visible place in mind where we should post this information, feel free to edit the README.md
and open a PR. I remember putting it under troubleshooting just to have it documented somewhere without thinking a lot about it.
@BenjaminRodenberg Actually the README is fine, the problem is that when you install the binding through the website, you're told that pip install
is enough, which is not neccesarily true. I didn't think of looking here for instructions, actually
I'll probably open a PR, but it could be website related and not binding-related
It is also listed in the building from source: preparation page. But I understand that maybe this is not the right point in the workflow. Which pages did you read, in which order? Where would it make more sense for you?
We can definitely add an info-box somewhere.
@BenjaminRodenberg Actually the README is fine, the problem is that when you install the binding through the website, you're told that
pip install
is enough, which is not neccesarily true. I didn't think of looking here for instructions, actually I'll probably open a PR, but it could be website related and not binding-related
A related issue to this is https://github.com/precice/python-bindings/issues/114 which suggests a broad overhaul of the README and porting a majority of the stuff to the website for better accessibility. @MakisH would this make things clear in an overall sense keeping this issue in context?
It would definitely make sense, but I think this is an issue in the preCICE documentation, not the Python bindings documentation.