[CMake] Behaviour of FindPythonInterp appears suboptimal

Roger Leigh rleigh at codelibre.net
Fri Aug 22 06:31:13 EDT 2014


I thought using FindPythonInterp would be more portable than
simply invoking "python" directly (i.e. using $PYTHON_EXECUTABLE).
However, this does not appear to be the case.  I'd be interested to
know if this is intentional or if I'm doing something wrong.

I've tried using "find_package(PythonInterp 2.6.0 REQUIRED)" on a
variety of systems.  The software in question works with any
python 2.6 or 2.7 version.

On Debian, with the default python 2.7 installed, it picked up
python 2.6.8 (from python2.6-minimal) which lacked all the
required modules.  /usr/bin/python was 2.7 and matched the
version requirement, and had all the required modules
available.

On Windows, with an active virtualenv, it doesn't use the
virtualenv python on the path, but an entirely different version
without the modules I need available.

Similar problems seen for Ubuntu.

I think the general problem here is that it tries to be too
clever, and tries to find a lower version in preference to
a perfectly suitable newer version, and even the version on
the path.  This includes using virtualenv, where I've
carefully gone to the effort of setting up a custom
environment for the purpose only to have it be ignored.

I would have expected that if the default path contained
"python", "python2" or "python2.7", these should all be
preferred (in order) over "python2.6" or any autodetected
version not on the path, if the version meets the requirement
from find_package.  The current behaviour gets it wrong in
almost every situation except where there's only a single
version to choose from!


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


More information about the CMake mailing list