The cmake-3.0.0-FindBoost-python.patch sets the $PYTHON_EXECUTABLE to "python". If FindPythonLibs is called after FindPackage( Boost ... python ) it throws an error because it expects $PYTHON_EXECUTABLE to be a path. A simple fix would be to unset $PYTHON_EXECUTABLE after we are done with it.
Created attachment 467874 [details, diff] unsets PYTHON_EXECUTABLE in FindBoost.cmake
Can you provide an example how this can be triggered?
Created attachment 467910 [details] Minimal CMake example to trigger the bug Without my patch this example CMakeLists.txt will error out. With my patch it will be fine. But I just realized unset PYTHON_EXECUTABLE should only happen when it was not set previously. In the case someone has find_package(PythonLibs) before find_package(Boost ... python) this would unset previously discovered PYTHON_EXECUTABLE
I agree, we shouldn't pollute the environment like this.
Created attachment 468026 [details, diff] FindBoost-python.patch Suggested new version of FindBoost-python.patch
Interesting part of diff between patches: + if(${COMPONENT} STREQUAL "python" OR ${COMPONENT} STREQUAL "mpi_python") -+ # Get version of Python. -+ if (NOT PYTHON_EXECUTABLE) -+ #if a certain version of python was detected by cmake before use that one -+ set(PYTHON_EXECUTABLE "python") -+ endif (NOT PYTHON_EXECUTABLE) -+ execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write('.'.join(str(x) for x in sys.version_info[:2]))" OUTPUT_VARIABLE _python_version) ++ # If a certain version of python has already been selected ensure we select the corresponding boost python version. ++ if(PYTHON_EXECUTABLE) ++ set(GENTOO_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") ++ else() ++ set(GENTOO_PYTHON_EXECUTABLE "python") ++ endif() ++ execute_process(COMMAND "${GENTOO_PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write('.'.join(str(x) for x in sys.version_info[:2]))" OUTPUT_VARIABLE _python_version) + endif()
commit c61eff3f68a45d5b25653c8022f97634fab20f36 Author: Lars Wendler <polynomial-c@gentoo.org> Date: Thu Mar 23 13:01:05 2017 dev-util/cmake: Attempt to fix FindBoost-python patch (bug #613442). Package-Manager: Portage-2.3.5, Repoman-2.3.2 Please report back if that fixes your issue.
The bug in the minimal example doesn't occur with the patch. And that the exact thing that triggers the bug. Nice work!