Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 603406

Summary: dev-util/cmake-3.6.3 - PythonInterp finds wrong Python executable with CMAKE_BUILD_TYPE=Gentoo
Product: Gentoo Linux Reporter: Wim de With <nauxuron>
Component: Current packagesAssignee: Gentoo KDE team <kde>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=253593
https://bugs.gentoo.org/show_bug.cgi?id=835799
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Minimal CMakeList.txt to reproduce behavior

Description Wim de With 2016-12-22 00:42:33 UTC
Created attachment 457060 [details]
Minimal CMakeList.txt to reproduce behavior

If you build the attached CMakeLists.txt with:

cmake .

CMake finds the correct Python executable (/usr/bin/python2.7):
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.7")

If you build it with:

cmake -DCMAKE_BUILD_TYPE=Gentoo .

CMake finds /usr/bin/python, which I eselected to python3.4:
-- Found PythonInterp: /usr/bin/python (found suitable version "3.4.5", minimum required is "2.7")
Comment 1 Michael Palimaka (kensington) gentoo-dev 2016-12-22 13:58:49 UTC
This is intentional behaviour.

When we build a package against python, we need to be absolutely certain that we are building against the correct version given the selected PYTHON_TARGET.

From FindPythonInterp.cmake:

>if (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo)
>    set(_Python_NAMES python)
>endif()

When a Gentoo build is active (intended only to be the case when building via a package manager), we throw away whatever cmake would have found and force /usr/bin/python instead.  The python eclass then exports EPYTHON="pythonX.Y" causing /usr/bin/python to point to the correct version given the active PYTHON_TARGET.