Control: tags -1 + patch Hi again Rafael!
On Tue, Dec 01, 2020 at 06:02:47PM +0100, Rafael Laboissière wrote: > I tried to build PLplot with my changes for SIP5 and againts version > 5.15.2+dfsg-1 of pyqt5-dev. It still fails with the error below. I have just noticed that the emails I sent to plplot-devel mailing list have not reached it for some reason and do not show up in the archives [1]. Maybe I need to be subscribed, or there is some moderation? In my email from 2020-12-03 there was a patch to port to SIP 5/6. I am attaching this patch here. The upstream developer (Alan W. Irwin) was one of the recipients, so I hope he got that mail. Copying the contents of my mail below, with slight corrections: I have attached a draft patch that makes plplot build successfully with sip-build. It retains compatibility with SIP 4, although I have not tested that version. My approach abuses the SIP's build system. sip-build generates a .pro file for qmake and tries to run qmake by default. I decided that it's better to rely on CMake to do the actual compilation (e.g. so that all compiler flags are honored), so I pass --no-build to sip-build and then copy the .cpp and .h files it generated to CMake's build directory, then let CMake build them. SIP adds two defines to the .pro file: SIP_PROTECTED_IS_PUBLIC and protected=public. This is needed to fix errors like: build/plplot_pyqt5/sipplplot_pyqt5QtExtWidget.cpp:1476:67: error: ‘virtual void QtExtWidget::paintEvent(QPaintEvent*)’ is protected within this context 1476 | (sipSelfWasArg ? sipCpp-> ::QtExtWidget::paintEvent(a0) : sipCpp->paintEvent(a0)); | ^ So I have copied these two defines to CMake code. SIP does not add them on Windows but I think they won't hurt there. How to test it: - With Debian packages: sudo apt install sip-tools python3-pyqtbuild - With upstream packages: pip install sip PyQt-builder Then build as usual (the code prefers SIP 5/6 to 4 if both are available). Please test it and let me know what you think. [1]: https://sourceforge.net/p/plplot/mailman/plplot-devel/?viewmonth=202012 -- Dmitry Shachnev
>From 508b5e3db060804f670a42454873a7b510c5c1a7 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev <mity...@gmail.com> Date: Wed, 9 Dec 2020 22:36:03 +0300 Subject: [PATCH] Add support for building with sip-build --- bindings/qt_gui/pyqt5/CMakeLists.txt | 27 +++++++++++++++++++++++---- bindings/qt_gui/pyqt5/pyproject.toml | 13 +++++++++++++ cmake/modules/qt.cmake | 25 ++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 bindings/qt_gui/pyqt5/pyproject.toml diff --git a/bindings/qt_gui/pyqt5/CMakeLists.txt b/bindings/qt_gui/pyqt5/CMakeLists.txt index d056657..326d3bf 100644 --- a/bindings/qt_gui/pyqt5/CMakeLists.txt +++ b/bindings/qt_gui/pyqt5/CMakeLists.txt @@ -42,11 +42,30 @@ if(ENABLE_pyqt5) #message("DEBUG: PYQT_SIP_DIR = ${PYQT_SIP_DIR}") #message("DEBUG: PYQT_SIP_FLAGS = ${PYQT_SIP_FLAGS}") - add_custom_command( - OUTPUT ${plplot_pyqt5_HDR} ${plplot_pyqt5_SRC} - COMMAND ${SIP_EXECUTABLE} -c . -b plplot_pyqt5.sbf -I${PYQT_SIP_DIR} ${PYQT_SIP_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/plplot_pyqt5.sip - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/plplot_pyqt5.sip + if(SIPBUILD_EXECUTABLE) + configure_file(plplot_pyqt5.sip plplot_pyqt5.sip COPYONLY) + configure_file(pyproject.toml pyproject.toml COPYONLY) + add_custom_command( + OUTPUT ${plplot_pyqt5_HDR} ${plplot_pyqt5_SRC} + COMMAND ${SIPBUILD_EXECUTABLE} --no-make + ) + set(FILES_TO_COPY ${plplot_pyqt5_HDR} ${plplot_pyqt5_SRC}) + list(TRANSFORM FILES_TO_COPY REPLACE .*/ build/plplot_pyqt5/) + add_custom_command( + OUTPUT ${plplot_pyqt5_HDR} ${plplot_pyqt5_SRC} APPEND + COMMAND ${CMAKE_COMMAND} -E copy ${FILES_TO_COPY} build/sip.h ${CMAKE_CURRENT_BINARY_DIR} + ) + add_compile_definitions( + SIP_PROTECTED_IS_PUBLIC + protected=public ) + else(SIPBUILD_EXECUTABLE) + add_custom_command( + OUTPUT ${plplot_pyqt5_HDR} ${plplot_pyqt5_SRC} + COMMAND ${SIP_EXECUTABLE} -c . -b plplot_pyqt5.sbf -I${PYQT_SIP_DIR} ${PYQT_SIP_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/plplot_pyqt5.sip + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/plplot_pyqt5.sip + ) + endif(SIPBUILD_EXECUTABLE) add_custom_target(generate_pyqt5_source DEPENDS ${plplot_pyqt5_HDR} ${plplot_pyqt5_SRC} ) diff --git a/bindings/qt_gui/pyqt5/pyproject.toml b/bindings/qt_gui/pyqt5/pyproject.toml new file mode 100644 index 0000000..165be2d --- /dev/null +++ b/bindings/qt_gui/pyqt5/pyproject.toml @@ -0,0 +1,13 @@ +[tool.sip] +project-factory = "pyqtbuild:PyQtProject" +bindings-factory = "pyqtbuild:PyQtBindings" + +[tool.sip.metadata] +name = "plplot" + +[tool.sip.project] +sip-files-dir = "." + +[tool.sip.bindings.plplot] +sip-file = "plplot_pyqt5.sip" +qmake-QT = ["printsupport", "widgets"] diff --git a/cmake/modules/qt.cmake b/cmake/modules/qt.cmake index 75be8ad..2f4ffca 100644 --- a/cmake/modules/qt.cmake +++ b/cmake/modules/qt.cmake @@ -62,7 +62,8 @@ # ENABLE_pyqt5 - ON means the plplot_pyqt5 Python extension module # is enabled. # ENABLE_smoke - ON means the smoke plplotqt library is enabled. -# SIP_EXECUTABLE - full path for sip +# SIPBUILD_EXECUTABLE - full path for sip-build (SIP v5, v6) +# SIP_EXECUTABLE - full path for sip (SIP v4) # PYQT_SIP_DIR - sip system directory containing QtCore/QtCoremod.sip (and other required sip files). # PYQT_SIP_FLAGS - sip command flags @@ -401,7 +402,25 @@ if(ANY_QT_DEVICE) endif(ENABLE_DYNDRIVERS) endif(ANY_QT_DEVICE) -if(ENABLE_pyqt4 OR ENABLE_pyqt5) +if(ENABLE_pyqt5) + find_program(SIPBUILD_EXECUTABLE sip-build) + message(STATUS "pyqt: SIPBUILD_EXECUTABLE = ${SIPBUILD_EXECUTABLE}") + if (SIPBUILD_EXECUTABLE) + execute_process( + COMMAND ${SIPBUILD_EXECUTABLE} -V + OUTPUT_VARIABLE SIP_VERSION + RESULT_VARIABLE SIP_VERSION_ERR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(SIP_VERSION_ERR) + message(AUTHOR_WARNING "sip-build -V command could not determine sip version") + else(SIP_VERSION_ERR) + message(STATUS "SIP_VERSION = ${SIP_VERSION}") + endif(SIP_VERSION_ERR) + endif(SIPBUILD_EXECUTABLE) +endif(ENABLE_pyqt5) + +if(ENABLE_pyqt4 OR (ENABLE_pyqt5 AND NOT SIPBUILD_EXECUTABLE)) find_program(SIP_EXECUTABLE sip) message(STATUS "pyqt: SIP_EXECUTABLE = ${SIP_EXECUTABLE}") if(SIP_EXECUTABLE) @@ -566,7 +585,7 @@ if(ENABLE_pyqt4 OR ENABLE_pyqt5) set(ENABLE_pyqt4 OFF CACHE BOOL "Enable pyqt4 Python extension module " FORCE) set(ENABLE_pyqt5 OFF CACHE BOOL "Enable pyqt5 Python extension module " FORCE) endif(SIP_EXECUTABLE) -endif(ENABLE_pyqt4 OR ENABLE_pyqt5) +endif(ENABLE_pyqt4 OR (ENABLE_pyqt5 AND NOT SIPBUILD_EXECUTABLE)) if(ENABLE_smoke) if(PLPLOT_USE_QT5) -- 2.25.1