← Back to team overview

kicad-developers team mailing list archive

Re: CMake doesn't find the right PythonLibs on recent Ubuntus, workaround included

 

On 4/12/2013 4:17 PM, Adam Wolf wrote:
Hi Wayne,

It looks like CMake doesn't extract the library version number from
the interpreter--it just finds the highest python version libraries
installed.  Someone wrote up a new FindPythonLibs.cmake that does look
at the running interpreter, and it was rejected in 2011.  This may be
part of why the team has such a hard time with Python and cmake!

The reason for the rejection is that it failed on cross-platform builds but it could have be modified to check for a cross build and use the version pulled from the default interpreter on non-cross builds.


The patch to do this would be extremely minimal--check if
PYTHON_VERSION_MAJOR and PYTHON_VERSION_MINOR were set (by
FindPythonInterp) and then replace the version list creation with

set(_FOUND_PYTHON_MAJ_MIN ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})

set(_Python_VERSIONS
    ${Python_ADDITIONAL_VERSIONS}\
    ${_FOUND_PYTHON_MAJ_MIN}\
    ${_PYTHON_FIND_OTHER_VERSIONS}
    )

This would make it search for user specified versions first, then the
detected version, and then the standard Python version list.

Since CMake's Python version detection is currently broken with cmake
on any system where there are installed headers of a newer version
than the default interpreter, which includes Fedora and Ubuntu, do you
think I should write and test this patch, and send it over to the
CMake folks, or do you think that'd be a waste given the fact that
since at least 2011, they've been wanting to first rewrite Python
version detection with FindPython.cmake?
(http://www.cmake.org/pipermail/cmake/2011-November/047799.html)

Adam Wolf
Wayne and Layne, LLC


I don't know if you'll get anywhere sending the patch to the CMake folks but for our purposes we could use the default interpreter version on non-cross builds which should solve part of the problem. To prevent python 3 from being used, you would have to remove the all of the python 3 paths from the path search lists of both FindPythonInter and FindPythonLib.



Follow ups

References