CMake 3.27 has dropped support for find_package(PythonInterp) and find_package(PythonLibs). They were deprecated since version 3.12. find_package(Python...) must be used instead.
The upshot is that we cannot get cmake to detect the presence of python when building TeXworks 0.6.9 on openSUSE Tumbleweed where we already have cmake 3.28. The patch at the end of this report gets system python recognised and cmake configuration succeeds, but we run into issue #1038 during compilation (probably unrelated).
[ 73s] CMake Warning at CMakeLists.txt:338 (FIND_PACKAGE):
[ 73s] By not providing "FindPythonInterp.cmake" in CMAKE_MODULE_PATH this project
[ 73s] has asked CMake to find a package configuration file provided by
[ 73s] "PythonInterp", but CMake did not find one.
[ 73s]
[ 73s] Could not find a package configuration file provided by "PythonInterp" with
[ 73s] any of the following names:
[ 73s]
[ 73s] PythonInterpConfig.cmake
[ 73s] pythoninterp-config.cmake
[ 73s]
[ 73s] Add the installation prefix of "PythonInterp" to CMAKE_PREFIX_PATH or set
[ 73s] "PythonInterp_DIR" to a directory containing one of the above files. If
[ 73s] "PythonInterp" provides a separate development package or SDK, be sure it
[ 73s] has been installed.
[ 73s]
[ 73s]
[ 73s] CMake Warning at CMakeLists.txt:339 (FIND_PACKAGE):
[ 73s] By not providing "FindPythonLibs.cmake" in CMAKE_MODULE_PATH this project
[ 73s] has asked CMake to find a package configuration file provided by
[ 73s] "PythonLibs", but CMake did not find one.
[ 73s]
[ 73s] Could not find a package configuration file provided by "PythonLibs" with
[ 73s] any of the following names:
[ 73s]
[ 73s] PythonLibsConfig.cmake
[ 73s] pythonlibs-config.cmake
[ 73s]
[ 73s] Add the installation prefix of "PythonLibs" to CMAKE_PREFIX_PATH or set
[ 73s] "PythonLibs_DIR" to a directory containing one of the above files. If
[ 73s] "PythonLibs" provides a separate development package or SDK, be sure it has
[ 73s] been installed.
[ 73s]
..
[ 81s] Version info
[ 81s] TeXworks: 0.6.9 (68a2e99cf, 2024-02-12T06:48:21+01:00)
[ 81s] Hunspell: yes
[ 81s] Lua: 5.3.6
[ 81s] Python:
[ 81s] Qt: 5.15.12
[ 81s] SyncTeX: 1.21
[ 81s] zlib: 1.3
[ 81s]
[ 81s] Scripting
[ 81s] ECMA scripting: yes
[ 81s] QtScript scripting: yes
[ 81s] Lua scripting plugin: yes
[ 81s] Python scripting plugin: no
[ 81s]
[ 81s] Build ID: openSUSE
[ 81s] Compiler optimization: RelWithDebInfo
Steps to reproduce the problem:
Configure with cmake >= 3.27 with the option ... -DWITH_PYTHON=ON
Expected behavior:
Should detect system python and enable python module.
General information:TeXworks version: 0.6.9
TeXworks obtained from: Source tarball from Github release page
Operating system: Linux x86_64 (openSUSE_Tumbleweed)
Python version: 3.11.7
GCC version: 13.2.1
Qt version: 5.15.12
Additional information:
Version 0.6.8 builds with the same configuration.
Fixed with the following patch (happy to submit a PR if this is acceptable):
Index: texworks-release-0.6.9/CMakeLists.txt
===================================================================
--- texworks-release-0.6.9.orig/CMakeLists.txt
+++ texworks-release-0.6.9/CMakeLists.txt
@@ -326,17 +326,14 @@ ENDIF()
IF ( WITH_PYTHON )
IF ( USE_SYSTEM_PYTHON )
- SET(PYTHON_LIBRARIES "-F/System/Library/Frameworks -framework Python" CACHE PATH "Python library.")
- SET(PYTHON_INCLUDE_DIR "/System/Library/Framework/Python.framework/Headers" CACHE PATH "Python framework.")
- MARK_AS_ADVANCED(PYTHON_LIBRARIES)
- MARK_AS_ADVANCED(PYTHON_INCLUDE_DIR)
- SET(PYTHONLIBS_FOUND TRUE)
+ SET(Python_LIBRARIES "-F/System/Library/Frameworks -framework Python" CACHE PATH "Python library.")
+ SET(Python_INCLUDE_DIR "/System/Library/Framework/Python.framework/Headers" CACHE PATH "Python framework.")
+ MARK_AS_ADVANCED(Python_LIBRARIES)
+ MARK_AS_ADVANCED(Python_INCLUDE_DIR)
+ SET(Python_Interpreter_FOUND TRUE)
+ SET(Python_Development_FOUND TRUE)
ELSE ()
- # **NOTE**
- # In order to find the correct version of 'PythonLibs', it seems that we need to run 'FIND_PACKAGE(PythonInterp)' firstly.
- # In order to find the correct version of 'PythonInterp', we need to set 'PYTHONHOME' environment variable
- FIND_PACKAGE(PythonInterp)
- FIND_PACKAGE(PythonLibs)
+ FIND_PACKAGE(Python COMPONENTS Interpreter Development)
ENDIF ()
ENDIF()
@@ -344,7 +341,7 @@ IF ( LUA_FOUND AND WITH_LUA AND NOT ${BU
ADD_DEFINITIONS(-DQT_STATICPLUGIN -DSTATIC_LUA_SCRIPTING_PLUGIN)
ENDIF ()
-IF ( PYTHONLIBS_FOUND AND WITH_PYTHON AND NOT ${BUILD_SHARED_PLUGINS})
+IF ( Python_Interpreter_FOUND AND Python_Development_FOUND AND WITH_PYTHON AND NOT ${BUILD_SHARED_PLUGINS})
ADD_DEFINITIONS(-DQT_STATICPLUGIN -DSTATIC_PYTHON_SCRIPTING_PLUGIN)
ENDIF ()
@@ -406,7 +403,7 @@ IF ( LUA_FOUND AND WITH_LUA )
ADD_SUBDIRECTORY(${TeXworks_SOURCE_DIR}/plugins-src/TWLuaPlugin)
ENDIF ()
-IF ( PYTHONLIBS_FOUND AND WITH_PYTHON )
+IF ( Python_Interpreter_FOUND AND Python_Development_FOUND AND WITH_PYTHON )
ADD_SUBDIRECTORY(${TeXworks_SOURCE_DIR}/plugins-src/TWPythonPlugin)
ENDIF ()
@@ -509,7 +506,7 @@ IF ( WITH_LUA )
CONFIG_VERSION("Lua" "${LUA_VERSION_STRING}")
ENDIF()
if (WITH_PYTHON)
- CONFIG_VERSION("Python" "${PYTHON_VERSION_STRING}")
+ CONFIG_VERSION("Python" "${Python_VERSION}")
endif()
CONFIG_VERSION("Qt" ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
CONFIG_VERSION("SyncTeX" "${SYNCTEX_VERSION_STRING}")
@@ -520,7 +517,7 @@ message(" Scripting")
CONFIG_YESNO(" ECMA scripting" ON)
CONFIG_YESNO(" QtScript scripting" WITH_QTSCRIPT)
CONFIG_YESNO(" Lua scripting plugin" LUA_FOUND)
-CONFIG_YESNO(" Python scripting plugin" PYTHONLIBS_FOUND)
+CONFIG_YESNO(" Python scripting plugin" Python_Development_FOUND)
message("")
CONFIG_INFO("Build ID" ${TW_BUILD_ID})
Index: texworks-release-0.6.9/plugins-src/TWPythonPlugin/CMakeLists.txt
===================================================================
--- texworks-release-0.6.9.orig/plugins-src/TWPythonPlugin/CMakeLists.txt
+++ texworks-release-0.6.9/plugins-src/TWPythonPlugin/CMakeLists.txt
@@ -37,13 +37,13 @@ if (NOT MSVC)
target_compile_options(TWPythonPlugin PRIVATE -Wno-old-style-cast)
endif ()
-target_include_directories(TWPythonPlugin SYSTEM PRIVATE ${PYTHON_INCLUDE_DIRS})
+target_include_directories(TWPythonPlugin SYSTEM PRIVATE ${Python_INCLUDE_DIRS})
target_include_directories(TWPythonPlugin PRIVATE ${TeXworks_SOURCE_DIR}/src)
# Specify link libraries even if the plugin is built statically so all the
# interface properties of the Qt targets (include directories, lib directories,
# etc.) are available
-TARGET_LINK_LIBRARIES(TWPythonPlugin ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${TEXWORKS_ADDITIONAL_LIBS})
+TARGET_LINK_LIBRARIES(TWPythonPlugin ${QT_LIBRARIES} ${Python_LIBRARIES} ${TEXWORKS_ADDITIONAL_LIBS})
IF (${BUILD_SHARED_PLUGINS})
INSTALL(TARGETS TWPythonPlugin
LIBRARY DESTINATION ${TeXworks_PLUGIN_DIR}
Index: texworks-release-0.6.9/src/CMakeLists.txt
===================================================================
--- texworks-release-0.6.9.orig/src/CMakeLists.txt
+++ texworks-release-0.6.9/src/CMakeLists.txt
@@ -207,8 +207,8 @@ IF (NOT ${BUILD_SHARED_PLUGINS})
IF (WITH_LUA AND LUA_FOUND)
LIST(INSERT TeXworks_LIBS 0 TWLuaPlugin ${LUA_LIBRARIES})
ENDIF()
- IF (WITH_PYTHON AND PYTHONLIBS_FOUND)
- LIST(INSERT TeXworks_LIBS 0 TWPythonPlugin ${PYTHON_LIBRARIES})
+ IF (WITH_PYTHON AND Python_Development_FOUND)
+ LIST(INSERT TeXworks_LIBS 0 TWPythonPlugin ${Python_LIBRARIES})
ENDIF()
ENDIF()
Bug description:
CMake 3.27 has dropped support for
find_package(PythonInterp)
andfind_package(PythonLibs)
. They were deprecated since version 3.12.find_package(Python...)
must be used instead.The upshot is that we cannot get cmake to detect the presence of python when building TeXworks 0.6.9 on openSUSE Tumbleweed where we already have cmake 3.28. The patch at the end of this report gets system python recognised and cmake configuration succeeds, but we run into issue #1038 during compilation (probably unrelated).
Steps to reproduce the problem:
cmake >= 3.27
with the option... -DWITH_PYTHON=ON
Expected behavior:
Should detect system python and enable python module.
General information: TeXworks version: 0.6.9 TeXworks obtained from: Source tarball from Github release page Operating system: Linux x86_64 (openSUSE_Tumbleweed) Python version: 3.11.7 GCC version: 13.2.1 Qt version: 5.15.12
Additional information: Version 0.6.8 builds with the same configuration.
Fixed with the following patch (happy to submit a PR if this is acceptable):