-
Notifications
You must be signed in to change notification settings - Fork 194
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
Installation path for Python bindings is not searched by the interpreter if CMAKE_INSTALL_PREFIX is /usr/local #2511
Comments
Related to robotology/robotology-superbuild#428 . Apparently for python2 the existing logic (i.e. |
The problem is that |
Given this comment I updated the title to reflect more specifically the problem, @PeterBowman feel free to change it again if you think it make sense. |
I divided my comment in different sections to simplify its readability. Why we need to use distutils.sysconfig.get_python_lib : for being platform indipendentAs for robotology-superbuild we are interesting in support both apt and conda-forge installation of Python bindings out of the box, I looked into this. On Ubuntu 20.04 apt we have:
while on Windows/conda-forge we have:
From this two cases, we can see that hardcoding the Python install path to The actual source of the problemI investigate a bit, and this seems to be more a Debian/Ubuntu problem rather then a downstream YARP problem, see https://bugs.launchpad.net/ubuntu/+source/python3-stdlib-extensions/+bug/1832215 . If the issue gets fixed as suggested in the issue (but the issue seems to have been like that for more than an year), then probably we would need to modify our logic from:
to
as the actual install prefix would depend to the value passed to the However, until the issue https://bugs.launchpad.net/ubuntu/+source/python3-stdlib-extensions/+bug/1832215 is solved, I am afraid that implementing Ubuntu-specific workarounds in the CMake may bring more problems then benefits, and so just specifying The bug we can actually quickly solveHowever:
This is an unrelated bug, for fixing that we just need to modify the line: yarp/bindings/python/CMakeLists.txt Line 47 in d02f3fd
to
|
+1 from me for fixing the destination path ( By the way, I came across this SO answer and the command |
How can this information be combined with
and the path returned by if |
You are right, I had not tested this with Conda, so I'm going to back off my words :). It seems difficult to find a unique solution that works well for all scenarios. |
Yes, it may be worth mentioning that CMake itself uses |
@traversaro I think this was fixed by #2523, right? |
Technically speaking the problem is in Ubuntu and it is tracked in https://bugs.launchpad.net/ubuntu/+source/python3-stdlib-extensions/+bug/1832215 . #2523 implement a way for user to workaround the problem, and at this point I think there is not much left to do at the YARP level. If @PeterBowman agrees, for me we can close this issue. |
@traversaro I'm sorry that I missed it, the #2523 patch should be followed by #2539 in order to fix the custom path issue. The latter PR will close this ticket 👍. Note for travellers: when passing PS quoting https://cmake.org/cmake/help/latest/manual/cmake.1.html#options:
Emphasis mine. This variable is in fact interpreted as yarp/bindings/python/CMakeLists.txt Line 32 in f593fec
|
Good catch!
Yes, I can add that specifying |
Describe the bug
YARP selects an installation path for Python bindings which the Python interpreter is not able to find out-of-the-box.
To Reproduce
Configure YARP via
cmake .. -DYARP_COMPILE_BINDINGS=ON -DCREATE_PYTHON=ON
. CMake populates the following variables with no further action on my part (inspected viaccmake
):However, binaries (
yarp.py
and_yarp.so
) are installed in the following path:CMAKE_INSTALL_PYTHON3DIR=lib/python3/dist-packages
. This will not work for me (i.e.python3 -c 'import yarp'
fails) because Python expects to find packages at/usr/local/lib/python3.8/dist-packages/
(among other paths), but note the currently configured value islib/python3/
instead.Expected behavior
Perhaps I could just tweak
PYTHONPATH
in my.bashrc
, but it would be nice to have YARP select the best path for Python packages automatically. I believe this workaround wasn't necessary in the past.Configuration
libpython3-dev
from Canonical's PPAAdditional context
I believe the
lib/python3/
path inCMAKE_INSTALL_PYTHON3DIR
originates from:yarp/bindings/python/CMakeLists.txt
Lines 32 to 35 in d02f3fd
I can tweak
CMAKE_INSTALL_PYTHON3DIR
viaccmake
, but the final installation path remains unchanged. The workaround for me consists of creating symlinks fromlib/python3.8/dist-packages/
tolib/python3/dist-packages/
, as suggested here.Possible solution (also workaround, not ideal)
Use
CMAKE_INSTALL_PYTHON3DIR
instead ofPython3_INSTDIR
here:yarp/bindings/python/CMakeLists.txt
Lines 46 to 47 in d02f3fd
yarp/bindings/python/CMakeLists.txt
Lines 62 to 63 in d02f3fd
See also
Perhaps related to some extent: #2509 (Support a user defined version of Python for YARP bindings).
The text was updated successfully, but these errors were encountered: