Hi, Attached are two patches which improve Python3 support in the FindPythonLibs.cmake module. The commit messages contain explanations for the commits, copied here for convenience.
Subject: [PATCH 1/2] Don't put legacy variables back into the cache If PYTHON_INCLUDE_PATH is put into the cache, then it will always override whatever might be found and PYTHON_INCLUDE_DIR is never given a chance to find something different. It being marked as INTERNAL also means that it cannot be changed without editing CMakeCache.txt directly. Basically, the scenario is that if the Python version is changed, then deleting PYTHON_INCLUDE_DIR doesn't work because any cached PYTHON_INCLUDE_PATH variable is set before find_path is even called. Any build tree using a previous version will still need either manual removal of PYTHON_INCLUDE_PATH or a complete reconfigure, but in the future changing the Python version can be accomplished by deleting PYTHON_INCLUDE_DIR and reconfiguring with the new version. Subject: [PATCH 2/2] Search for other ABIFLAGS builds of Python Starting with Python3, standard Python installs may have additional ABI flags attached to include directories and library names. As of 3.2, the following flags are in the configure file: d -> --with-debug m -> --with-pymalloc u -> --with-wide-unicode Python 3.3 seems to no longer have --with-wide-unicode. Hopefully Python will ensure that the possible flags always show up in a stable order. The 'd' flag is ignored since the debug library is considered separate. There is still the problem where ABI flags cannot be specified in find_package since the letters confuse the version comparator. --Ben
>From 6a46f5ce809185e0c7dbd3d618eb4bbde808827b Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Tue, 27 Mar 2012 16:21:06 -0400 Subject: [PATCH 1/2] Don't put legacy variables back into the cache If PYTHON_INCLUDE_PATH is put into the cache, then it will always override whatever might be found and PYTHON_INCLUDE_DIR is never given a chance to find something different. It being marked as INTERNAL also means that it cannot be changed without editing CMakeCache.txt directly. Basically, the scenario is that if the Python version is changed, then deleting PYTHON_INCLUDE_DIR doesn't work because any cached PYTHON_INCLUDE_PATH variable is set before find_path is even called. Any build tree using a previous version will still need either manual removal of PYTHON_INCLUDE_PATH or a complete reconfigure, but in the future changing the Python version can be accomplished by deleting PYTHON_INCLUDE_DIR and reconfiguring with the new version. --- Modules/FindPythonLibs.cmake | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index fcd0838..e833150 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -123,9 +123,8 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) python${_CURRENT_VERSION} ) - # For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal. - SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL - "Path to where Python.h is found (deprecated)") + # For backward compatibility, set PYTHON_INCLUDE_PATH. + SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") IF(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") FILE(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str -- 1.7.6.5
>From 4bdec581b3a5a32239370e87aa2f7cadcb058aae Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Tue, 27 Mar 2012 16:24:43 -0400 Subject: [PATCH 2/2] Search for other ABIFLAGS builds of Python Starting with Python3, standard Python installs may have additional ABI flags attached to include directories and library names. As of 3.2, the following flags are in the configure file: d -> --with-debug m -> --with-pymalloc u -> --with-wide-unicode Python 3.3 seems to no longer have --with-wide-unicode. Hopefully Python will ensure that the possible flags always show up in a stable order. The 'd' flag is ignored since the debug library is considered separate. There is still the problem where ABI flags cannot be specified in find_package since the letters confuse the version comparator. --- Modules/FindPythonLibs.cmake | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index e833150..591b3e6 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -82,7 +82,12 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) ENDIF(WIN32) FIND_LIBRARY(PYTHON_LIBRARY - NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + NAMES + python${_CURRENT_VERSION_NO_DOTS} + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs @@ -120,6 +125,9 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include PATH_SUFFIXES + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u python${_CURRENT_VERSION} ) -- 1.7.6.5
-- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers