python: finding specific library version via CMake

Mark Moll mmoll at rice.edu
Tue Jun 30 07:18:57 PDT 2015


> On Jun 29, 2015, at 9:18 PM, Mark Moll <mmoll at rice.edu> wrote:
> 
>> 
>> On Jun 29, 2015, at 8:10 PM, Ryan Schmidt <ryandesign at macports.org> wrote:
>> 
>> 
>> On Jun 24, 2015, at 3:04 PM, Mark Moll wrote:
>> 
>>> Part of the problem is that there is no way to force the default CMake modules for finding an python interpreter and python libraries to agree on the same version. As a way around that I wrote my own FindPython.cmake:
>>> 
>>> https://bitbucket.org/ompl/ompl/src/tip/CMakeModules/FindPython.cmake
>>> 
>>> You can then specify a specific version:
>>> 
>>> 	find_package(python 3.4)
>>> 
>>> This will define PYTHON_EXEC, PYTHON_LIBRARIES, PYTHON_INCLUDE_DIRS, PYTHON_SITE_MODULES, and PYTHON_VERSION. If you run cmake like so:
>>> 
>>> 	cmake -DPYTHON_EXEC=/opt/local/bin/python3.4 ..
>>> 
>>> then the other variables are automatically defined appropriately.
>>> 
>>> You can also use it to find python modules:
>>> 
>>> 	find_python_module(numpy [version] [REQUIRED|QUIET])
>> 
>> Have you tried to contribute your FindPython.cmake to the developers of cmake for inclusion in cmake?
> 
> That’s a good idea. Done:
> http://public.kitware.com/pipermail/cmake-developers/2015-June/025535.html

It won’t work:

http://public.kitware.com/pipermail/cmake-developers/2015-June/025542.html

Essentially, cross-compilation isn’t handled. There are also use cases where only the python libs are needed and one can’t depend on the python interpreter.

--
Mark Moll
http://www.cs.rice.edu/~mmoll
Rice University, MS 132, PO Box 1892, Houston, TX 77251
713-348-5934 (phone), 713-348-5930 (fax)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.macosforge.org/pipermail/macports-dev/attachments/20150630/38414b29/attachment.sig>


More information about the macports-dev mailing list