aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-08-01 12:18:21 +0200
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-12-11 11:53:33 +0100
commitd5b56ebb1534a3359f03534a967bbe3cf2a5eb51 (patch)
tree556970cbfdb5e509b58fd89aba86e078325311a8
parentfd5916f44c052f21d6e86570f37dd92d1bbaa203 (diff)
Shiboken: Remove FindPythonInterp and FindPythonLibs CMake modules
- They were deprecated since 3.12 and removed in 3.27 - Use FindPython module as replacement - all the Python cmake variables resulted are renamed to their respective variable names as per the FindPython module instead of FindPythonInterp or FindPythonLibs module Pick-to: 6.6 Fixes: PYSIDE-2439 Change-Id: I1d3106e2cc9ee97e2d4f62d4e19e1a591d1021ad Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--build_scripts/main.py6
-rw-r--r--sources/pyside6/cmake/PySideSetup.cmake2
-rw-r--r--sources/pyside6/doc/CMakeLists.txt5
-rw-r--r--sources/pyside6/doc/gettingstarted/linux.rst2
-rw-r--r--sources/shiboken6/cmake/ShibokenHelpers.cmake80
-rw-r--r--sources/shiboken6/cmake/ShibokenSetup.cmake18
-rw-r--r--sources/shiboken6/data/Shiboken6Config-spec.cmake.in8
-rw-r--r--sources/shiboken6/data/shiboken6.pc.in6
-rw-r--r--sources/shiboken6/doc/CMakeLists.txt2
-rw-r--r--sources/shiboken6/generator/CMakeLists.txt2
-rw-r--r--sources/shiboken6/libshiboken/CMakeLists.txt2
-rw-r--r--sources/shiboken6/libshiboken/sbkversion.h.in6
-rw-r--r--sources/shiboken6/tests/CMakeLists.txt11
13 files changed, 70 insertions, 80 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 27270e71d..cd5be7bd3 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -611,9 +611,9 @@ class PysideBuild(_build, CommandMixin, BuildInfoCollectorMixin):
# embedding_generator.py. Pass it as a separate option.
cmake_cmd.append(f"-DQFP_PYTHON_HOST_PATH={sys.executable}")
else:
- cmake_cmd.append(f"-DPYTHON_EXECUTABLE={self.py_executable}")
- cmake_cmd.append(f"-DPYTHON_INCLUDE_DIR={self.py_include_dir}")
- cmake_cmd.append(f"-DPYTHON_LIBRARY={self.py_library}")
+ cmake_cmd.append(f"-DPython_EXECUTABLE={self.py_executable}")
+ cmake_cmd.append(f"-DPython_INCLUDE_DIR={self.py_include_dir}")
+ cmake_cmd.append(f"-DPython_LIBRARY={self.py_library}")
# If a custom shiboken cmake config directory path was provided, pass it to CMake.
if OPTION["SHIBOKEN_CONFIG_DIR"] and config.is_internal_pyside_build():
diff --git a/sources/pyside6/cmake/PySideSetup.cmake b/sources/pyside6/cmake/PySideSetup.cmake
index 87a91cfd9..ff2cfbd92 100644
--- a/sources/pyside6/cmake/PySideSetup.cmake
+++ b/sources/pyside6/cmake/PySideSetup.cmake
@@ -51,7 +51,7 @@ set(BINDING_API_PRE_RELEASE_VERSION "${pyside_PRE_RELEASE_VERSION}")
# Detect if the Python interpreter is actually PyPy
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ COMMAND ${Python_EXECUTABLE} -c "if True:
pypy_version = ''
import sys
if hasattr(sys, 'pypy_version_info'):
diff --git a/sources/pyside6/doc/CMakeLists.txt b/sources/pyside6/doc/CMakeLists.txt
index 76f717ee3..8b1c97c21 100644
--- a/sources/pyside6/doc/CMakeLists.txt
+++ b/sources/pyside6/doc/CMakeLists.txt
@@ -67,7 +67,6 @@ file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/pyside.qdocconf ${CMAKE_CURRENT_LIST_DIR}/
# for the 'build_base_docs' case, and not a full doc build
if (NOT FULLDOCSBUILD)
find_package(Python COMPONENTS Interpreter)
- set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
endif()
if (QT_SRC_DIR)
@@ -79,7 +78,7 @@ endif()
if(PYSIDE_IS_CROSS_BUILD)
set(python_executable "${QFP_PYTHON_HOST_PATH}")
else()
- set(python_executable "${PYTHON_EXECUTABLE}")
+ set(python_executable "${Python_EXECUTABLE}")
endif()
set(TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../tools")
@@ -138,7 +137,7 @@ if (FULLDOCSBUILD)
file(WRITE ${global_typesystem} "${typeSystemDocXmlContents}")
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} "${TOOLS_DIR}/doc_modules.py"
+ COMMAND ${Python_EXECUTABLE} "${TOOLS_DIR}/doc_modules.py"
-t "${global_typesystem}" -g "${global_header}" -d "${config_docconf}"
"${QT_INCLUDE_DIR}" "${SUPPORTED_QT_VERSION}"
OUTPUT_VARIABLE ALL_DOC_MODULES
diff --git a/sources/pyside6/doc/gettingstarted/linux.rst b/sources/pyside6/doc/gettingstarted/linux.rst
index 111085add..912105ef8 100644
--- a/sources/pyside6/doc/gettingstarted/linux.rst
+++ b/sources/pyside6/doc/gettingstarted/linux.rst
@@ -86,7 +86,7 @@ Assumming that Qt is in PATH, for example, the configure step can be done with::
cmake -B /path/to/the/build/directory \
-S /path/to/the/pyside-setup \
-DCMAKE_INSTALL_PREFIX=/where/to/install \
- -DPYTHON_EXECUTABLE=/path/to/interpreter
+ -DPython_EXECUTABLE=/path/to/interpreter
.. note:: You can add `-DFORCE_LIMITED_API=yes` in case you want to have a
build which will be compatible with Python 3.7+.
diff --git a/sources/shiboken6/cmake/ShibokenHelpers.cmake b/sources/shiboken6/cmake/ShibokenHelpers.cmake
index 298eaf7db..b42ba413a 100644
--- a/sources/shiboken6/cmake/ShibokenHelpers.cmake
+++ b/sources/shiboken6/cmake/ShibokenHelpers.cmake
@@ -116,7 +116,7 @@ macro(shiboken_internal_set_python_site_packages)
endif()
else()
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ COMMAND ${Python_EXECUTABLE} -c "if True:
import sysconfig
from os.path import sep
@@ -209,7 +209,7 @@ macro(get_python_extension_suffix)
else()
# See PYSIDE-1841 / https://bugs.python.org/issue39825 for distutils vs sysconfig
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ COMMAND ${Python_EXECUTABLE} -c "if True:
import sys
if sys.version_info >= (3, 8, 2):
import sysconfig
@@ -241,18 +241,22 @@ macro(shiboken_check_if_limited_api)
# TODO: Figure out how to use limited API libs when cross-building to Windows, if that's ever
# needed. Perhaps use host python to walk the libs of the target python installation.
- if(NOT SHIBOKEN_IS_CROSS_BUILD)
+ if(NOT SHIBOKEN_IS_CROSS_BUILD AND WIN32)
# 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:
- import os
- for lib in '${PYTHON_LIBRARIES}'.split(';'):
- if '/' in lib and os.path.isfile(lib):
- prefix, py = lib.rsplit('/', 1)
+ COMMAND ${Python_EXECUTABLE} -c "if True:
+ from pathlib import Path
+ libs = r'${Python_LIBRARIES}'
+ libs = libs.split(';')
+ for lib in libs:
+ if '\\\\' in lib and Path(lib).is_file():
+ lib = Path(lib)
+ prefix = lib.parent
+ py = lib.name
if py.startswith('python3'):
- print(prefix + '/python3.lib')
+ print(prefix / 'python3.lib')
break
"
OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
@@ -271,6 +275,10 @@ endmacro()
macro(shiboken_find_required_python)
+ set(_shiboken_find_python_version_args "")
+ if(${ARGC} GREATER 0)
+ list(APPEND _shiboken_find_python_version_args "${ARGV0}")
+ endif()
# This function can also be called by consumers of ShibokenConfig.cmake package like pyside,
# that's why we also check for PYSIDE_IS_CROSS_BUILD (which is set by pyside project)
# and QFP_FIND_NEW_PYTHON_PACKAGE for an explicit opt in.
@@ -278,11 +286,6 @@ macro(shiboken_find_required_python)
# We have to use FindPython package instead of FindPythonInterp to get required target Python
# information.
if(SHIBOKEN_IS_CROSS_BUILD OR PYSIDE_IS_CROSS_BUILD OR QFP_FIND_NEW_PYTHON_PACKAGE)
- set(_shiboken_find_python_version_args "")
- if(${ARGC} GREATER 0)
- list(APPEND _shiboken_find_python_version_args "${ARGV0}")
- endif()
-
# We want FindPython to look in the sysroot for the python-config executable,
# but toolchain files might set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to NEVER because
# programs are mostly found for running and you usually can't run a target executable on
@@ -311,40 +314,23 @@ macro(shiboken_find_required_python)
"${_shiboken_backup_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM}")
set(CMAKE_FIND_ROOT_PATH
"${_shiboken_backup_CMAKE_FIND_ROOT_PATH}")
-
- # Mirror the variables that FindPythonInterp sets, instead of conditionally checking
- # and modifying all the places where the variables are used.
- set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
- set(PYTHON_VERSION "${Python_VERSION}")
- set(PYTHON_LIBRARIES "${Python_LIBRARIES}")
- set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}")
- set(PYTHONINTERP_FOUND "${Python_Interpreter_FOUND}")
- set(PYTHONINTERP_FOUND "${Python_Interpreter_FOUND}")
- set(PYTHONLIBS_FOUND "${Python_Development_FOUND}")
- set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
- set(PYTHON_VERSION_MINOR "${Python_VERSION_MINOR}")
- set(PYTHON_VERSION_PATCH "${Python_VERSION_PATCH}")
else()
- if(${ARGC} GREATER 0)
- find_package(PythonInterp ${ARGV0} REQUIRED)
- find_package(PythonLibs ${ARGV0} REQUIRED)
- else()
- # If no version is specified, just use any interpreter that can be found (from PATH).
- # This is useful for super-project builds, so that the default system interpeter
- # gets picked up (e.g. /usr/bin/python and not /usr/bin/python2.7).
- find_package(PythonInterp REQUIRED)
- find_package(PythonLibs REQUIRED)
- endif()
+ find_package(
+ Python
+ ${_shiboken_find_python_version_args}
+ REQUIRED
+ COMPONENTS Interpreter Development
+ )
endif()
shiboken_validate_python_version()
- set(SHIBOKEN_PYTHON_INTERPRETER "${PYTHON_EXECUTABLE}")
- set_property(GLOBAL PROPERTY SHIBOKEN_PYTHON_INTERPRETER "${PYTHON_EXECUTABLE}")
+ set(SHIBOKEN_PYTHON_INTERPRETER "${Python_EXECUTABLE}")
+ set_property(GLOBAL PROPERTY SHIBOKEN_PYTHON_INTERPRETER "${Python_EXECUTABLE}")
endmacro()
macro(shiboken_validate_python_version)
- if(PYTHON_VERSION_MAJOR EQUAL "3" AND PYTHON_VERSION_MINOR LESS "7")
+ if(Python_VERSION_MAJOR EQUAL "3" AND Python_VERSION_MINOR LESS "7")
message(FATAL_ERROR
"Shiboken requires Python 3.7+.")
endif()
@@ -365,14 +351,14 @@ macro(shiboken_compute_python_includes)
if (SHIBOKEN_COMPUTE_INCLUDES_IS_CALLED_FROM_EXPORT)
#TODO target_include_directories works on imported targets only starting with v3.11.0.
set_property(TARGET Shiboken6::libshiboken
- APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
+ APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Python_INCLUDE_DIRS})
else()
target_include_directories(libshiboken
- PUBLIC $<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>)
+ PUBLIC $<BUILD_INTERFACE:${Python_INCLUDE_DIRS}>)
endif()
- set(SHIBOKEN_PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}")
+ set(SHIBOKEN_PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}")
set_property(GLOBAL PROPERTY shiboken_python_include_dirs "${SHIBOKEN_PYTHON_INCLUDE_DIRS}")
@@ -440,7 +426,7 @@ macro(shiboken_compute_python_libraries)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if(WIN32 AND NOT SHIBOKEN_PYTHON_LIBRARIES)
- set(SHIBOKEN_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
+ set(SHIBOKEN_PYTHON_LIBRARIES ${Python_LIBRARIES})
endif()
endif()
@@ -474,11 +460,11 @@ macro(shiboken_compute_python_libraries)
endmacro()
function(shiboken_check_if_built_and_target_python_are_compatible)
- if(NOT SHIBOKEN_PYTHON_VERSION_MAJOR STREQUAL PYTHON_VERSION_MAJOR)
+ if(NOT SHIBOKEN_PYTHON_VERSION_MAJOR STREQUAL Python_VERSION_MAJOR)
message(FATAL_ERROR "The detected Python major version is not \
compatible with the Python major version which was used when Shiboken was built.
Built with: '${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}' \
-Detected: '${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}'")
+Detected: '${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}'")
else()
if(NOT SHIBOKEN_PYTHON_LIMITED_API
AND NOT SHIBOKEN_PYTHON_VERSION_MINOR STREQUAL PYTHON_VERSION_MINOR)
@@ -487,7 +473,7 @@ Detected: '${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}'")
version which was used when Shiboken was built. Consider building shiboken with \
FORCE_LIMITED_API set to '1', so that only the Python major version matters.
Built with: '${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}' \
-Detected: '${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}'")
+Detected: '${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}'")
endif()
endif()
endfunction()
diff --git a/sources/shiboken6/cmake/ShibokenSetup.cmake b/sources/shiboken6/cmake/ShibokenSetup.cmake
index c1d477bef..89e64dee9 100644
--- a/sources/shiboken6/cmake/ShibokenSetup.cmake
+++ b/sources/shiboken6/cmake/ShibokenSetup.cmake
@@ -44,13 +44,13 @@ set(shiboken6_library_so_version "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VER
compute_config_py_values(shiboken6_VERSION)
## For debugging the PYTHON* variables
-message(STATUS "PYTHONLIBS_FOUND: " ${PYTHONLIBS_FOUND})
-message(STATUS "PYTHON_LIBRARIES: " ${PYTHON_LIBRARIES})
-message(STATUS "PYTHON_INCLUDE_DIRS: " ${PYTHON_INCLUDE_DIRS})
-message(STATUS "PYTHON_DEBUG_LIBRARIES: " ${PYTHON_DEBUG_LIBRARIES})
-message(STATUS "PYTHONINTERP_FOUND: " ${PYTHONINTERP_FOUND})
-message(STATUS "PYTHON_EXECUTABLE: " ${PYTHON_EXECUTABLE})
-message(STATUS "PYTHON_VERSION: " ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})
+message(STATUS "Python_Development_FOUND: " ${Python_Development_FOUND})
+message(STATUS "Python_LIBRARIES: " ${Python_LIBRARIES})
+message(STATUS "Python_INCLUDE_DIRS: " ${Python_INCLUDE_DIRS})
+message(STATUS "Python_DEBUG_LIBRARIES: " ${PYTHON_DEBUG_LIBRARIES})
+message(STATUS "Python_Interpreter_FOUND: " ${Python_Interpreter_FOUND})
+message(STATUS "Python_EXECUTABLE: " ${Python_EXECUTABLE})
+message(STATUS "Python_VERSION: " ${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}.${Python_VERSION_PATCH})
if(NOT PYTHON_EXTENSION_SUFFIX)
get_python_extension_suffix()
@@ -121,7 +121,7 @@ endif()
# Detect if the python libs were compiled in debug mode
# On Linux distros there is no standard way to check that.
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ COMMAND ${Python_EXECUTABLE} -c "if True:
import sys
import sysconfig
config_py_debug = sysconfig.get_config_var('Py_DEBUG')
@@ -139,7 +139,7 @@ if(SHIBOKEN_IS_CROSS_BUILD)
set(PYTHON_WITH_COUNT_ALLOCS 0)
else()
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ COMMAND ${Python_EXECUTABLE} -c "if True:
count_allocs = False
import sys
try:
diff --git a/sources/shiboken6/data/Shiboken6Config-spec.cmake.in b/sources/shiboken6/data/Shiboken6Config-spec.cmake.in
index a07563a53..233404bc6 100644
--- a/sources/shiboken6/data/Shiboken6Config-spec.cmake.in
+++ b/sources/shiboken6/data/Shiboken6Config-spec.cmake.in
@@ -5,9 +5,9 @@
# This is the version of Python against which Shiboken was built. Not necessarily the version
# against which a downstream project is built (e.g. PySide6).
-set(SHIBOKEN_PYTHON_VERSION_MAJOR "@PYTHON_VERSION_MAJOR@")
-set(SHIBOKEN_PYTHON_VERSION_MINOR "@PYTHON_VERSION_MINOR@")
-set(SHIBOKEN_PYTHON_VERSION_PATCH "@PYTHON_VERSION_PATCH@")
+set(SHIBOKEN_PYTHON_VERSION_MAJOR "@Python_VERSION_MAJOR@")
+set(SHIBOKEN_PYTHON_VERSION_MINOR "@Python_VERSION_MINOR@")
+set(SHIBOKEN_PYTHON_VERSION_PATCH "@Python_VERSION_PATCH@")
set(SHIBOKEN_PYTHON_LIMITED_API "@PYTHON_LIMITED_API@")
# Import targets and call variable set up functions only when using an installed shiboken config
@@ -17,7 +17,7 @@ if (NOT TARGET Shiboken6::libshiboken)
include("${CMAKE_CURRENT_LIST_DIR}/ShibokenHelpers.cmake")
# Compute the python include and libraries path if needed (aka not part of super project build).
- shiboken_find_required_python(@PYTHON_VERSION_MAJOR@)
+ shiboken_find_required_python(@Python_VERSION_MAJOR@)
shiboken_check_if_built_and_target_python_are_compatible()
shiboken_check_if_limited_api()
shiboken_compute_python_includes(IS_CALLED_FROM_EXPORT)
diff --git a/sources/shiboken6/data/shiboken6.pc.in b/sources/shiboken6/data/shiboken6.pc.in
index 3ba422627..a82d23168 100644
--- a/sources/shiboken6/data/shiboken6.pc.in
+++ b/sources/shiboken6/data/shiboken6.pc.in
@@ -2,11 +2,11 @@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@
includedir=@CMAKE_INSTALL_PREFIX@/include/shiboken6
-python_interpreter=@PYTHON_EXECUTABLE@
-python_include_dir=@PYTHON_INCLUDE_DIRS@
+python_interpreter=@Python_EXECUTABLE@
+python_include_dir=@Python_INCLUDE_DIRS@
Name: shiboken6
Description: Support library for Python bindings created with the Shiboken6 generator.
Version: @shiboken6_VERSION@
Libs: @SHIBOKEN_PYTHON_LIBRARIES@ -L${libdir} -lshiboken6@shiboken6_SUFFIX@@PYTHON_SHARED_LIBRARY_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@
-Cflags: -I@PYTHON_INCLUDE_DIRS@ -I${includedir}/@shiboken6_SUFFIX@@SBK_PKG_CONFIG_PY_DEBUG_DEFINITION@
+Cflags: -I@Python_INCLUDE_DIRS@ -I${includedir}/@shiboken6_SUFFIX@@SBK_PKG_CONFIG_PY_DEBUG_DEFINITION@
diff --git a/sources/shiboken6/doc/CMakeLists.txt b/sources/shiboken6/doc/CMakeLists.txt
index 74987703d..eaef4ff29 100644
--- a/sources/shiboken6/doc/CMakeLists.txt
+++ b/sources/shiboken6/doc/CMakeLists.txt
@@ -37,7 +37,7 @@ if(SPHINX_BUILD)
if(SHIBOKEN_IS_CROSS_BUILD)
set(python_executable "${QFP_PYTHON_HOST_PATH}")
else()
- set(python_executable "${PYTHON_EXECUTABLE}")
+ set(python_executable "${Python_EXECUTABLE}")
endif()
if(NOT python_executable OR NOT EXISTS "${python_executable}")
message(FATAL_ERROR "No python executable found to build documentation.")
diff --git a/sources/shiboken6/generator/CMakeLists.txt b/sources/shiboken6/generator/CMakeLists.txt
index 466de4325..aebe2cd5e 100644
--- a/sources/shiboken6/generator/CMakeLists.txt
+++ b/sources/shiboken6/generator/CMakeLists.txt
@@ -6,7 +6,7 @@ set(package_name "Shiboken6Tools")
set(CMAKE_AUTOMOC ON)
-if(NOT (Qt${QT_MAJOR_VERSION}Core_FOUND AND PYTHONINTERP_FOUND))
+if(NOT (Qt${QT_MAJOR_VERSION}Core_FOUND AND Python_Interpreter_FOUND))
message(WARNING "Some dependencies were not found: shiboken6 generator compilation disabled!")
return()
endif()
diff --git a/sources/shiboken6/libshiboken/CMakeLists.txt b/sources/shiboken6/libshiboken/CMakeLists.txt
index 05c779fd1..4638ca6f9 100644
--- a/sources/shiboken6/libshiboken/CMakeLists.txt
+++ b/sources/shiboken6/libshiboken/CMakeLists.txt
@@ -30,7 +30,7 @@ if(SHIBOKEN_IS_CROSS_BUILD)
set(host_python_path "${QFP_PYTHON_HOST_PATH}")
set(use_pyc_in_embedding FALSE)
else()
- set(host_python_path "${PYTHON_EXECUTABLE}")
+ set(host_python_path "${Python_EXECUTABLE}")
if(PYTHON_LIMITED_API)
set(use_pyc_in_embedding FALSE)
else()
diff --git a/sources/shiboken6/libshiboken/sbkversion.h.in b/sources/shiboken6/libshiboken/sbkversion.h.in
index 7f99abc3e..5c0b38fdb 100644
--- a/sources/shiboken6/libshiboken/sbkversion.h.in
+++ b/sources/shiboken6/libshiboken/sbkversion.h.in
@@ -10,8 +10,8 @@
#define SHIBOKEN_MICRO_VERSION @shiboken_MICRO_VERSION@
#define SHIBOKEN_RELEASE_LEVEL "final"
#define SHIBOKEN_SERIAL 0
-#define PYTHON_VERSION_MAJOR @PYTHON_VERSION_MAJOR@
-#define PYTHON_VERSION_MINOR @PYTHON_VERSION_MINOR@
-#define PYTHON_VERSION_PATCH @PYTHON_VERSION_PATCH@
+#define PYTHON_VERSION_MAJOR @Python_VERSION_MAJOR@
+#define PYTHON_VERSION_MINOR @Python_VERSION_MINOR@
+#define PYTHON_VERSION_PATCH @Python_VERSION_PATCH@
#endif
diff --git a/sources/shiboken6/tests/CMakeLists.txt b/sources/shiboken6/tests/CMakeLists.txt
index f3b096588..05f6e9e60 100644
--- a/sources/shiboken6/tests/CMakeLists.txt
+++ b/sources/shiboken6/tests/CMakeLists.txt
@@ -46,13 +46,18 @@ list(SORT TEST_FILES)
set(test_blacklist "")
if(SHIBOKEN_IS_CROSS_BUILD)
- # PYTHON_EXECUTABLE will be empty when cross-building.
+ # Python_EXECUTABLE will be empty when cross-building.
message(WARNING
"Running tests when cross-compiling is not supported because it would require running "
"a target python interpreter which might have a different architecture than the host."
)
else()
- find_package(PythonInterp REQUIRED)
+ find_package(
+ Python
+ ${USE_PYTHON_VERSION}
+ REQUIRED
+ COMPONENTS Interpreter Development
+ )
endif()
if(NOT CTEST_TESTING_TIMEOUT)
@@ -66,7 +71,7 @@ foreach(test_file ${TEST_FILES})
string(REGEX MATCH "/([^/]+)(binding|module)/([^/]+)_test.py" tmp ${test_file})
set(test_name "${CMAKE_MATCH_1}_${CMAKE_MATCH_3}")
list(FIND test_blacklist ${test_name} expect_fail)
- add_test(${test_name} ${PYTHON_EXECUTABLE} ${test_file})
+ add_test(${test_name} ${Python_EXECUTABLE} ${test_file})
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "BUILD_DIR=${BUILD_DIR}")
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${CTEST_TESTING_TIMEOUT})
if (${expect_fail} GREATER -1)