[CMake] How to install openbabel python bindings by using the new cmake installer (problem selecting a particular python version).

Michael Hertling mhertling at online.de
Sat Nov 13 08:57:29 EST 2010


On 11/12/2010 02:13 PM, Hector Martinez-Seara wrote:
> Dear all,
> I'm trying to install openbabel in linux which in its last version
> (2.3.0) uses cmake installer. I haven't been able to compile it with
> biddings with python 3.1 when using the -DPYTHON_BINDINGS=ON option. I
> have python 2.7 and 3.1 installed in my system and the python command
> points to python 3.1. Still cmake only select python 2.7 despite it is
> not set as preferred in my system in any way. I have made a small
> search and I have seen that there is a lot of troubles selecting
> python 3 with cmake. Most of the information was very technical and
> honestly I'm not sure if there was any solution at the end.

AFAIK, the FindPython{Interp,Libs}.cmake modules are currently not
capable to find Python 3, so you should focus on a manual approach
at the moment, see below. With the scheduling of issue 8396 for the
2.8.4 roadmap, there's a perpective for the availability of version-
or pattern-aware find functions, so maybe, it is possible to improve
the find modules w.r.t. version selection in the near or medium term.

> My question is rather easy:
> a) Is there any way to force a specific python version (3.1) from the
> cmake command line?

You might try to set the PYTHON_EXECUTABLE, PYTHON_INCLUDE_DIR and
PYTHON_LIBRARY variables to appropriate values for your Python 3.1
installation on the command line, i.e. by use of the -D option or
-C along with a prepared script. AFAICS, defining these variables
makes the FindPython{Interp,Libs}.cmake modules not look for the
interpreter, the include directory and the library by themselves,
so you possibly get by without any further modifications, but I
have not yet tested this with Open Babel.

> or b) Is there variable which I could export, e.g. CC=gcc4.5, to force
> python to select the python version I want?

None I'm aware of, but - as stated above - there're some undertakings
in the near future that might result in a comprehensive and flexible
FindPython.cmake module which receives the requested version through
FIND_PACKAGE()'s version parameter, including version 3.

Regards,

Michael


More information about the CMake mailing list