Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 613442 - dev-util/cmake: FindBoostPython patch pollutes environment with ${PYTHON_EXECUTABLE}
Summary: dev-util/cmake: FindBoostPython patch pollutes environment with ${PYTHON_EXEC...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo KDE team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-22 01:55 UTC by Andrej Rode
Modified: 2017-03-25 00:48 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
unsets PYTHON_EXECUTABLE in FindBoost.cmake (FindBoostPython-unset-Python.patch,671 bytes, patch)
2017-03-22 02:19 UTC, Andrej Rode
Details | Diff
Minimal CMake example to trigger the bug (CMakeLists.txt,104 bytes, text/plain)
2017-03-22 16:32 UTC, Andrej Rode
Details
FindBoost-python.patch (FindBoost-python.patch,5.82 KB, patch)
2017-03-23 08:37 UTC, Michael Palimaka (kensington)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrej Rode 2017-03-22 01:55:13 UTC
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.
Comment 1 Andrej Rode 2017-03-22 02:19:18 UTC
Created attachment 467874 [details, diff]
unsets PYTHON_EXECUTABLE in FindBoost.cmake
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2017-03-22 10:24:51 UTC
Can you provide an example how this can be triggered?
Comment 3 Andrej Rode 2017-03-22 16:32:30 UTC
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
Comment 4 Michael Palimaka (kensington) gentoo-dev 2017-03-23 08:15:09 UTC
I agree, we shouldn't pollute the environment like this.
Comment 5 Michael Palimaka (kensington) gentoo-dev 2017-03-23 08:37:36 UTC
Created attachment 468026 [details, diff]
FindBoost-python.patch

Suggested new version of FindBoost-python.patch
Comment 6 Michael Palimaka (kensington) gentoo-dev 2017-03-23 08:39:18 UTC
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()
Comment 7 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2017-03-23 12:20:57 UTC
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.
Comment 8 Andrej Rode 2017-03-24 04:14:15 UTC
The bug in the minimal example doesn't occur with the patch. And that the exact thing that triggers the bug. Nice work!