wlav / cppyy

Other
387 stars 39 forks source link

libcppyy_backend.so installed in the wrong location on Fedora #191

Open N-Coder opened 10 months ago

N-Coder commented 10 months ago

In a blank Fedora container, pip installing cppyy yields a non-working setup:

# docker run  -t -i --rm fedora bash
sudo dnf install python3 python3-pip python3-devel gcc g++ cmake wget
python3 -V
pip3 -V
pip3 install cppyy
python3 -c "import cppyy"
[...]
Python 3.11.5
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
[...]
Successfully installed CPyCppyy-1.12.13 cppyy-3.0.0 cppyy-backend-1.14.11 cppyy-cling-6.28.0
[...]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/cppyy/__init__.py", line 80, in <module>
    from ._cpython_cppyy import *
  File "/usr/local/lib/python3.11/site-packages/cppyy/_cpython_cppyy.py", line 21, in <module>
    c = loader.load_cpp_backend()
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cppyy_backend/loader.py", line 92, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
RuntimeError: could not load cppyy_backend library, details:
  libcppyy_backend.so: cannot open shared object file: No such file or directory
  /usr/local/lib/python3.11/site-packages/cppyy_backend/lib/libcppyy_backend.so: cannot open shared object file: No such file or directory
  /usr/local/lib/python3.11/site-packages/cppyy_backend/lib/libcppyy_backend.cpython-311-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory
  libcppyy_backend.cpython-311-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory

This is because the shared object ends up in a different location (note the lib64 instead of lib at the beginning):

# ls -l /usr/local/lib/python3.11/site-packages/cppyy_backend/lib/
total 114400
-rwxr-xr-x. 1 root root 109629984 Sep 13 10:00 libCling.so
-rw-r--r--. 1 root root      9722 Sep 13 10:00 libCoreLegacy.rootmap
-rwxr-xr-x. 1 root root   3472728 Sep 13 10:00 libCoreLegacy.so
-rw-r--r--. 1 root root      1386 Sep 13 10:00 libRIOLegacy.rootmap
-rwxr-xr-x. 1 root root   3603328 Sep 13 10:00 libRIOLegacy.so
-rw-r--r--. 1 root root       700 Sep 13 10:00 libThreadLegacy.rootmap
-rwxr-xr-x. 1 root root    407144 Sep 13 10:00 libThreadLegacy.so
# ls -l /usr/local/lib64/python3.11/site-packages/cppyy_backend/lib/
total 1868
-rwxr-xr-x. 1 root root 1912536 Sep 13 10:00 libcppyy_backend.so

Fedora uses lib for architecture-independent python modules and lib64 for extensions modules and the like, not making both folders point to the same contents via a symlink. After moving it using mv /usr/local/lib64/python3.11/site-packages/cppyy_backend/lib/libcppyy_backend.so /usr/local/lib/python3.11/site-packages/cppyy_backend/lib/libcppyy_backend.so, the cppyy installation continues to work as usual. An easy fix for this might be throwing the lib64 folder also into the default search path (or only if its no symlink to lib).

It seems that the site-packages/cppyy_backend folder is pieced together from different packages (see the following listing of packages and their corresponding files), which might be related to this.

# pip uninstall cppyy cppyy-backend cppyy-cling CPyCppyy
Found existing installation: cppyy 3.0.0
Uninstalling cppyy-3.0.0:
  Would remove:
    /usr/local/lib/python3.11/site-packages/cppyy-3.0.0.dist-info/*
    /usr/local/lib/python3.11/site-packages/cppyy/*
Proceed (Y/n)? y
  Successfully uninstalled cppyy-3.0.0
Found existing installation: cppyy-backend 1.14.11
Uninstalling cppyy-backend-1.14.11:
  Would remove:
    /usr/local/lib/python3.11/site-packages/cppyy_backend-1.14.11.dist-info/*
    /usr/local/lib64/python3.11/site-packages/cppyy_backend/lib/libcppyy_backend.so
Proceed (Y/n)? y
  Successfully uninstalled cppyy-backend-1.14.11
Found existing installation: cppyy-cling 6.28.0
Uninstalling cppyy-cling-6.28.0:
  Would remove:
    /usr/local/bin/cling-config
    /usr/local/bin/cppyy-generator
    /usr/local/bin/genreflex
    /usr/local/bin/rootcling
    /usr/local/lib/python3.11/site-packages/cppyy_backend/*
    /usr/local/lib/python3.11/site-packages/cppyy_cling-6.28.0.dist-info/*
Proceed (Y/n)? y
  Successfully uninstalled cppyy-cling-6.28.0
Found existing installation: CPyCppyy 1.12.13
Uninstalling CPyCppyy-1.12.13:
  Would remove:
    /usr/include/python3.11/CPyCppyy/API.h
    /usr/include/python3.11/CPyCppyy/CommonDefs.h
    /usr/include/python3.11/CPyCppyy/DispatchPtr.h
    /usr/include/python3.11/CPyCppyy/PyException.h
    /usr/include/python3.11/CPyCppyy/PyResult.h
    /usr/include/python3.11/CPyCppyy/Reflex.h
    /usr/include/python3.11/CPyCppyy/TPyArg.h
    /usr/local/lib64/python3.11/site-packages/CPyCppyy-1.12.13.dist-info/*
    /usr/local/lib64/python3.11/site-packages/libcppyy.cpython-311-x86_64-linux-gnu.so
Proceed (Y/n)? y
  Successfully uninstalled CPyCppyy-1.12.13