[cmake-developers] Issues with overriding Python version, possible bug?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Apr 29 16:47:29 EDT 2017


My use case (which I am pretty sure is a common one) is that for
PLplot I want the default behaviour of our build system to be that it
looks for Python 3, but if that does not exist it looks for Python 2.

It appears the following logic implements that desired default
behaviour.

find_package(PythonInterp 3)
find_package(PythonInterp 2)

So far so good, but I am sure there will be some of our users that
prefer Python 2 even when Python 3 is installed on their system.

I could implement that user choice with a special FORCE_PYTHON2 option
option to allow the user to skip the first find_package command above,
but if possible I would far prefer that our users used a more standard
way (e.g., by setting Python_ADDITIONAL_VERSIONS) to specify the
Python version they prefer. However, when I tried (for both CMake-3.6.2 and
CMake-3.8.0-rc4) -DPython_ADDITIONAL_VERSIONS:STRING=2, the result was
that setting was ignored, i.e., the result of the above two
find_package commands was

-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.4.2", minimum required is "3") 
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.4.2", minimum required is "2")

Is this ignoring of Python_ADDITIONAL_VERSIONS for the above
find_package logic due to a bug in Modules/FindPythonInterp.cmake? Is
there some other standard way that the Python version can overridden
by the user for the above find_package logic?

(I am sorry I cannot answer either of these questions myself, but I am
having real trouble following the PythonInterp module logic for the
case when the default behaviour is specified via the above
find_package logic.)

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the cmake-developers mailing list