-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix Linux library search path #519
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
Conversation
Looks like the library is only found on one of the linux configurations on Travis, but not on the others. Perhaps it's a virtualenv issue and could be resolved similarly to the Windows path? (See |
It's not a virtualenv issue. FindPythonLibsNew is really, really broken on a modern Debian/Ubuntu system (e.g. it really isn't valid to guess that I'm trying to look at the history for it, and I read through the rational in #207. While I think most of those changes were great, I think using FindPythonLibsNew introduced some serious regressions in FindPythonLibs that have been long-since fixed in cmake's upstream FindPythonLibs. (FindPythonLibs in current cmake correctly finds the arch-specific library). The useful part of FindPythonLibsNew seems, mainly, to be in providing |
As for the issue in #99, it looks like that would be solved by making sure we call
The code prior to #207 was doing this in the reverse order, which seems likely to be what led to #99. |
Thee default CMake Asking Python for where stuff is -- i.e. the approach taken by Looking at the PR, thing I'm wondering is whether we even need set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib64" "${PYTHON_PREFIX}/lib" "${PYTHON_LIBRARY_PATH}") (and similar a few lines below) |
@jagerman At first glance, it does seem like the following should work: find_package(PythonInterp)
find_package(PythonLibs PYTHON_VERSION EXACT REQUIRED) And I really really wish it did. It would have saved me so many headaches. The issue is that the two find modules work completely independently with only a common version number. But it's easy to install two Python distributions with the exact same version number (e.g. on Linux, you can have the system python and conda). In that case This is especially problematic on macOS because it's very common to install Python from homebrew instead of using the bundled system variant. CMake will happily find the homebrew exe because it's first in the path, but by default it will return the system lib, thus requiring manual intervention. It becomes even worse if you have 3 different distributions installed (system, homebrew, conda -- all needed for testing) in which case the default CMake scripts will really go nuts. This has not changed even with the newer CMake versions. There is an additional layer to this on Windows where 32-bit and 64-bit variants of Python are still used. The default CMake scripts can again return a mismatched library because it only looks at the version -- There are probably other issues here that I'm forgetting... or selectively erasing from memory because of how frustrating the whole thing was to deal with (for a cross-platform, Python-distribution agnostic build system).
Sorry for the lengthy rant. Back to the issue at hand: the Python executable should have a good hint at where the library is. Perhaps |
@dean0x7d Thanks for the lengthy description; I appreciate the problems. I think the right places to look are:
where the first one is only checked if MULTIARCH is set. |
(PR incoming) |
Closing in favor of #523. |
@jagerman Thanks for resolving it. |
This fixes issue #516 by getting the path to the python library from sysconfig.