View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010077CMakeModulespublic2009-12-23 00:402014-10-06 10:32
Reportercelil 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0010077: FindPythonInterp and FindPythonLibs result in inconsistent python versions
DescriptionI am using the macports version of python on a Snow Leopard computer, and using cmake to build a cross-platform extension to it. I search for the python interpreter and libraries on the system using the following commands in CMakeLists.txt

   include(FindPythonInterp)
   include(FindPythonLibs )

However, while cmake identified the correct interpreter in /opt/local/bin (the one that is on my path), it tries to link against the wrong framework - namely the system Python framework. This results in an error when importing any python extension built with cmake:

    Fatal Python error: Interpreter not initialized (version mismatch?)

The correct behavior would be for FindPythonLibs to find the libraries corresponding to the version of the python interpreter that FindPythonInterp has found. In this case, at the linking stage the

    -framework Python

flag needs to be replaced with the full path name of the framework

    /opt/local/Library/Frameworks/Python.framework/Python

in order to create the right library.

To reproduce this bug simply try to build an extension for a version of python that is not the default version on your computer. Then importing the extension from the same version of python would result in the above error.
TagsNo tags attached.
Attached Filespatch file icon FindPythonLibs.cmake.patch [^] (3,847 bytes) 2012-11-17 12:15 [Show Content]

 Relationships
duplicate of 0013794closedMatt McCormick find_package(PythonLibs) finds different version of Python headers and libraries 

  Notes
(0026595)
David Cole (manager)
2011-05-25 17:02

Not for 2.8.5 - postponing until a future release
(0031540)
Orion E. Poplawski (reporter)
2012-11-13 10:46

This is also an issue in Fedora where we have both python 2 and python 3. Any chance of a fix soon?

https://bugzilla.redhat.com/show_bug.cgi?id=876118 [^]
(0031575)
Marcel Loose (developer)
2012-11-16 11:09
edited on: 2012-11-16 11:16

And also an issue on Debian and Ubuntu 12.10.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=686407 [^]

Is there a work-around, other than specifying PYTHON_LIBRARY on the command-line?
E.g., by specifying a limited range of Python 2.x versions.

--- 5 minutes of deep contemplation ;) ---

Just realized I could of course also use FIND_PACKAGE(PythonLibs 2), which effectively rules out finding any Python 3 libraries.

(0031595)
Marcel Loose (developer)
2012-11-17 12:14

I've created a patch, which I will upload in a minute.

The problem was that the search for the library and the include directory were basically independent. I've swapped these two code blocks, and made the search for the library depend on the success of finding the include directory.

It seems to work fine on my Ubunt 12.10 system which has both Python 3.2 and 2.7 libraries installed, but only 2.7 header files. FindPythonLibs now finds the 2.7 library, instead of the 3.2
(0035305)
Brad King (manager)
2014-03-05 11:47

Although this issue came first, more progress has been made in 0013794 so I'm resolving this as a duplicate of that.
(0036932)
Robert Maynard (manager)
2014-10-06 10:32

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2009-12-23 00:40 celil New Issue
2010-08-03 12:24 Kovarththanan Rajaratnam Category CMake => Modules
2010-12-14 17:06 David Cole Status new => assigned
2010-12-14 17:06 David Cole Assigned To => Marcus D. Hanwell
2011-04-14 14:30 David Cole Target Version => CMake 2.8.5
2011-05-25 17:02 David Cole Note Added: 0026595
2011-05-25 17:02 David Cole Target Version CMake 2.8.5 =>
2012-11-13 10:46 Orion E. Poplawski Note Added: 0031540
2012-11-16 11:09 Marcel Loose Note Added: 0031575
2012-11-16 11:16 Marcel Loose Note Edited: 0031575
2012-11-17 12:14 Marcel Loose Note Added: 0031595
2012-11-17 12:15 Marcel Loose File Added: FindPythonLibs.cmake.patch
2014-03-05 11:46 Brad King Relationship added duplicate of 0013794
2014-03-05 11:47 Brad King Note Added: 0035305
2014-03-05 11:47 Brad King Assigned To Marcus D. Hanwell =>
2014-03-05 11:47 Brad King Status assigned => resolved
2014-03-05 11:47 Brad King Resolution open => duplicate
2014-10-06 10:32 Robert Maynard Note Added: 0036932
2014-10-06 10:32 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team