Hello, everyone
I was trying to use cmake to build python c++ extensions in win7, but
couldn't get cmake to detect PythonLibs. At least, not without editing the
windows registry. Since it could detect PythonInterp, I got it working
using the directories provided from methods inside the interpreter.
-- code snippet --
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys;from
distutils.sysconfig import
get_python_inc;sys.stdout.write(get_python_inc())"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS
ERROR_VARIABLE ERROR_FINDING_INCLUDES)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys;from
numpy.distutils.numpy_distribution import NumpyDistribution;from
numpy.distutils.command.build_ext import
build_ext;a=build_ext(NumpyDistribution());a.ensure_finalized();sys.stdout.write(';'.join(a.library_dirs))"
OUTPUT_VARIABLE PYTHON_LIBRARIES_DIR
ERROR_VARIABLE ERROR_FINDING_LIBRARIES)
-- /code snippet --
These directories can be used later for finding the python .lib files and
version number, as cmake currently does (although using the directories
from the windows registry)
The only setback (at least for finding the python lib files) is that the
user must have numpy correctly installed with the found interpreter.
Haven't tried it, but there should be a way to get it to work without numpy
installed.
In spite of the latest, I still think that this code is very useful.
PS=Just in case, the python script embedded in the execute_process args
should be a single line
--
Felipe Lema Salas
Ingeniero Civil en Computación
Laboratorio ALGES
Departamento de IngenierÃa en Minas
Universidad de Chile
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake