summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-05-25 17:08:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-31 07:32:29 +0000
commit6b4155223ce1670ed630b0b8780187cfeeadb564 (patch)
treee753252dc733dce4232e70cf4fc600a752481215
parent18dc31becdd994c53a9f894087cf1ef99fbd0232 (diff)
Fix module names to contain correct limited api suffix
This includes .abi3.so on Linux and macOS, and .pyd on Windows. Otherwise if you build with Python 3.6, and try to install the package on Python 3.5, none of the modules would be found on import. Change-Id: I56639da6319cfa06e23ae793d66099813074adf4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/pyside2/CMakeLists.txt98
-rw-r--r--sources/shiboken2/CMakeLists.txt98
2 files changed, 107 insertions, 89 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index 08647530..ee98d1d0 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -69,6 +69,50 @@ if (NOT PYTHON_EXTENSION_SUFFIX)
get_python_extension_suffix()
endif()
+# On Windows, PYTHON_LIBRARIES can be a list. Example:
+# optimized;C:/Python36/libs/python36.lib;debug;C:/Python36/libs/python36_d.lib
+# On other platforms, this result is not used at all.
+execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ for lib in '${PYTHON_LIBRARIES}'.split(';'):
+ if '/' in lib:
+ prefix, py = lib.rsplit( '/', 1)
+ if py.startswith('python3'):
+ print(prefix + '/python3.lib')
+ break
+ "
+ OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (WIN32)
+ set(PATH_SEP "\;")
+else()
+ set(PATH_SEP ":")
+endif()
+
+option(FORCE_LIMITED_API "Enable the limited API." "no")
+
+set(PYTHON_LIMITED_API 0)
+if(FORCE_LIMITED_API STREQUAL "yes")
+ # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
+ if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
+ add_definitions("-DPy_LIMITED_API=0x03050000")
+ set(PYTHON_LIMITED_API 1)
+ endif()
+endif()
+if (CMAKE_BUILD_TYPE STREQUAL "Release")
+ add_definitions("-DNDEBUG")
+endif()
+
+if (PYTHON_LIMITED_API)
+ if (WIN32 AND NOT EXISTS "${PYTHON_LIMITED_LIBRARIES}")
+ message(FATAL_ERROR "The Limited API was enabled, but ${PYTHON_LIMITED_LIBRARIES} was not found!")
+ endif()
+ message(STATUS "******************************************************")
+ message(STATUS "** Limited API enabled ${PYTHON_LIMITED_LIBRARIES}")
+ message(STATUS "******************************************************")
+endif()
+
if (NOT PYTHON_CONFIG_SUFFIX)
if (PYTHON_VERSION_MAJOR EQUAL 2)
set(PYTHON_CONFIG_SUFFIX "-python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
@@ -76,6 +120,13 @@ if (NOT PYTHON_CONFIG_SUFFIX)
set(PYTHON_CONFIG_SUFFIX "${PYTHON_CONFIG_SUFFIX}${PYTHON_EXTENSION_SUFFIX}")
endif()
elseif (PYTHON_VERSION_MAJOR EQUAL 3)
+ if (PYTHON_LIMITED_API)
+ if(WIN32)
+ set(PYTHON_EXTENSION_SUFFIX "")
+ else()
+ set(PYTHON_EXTENSION_SUFFIX ".abi3")
+ endif()
+ endif()
set(PYTHON_CONFIG_SUFFIX "${PYTHON_EXTENSION_SUFFIX}")
endif()
endif()
@@ -400,53 +451,6 @@ else()
endif()
message(STATUS "Detected OS: ${AUTO_OS}")
-# On Windows, PYTHON_LIBRARIES can be a list. Example:
-# optimized;C:/Python36/libs/python36.lib;debug;C:/Python36/libs/python36_d.lib
-# On other platforms, this result is not used at all.
-execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
- for lib in '${PYTHON_LIBRARIES}'.split(';'):
- if '/' in lib:
- prefix, py = lib.rsplit( '/', 1)
- if py.startswith('python3'):
- print(prefix + '/python3.lib')
- break
- "
- OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-if (WIN32)
- set(PATH_SEP "\;")
-else()
- set(PATH_SEP ":")
-endif()
-
-option(FORCE_LIMITED_API "Enable the limited API." "no")
-
-set(PYTHON_LIMITED_API 0)
-if(FORCE_LIMITED_API STREQUAL "yes")
- # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
- if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
- if (WIN32)
- set(SHIBOKEN_PYTHON_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
- endif()
- add_definitions("-DPy_LIMITED_API=0x03050000")
- set(PYTHON_LIMITED_API 1)
- endif()
- if (CMAKE_BUILD_TYPE STREQUAL "Release")
- add_definitions("-DNDEBUG")
- endif()
-endif()
-
-if (PYTHON_LIMITED_API)
- if (WIN32 AND NOT EXISTS "${PYTHON_LIMITED_LIBRARIES}")
- message(FATAL_ERROR "The Limited API was enabled, but ${PYTHON_LIMITED_LIBRARIES} was not found!")
- endif()
- message(STATUS "******************************************************")
- message(STATUS "** Limited API enabled ${PYTHON_LIMITED_LIBRARIES}")
- message(STATUS "******************************************************")
-endif()
-
# Define supported Qt Version
set(SUPPORTED_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}")
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
index 5720ff55..f3c586a9 100644
--- a/sources/shiboken2/CMakeLists.txt
+++ b/sources/shiboken2/CMakeLists.txt
@@ -234,6 +234,47 @@ if (NOT PYTHON_EXTENSION_SUFFIX)
get_python_extension_suffix()
endif()
+option(FORCE_LIMITED_API "Enable the limited API." "no")
+set(PYTHON_LIMITED_API 0)
+
+# On Windows, PYTHON_LIBRARIES can be a list. Example:
+# optimized;C:/Python36/libs/python36.lib;debug;C:/Python36/libs/python36_d.lib
+# On other platforms, this result is not used at all.
+execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ for lib in '${PYTHON_LIBRARIES}'.split(';'):
+ if '/' in lib:
+ prefix, py = lib.rsplit('/', 1)
+ if py.startswith('python3'):
+ print(prefix + '/python3.lib')
+ break
+ "
+ OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if(FORCE_LIMITED_API STREQUAL "yes")
+ if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
+ # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
+ add_definitions("-DPy_LIMITED_API=0x03050000")
+ set(PYTHON_LIMITED_API 1)
+ endif()
+ if(WIN32)
+ if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
+ # PYSIDE-560: XXX maybe add an option to setup.py as override
+ set(SBK_PYTHON_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
+ endif()
+ endif()
+endif()
+
+if (PYTHON_LIMITED_API)
+ if (WIN32 AND NOT EXISTS "${PYTHON_LIMITED_LIBRARIES}")
+ message(FATAL_ERROR "The Limited API was enabled, but ${PYTHON_LIMITED_LIBRARIES} was not found!")
+ endif()
+ message(STATUS "******************************************************")
+ message(STATUS "** Limited API enabled ${PYTHON_LIMITED_LIBRARIES}")
+ message(STATUS "******************************************************")
+endif()
+
if (NOT PYTHON_CONFIG_SUFFIX)
if (PYTHON_VERSION_MAJOR EQUAL 2)
set(PYTHON_CONFIG_SUFFIX "-python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
@@ -241,6 +282,13 @@ if (NOT PYTHON_CONFIG_SUFFIX)
set(PYTHON_CONFIG_SUFFIX "${PYTHON_CONFIG_SUFFIX}${PYTHON_EXTENSION_SUFFIX}")
endif()
elseif (PYTHON_VERSION_MAJOR EQUAL 3)
+ if (PYTHON_LIMITED_API)
+ if(WIN32)
+ set(PYTHON_EXTENSION_SUFFIX "")
+ else()
+ set(PYTHON_EXTENSION_SUFFIX ".abi3")
+ endif()
+ endif()
set(PYTHON_CONFIG_SUFFIX "${PYTHON_EXTENSION_SUFFIX}")
endif()
endif()
@@ -378,30 +426,15 @@ execute_process(
OUTPUT_VARIABLE PYTHON_WITH_COUNT_ALLOCS
OUTPUT_STRIP_TRAILING_WHITESPACE)
-# On Windows, PYTHON_LIBRARIES can be a list. Example:
-# optimized;C:/Python36/libs/python36.lib;debug;C:/Python36/libs/python36_d.lib
-# On other platforms, this result is not used at all.
-execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
- for lib in '${PYTHON_LIBRARIES}'.split(';'):
- if '/' in lib:
- prefix, py = lib.rsplit('/', 1)
- if py.startswith('python3'):
- print(prefix + '/python3.lib')
- break
- "
- OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
set(SHIBOKEN_BUILD_TYPE "Release")
# We do not want to link against the python shared / static library on Linux and macOS.
# The dynamic linker will pick up the python symbols at runtime automatically.
# On Windows we do need to link against the python.lib import library.
+if (NOT SBK_PYTHON_LIBRARIES)
+ set(SBK_PYTHON_LIBRARIES "")
+endif()
-set(SBK_PYTHON_LIBRARIES "")
-option(FORCE_LIMITED_API "Enable the limited API." "no")
-set(PYTHON_LIMITED_API 0)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(NOT PYTHON_DEBUG_LIBRARIES)
message(WARNING "Python debug shared library not found; assuming python was built with shared library support disabled.")
@@ -421,42 +454,23 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SBK_PKG_CONFIG_PY_DEBUG_DEFINITION "${SBK_PKG_CONFIG_PY_DEBUG_DEFINITION} -DCOUNT_ALLOCS")
endif()
- if(WIN32)
+ if(WIN32 AND NOT SBK_PYTHON_LIBRARIES)
set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES})
endif()
set(SHIBOKEN_BUILD_TYPE "Debug")
endif()
-if(FORCE_LIMITED_API STREQUAL "yes")
- if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
- # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
- add_definitions("-DPy_LIMITED_API=0x03050000")
- set(PYTHON_LIMITED_API 1)
- endif()
- if(WIN32)
+
+if(CMAKE_BUILD_TYPE STREQUAL "Release")
+ add_definitions("-DNDEBUG")
+ if(WIN32 AND NOT SBK_PYTHON_LIBRARIES)
set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
- if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
- # PYSIDE-560: XXX maybe add an option to setup.py as override
- set(SBK_PYTHON_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
- endif()
- endif()
- if (CMAKE_BUILD_TYPE STREQUAL "Release")
- add_definitions("-DNDEBUG")
endif()
endif()
-if (PYTHON_LIMITED_API)
- if (WIN32 AND NOT EXISTS "${PYTHON_LIMITED_LIBRARIES}")
- message(FATAL_ERROR "The Limited API was enabled, but ${PYTHON_LIMITED_LIBRARIES} was not found!")
- endif()
- message(STATUS "******************************************************")
- message(STATUS "** Limited API enabled ${PYTHON_LIMITED_LIBRARIES}")
- message(STATUS "******************************************************")
-endif()
if(APPLE)
set(SBK_PYTHON_LIBRARIES "-undefined dynamic_lookup")
endif()
-
if(CMAKE_VERSION VERSION_LESS 2.8)
set(SBK_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH})
else()