<div>Hello, everyone<br clear="all"></div><div><br></div><div>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.</div>
<div><br></div><div>-- code snippet --<font face="courier new,monospace"><br></font><font face="courier new,monospace">execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys;from distutils.sysconfig import get_python_inc;sys.stdout.write(get_python_inc())"</font><font face="courier new,monospace"><br>
</font><font face="courier new,monospace">                OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS</font><font face="courier new,monospace"><br></font><font face="courier new,monospace">                ERROR_VARIABLE ERROR_FINDING_INCLUDES)</font><font face="courier new,monospace"><br>
</font><font face="courier new,monospace"><br></font><font face="courier new,monospace">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))"</font><font face="courier new,monospace"><br>
</font><font face="courier new,monospace">                OUTPUT_VARIABLE PYTHON_LIBRARIES_DIR</font><font face="courier new,monospace"><br></font><font face="courier new,monospace">                ERROR_VARIABLE ERROR_FINDING_LIBRARIES)</font></div>
<div><font face="courier new,monospace"><br></font></div><div>
-- /code snippet --
</div><div><br></div><div>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)</div>
<div><br></div><div>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.</div>
<div><br></div><div>In spite of the latest, I still think that this code is very useful.</div><div><br></div><div>PS=Just in case, the python script embedded in the execute_process args should be a single line<br></div>-- <br>
<p>Felipe Lema Salas<br>Ingeniero Civil en Computación<br>Laboratorio ALGES<br>Departamento de Ingeniería en Minas<br>Universidad de Chile<br></p>
<br>