diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-02 09:52:19 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-02 11:03:05 +0000 |
commit | 4544a943ca2df4e6f0ac24914f0c0f844dc6f748 (patch) | |
tree | 140904c3265894dbdd3ed7f864cbdb2ddc04a7c9 /examples/scriptableapplication | |
parent | 559c56b140410bcfa0ce6f19b47d1ba0daa9a201 (diff) |
Binding Example helpers: Remove version numbers
- Rename the scripts
- Introduce variables for the versions in pyside_config.py
Change-Id: I1dcb8ca7eee259f25af0db7c09abd30484c7e99c
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/scriptableapplication')
-rw-r--r-- | examples/scriptableapplication/CMakeLists.txt | 52 | ||||
-rw-r--r-- | examples/scriptableapplication/README.md | 31 | ||||
-rw-r--r-- | examples/scriptableapplication/pyside.pri | 52 | ||||
-rw-r--r-- | examples/scriptableapplication/pyside2.pri | 52 | ||||
-rw-r--r-- | examples/scriptableapplication/scriptableapplication.pro | 14 |
5 files changed, 100 insertions, 101 deletions
diff --git a/examples/scriptableapplication/CMakeLists.txt b/examples/scriptableapplication/CMakeLists.txt index 2ccb9897d..63a4afd35 100644 --- a/examples/scriptableapplication/CMakeLists.txt +++ b/examples/scriptableapplication/CMakeLists.txt @@ -23,7 +23,7 @@ endif() message(STATUS "Using python interpreter: ${python_interpreter}") # Macro to get various pyside / python include / link flags. -macro(pyside2_config option output_var) +macro(pyside_config option output_var) if(${ARGC} GREATER 2) set(is_list ${ARGV2}) else() @@ -31,13 +31,13 @@ macro(pyside2_config option output_var) endif() execute_process( - COMMAND ${python_interpreter} "${CMAKE_SOURCE_DIR}/../utils/pyside2_config.py" + COMMAND ${python_interpreter} "${CMAKE_SOURCE_DIR}/../utils/pyside_config.py" ${option} OUTPUT_VARIABLE ${output_var} OUTPUT_STRIP_TRAILING_WHITESPACE) if ("${${output_var}}" STREQUAL "") - message(FATAL_ERROR "Error: Calling pyside2_config.py ${option} returned no output.") + message(FATAL_ERROR "Error: Calling pyside_config.py ${option} returned no output.") endif() if(is_list) string (REPLACE " " ";" ${output_var} "${${output_var}}") @@ -45,19 +45,19 @@ macro(pyside2_config option output_var) endmacro() # Query for the shiboken6-generator path, PySide2 path, Python path, include paths and linker flags. -pyside2_config(--shiboken6-module-path SHIBOKEN6_MODULE_PATH) -pyside2_config(--shiboken6-generator-path SHIBOKEN6_GENERATOR_PATH) -pyside2_config(--pyside2-path PYSIDE2_PATH) +pyside_config(--shiboken-module-path SHIBOKEN_MODULE_PATH) +pyside_config(--shiboken-generator-path SHIBOKEN_GENERATOR_PATH) +pyside_config(--pyside-path PYSIDE_PATH) -pyside2_config(--python-include-path PYTHON_INCLUDE_DIR) -pyside2_config(--shiboken6-generator-include-path SHIBOKEN6_GENERATOR_INCLUDE_DIR 1) -pyside2_config(--pyside2-include-path PYSIDE2_INCLUDE_DIR 1) +pyside_config(--python-include-path PYTHON_INCLUDE_DIR) +pyside_config(--shiboken-generator-include-path SHIBOKEN_GENERATOR_INCLUDE_DIR 1) +pyside_config(--pyside-include-path PYSIDE_INCLUDE_DIR 1) -pyside2_config(--python-link-flags-cmake PYTHON_LINKING_DATA 0) -pyside2_config(--shiboken6-module-shared-libraries-cmake SHIBOKEN6_MODULE_SHARED_LIBRARIES 0) -pyside2_config(--pyside2-shared-libraries-cmake PYSIDE2_SHARED_LIBRARIES 0) +pyside_config(--python-link-flags-cmake PYTHON_LINKING_DATA 0) +pyside_config(--shiboken-module-shared-libraries-cmake SHIBOKEN_MODULE_SHARED_LIBRARIES 0) +pyside_config(--pyside-shared-libraries-cmake PYSIDE_SHARED_LIBRARIES 0) -set(SHIBOKEN_PATH "${SHIBOKEN6_GENERATOR_PATH}/shiboken6${CMAKE_EXECUTABLE_SUFFIX}") +set(SHIBOKEN_PATH "${SHIBOKEN_GENERATOR_PATH}/shiboken6${CMAKE_EXECUTABLE_SUFFIX}") if(NOT EXISTS ${SHIBOKEN_PATH}) message(FATAL_ERROR "Shiboken executable not found at path: ${SHIBOKEN_PATH}") @@ -93,7 +93,7 @@ set(SHIBOKEN_OPTIONS --generator-set=shiboken --enable-parent-ctor-heuristic ${INCLUDES} -I${CMAKE_SOURCE_DIR} -T${CMAKE_SOURCE_DIR} - -T${PYSIDE2_PATH}/typesystems + -T${PYSIDE_PATH}/typesystems --output-directory=${CMAKE_CURRENT_BINARY_DIR} ) @@ -123,11 +123,11 @@ set(SOURCES ) # We need to include the headers for the module bindings that we use. -set(PYSIDE2_ADDITIONAL_INCLUDES "") -foreach(INCLUDE_DIR ${PYSIDE2_INCLUDE_DIR}) - list(APPEND PYSIDE2_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtCore") - list(APPEND PYSIDE2_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtGui") - list(APPEND PYSIDE2_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtWidgets") +set(PYSIDE_ADDITIONAL_INCLUDES "") +foreach(INCLUDE_DIR ${PYSIDE_INCLUDE_DIR}) + list(APPEND PYSIDE_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtCore") + list(APPEND PYSIDE_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtGui") + list(APPEND PYSIDE_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtWidgets") endforeach() # ============================================================================================= @@ -137,7 +137,7 @@ endforeach() # Enable rpaths so that the example can be executed from the build dir. set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -set(CMAKE_INSTALL_RPATH ${PYSIDE2_PATH} ${SHIBOKEN6_MODULE_PATH}) +set(CMAKE_INSTALL_RPATH ${PYSIDE_PATH} ${SHIBOKEN_MODULE_PATH}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # ============================================================================================= # !!! End of dubious section. @@ -154,14 +154,14 @@ target_sources(${PROJECT_NAME} PUBLIC ${SOURCES}) # Apply relevant include and link flags. target_include_directories(${PROJECT_NAME} PRIVATE ${PYTHON_INCLUDE_DIR}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SHIBOKEN6_GENERATOR_INCLUDE_DIR}) -target_include_directories(${PROJECT_NAME} PRIVATE ${PYSIDE2_INCLUDE_DIR}) -target_include_directories(${PROJECT_NAME} PRIVATE ${PYSIDE2_ADDITIONAL_INCLUDES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${SHIBOKEN_GENERATOR_INCLUDE_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${PYSIDE_ADDITIONAL_INCLUDES}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets) -target_link_libraries(${PROJECT_NAME} PRIVATE ${SHIBOKEN6_MODULE_SHARED_LIBRARIES}) -target_link_libraries(${PROJECT_NAME} PRIVATE ${PYSIDE2_SHARED_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${SHIBOKEN_MODULE_SHARED_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${PYSIDE_SHARED_LIBRARIES}) # Find and link to the python library. list(GET PYTHON_LINKING_DATA 0 PYTHON_LIBDIR) @@ -193,7 +193,7 @@ if(WIN32) # Add custom target to hard link PySide2 shared libraries (just like in qmake example), so you # don't have to set PATH manually to point to the PySide2 package. - set(shared_libraries ${SHIBOKEN6_MODULE_SHARED_LIBRARIES} ${PYSIDE2_SHARED_LIBRARIES}) + set(shared_libraries ${SHIBOKEN_MODULE_SHARED_LIBRARIES} ${PYSIDE_SHARED_LIBRARIES}) foreach(LIBRARY_PATH ${shared_libraries}) string(REGEX REPLACE ".lib$" ".dll" LIBRARY_PATH ${LIBRARY_PATH}) get_filename_component(BASE_NAME ${LIBRARY_PATH} NAME) diff --git a/examples/scriptableapplication/README.md b/examples/scriptableapplication/README.md index c388f61de..908cac36b 100644 --- a/examples/scriptableapplication/README.md +++ b/examples/scriptableapplication/README.md @@ -26,31 +26,30 @@ This example can be built using *CMake* or *QMake*, but there are common requirements that you need to take into consideration: -* Make sure that a --standalone PySide2 package (bundled with Qt libraries) +* Make sure that a --standalone PySide package (bundled with Qt libraries) is installed into the current active Python environment (system or virtualenv) * qmake has to be in your PATH: - * so that CMake find_package(Qt5) works (used for include headers), + * so that CMake find_package(Qt6 COMPONENTS Core) works (used for include + headers), * used for building the application with qmake instead of CMake * use the same Qt version for building the example application, as was used - for building PySide2, this is to ensure binary compatibility between the - newly generated bindings libraries, the PySide2 libraries and the + for building PySide, this is to ensure binary compatibility between the + newly generated bindings libraries, the PySide libraries and the Qt libraries. For Windows you will also need: * a Visual Studio environment to be active in your terminal * Correct visual studio architecture chosen (32 vs 64 bit) -* Make sure that your Qt + Python + PySide2 package + app build configuration +* Make sure that your Qt + Python + PySide package + app build configuration is the same (all Release, which is more likely, or all Debug). -* Make sure that your Qt + Python + PySide2 package + app are built with the +* Make sure that your Qt + Python + PySide package + app are built with the same version of MSVC, to avoid mixing of C++ runtime libraries. In principle this means that if you use the python.org provided Python - interpreters, you need to use MSVC2015 for Python 3 projects, and MSVC2008 - for Python 2 projects. Which also means that you can't use official Qt - packages, because none of the supported ones are built with MSVC2008. + interpreters, you need to use MSVC2015 for Python 3 projects. -Both build options will use the `pyside2_config.py` file to configure the project -using the current PySide2/Shiboken6 installation (for qmake via pyside2.pri, +Both build options will use the `pyside_config.py` file to configure the project +using the current PySide/Shiboken installation (for qmake via pyside.pri, and for CMake via the project CMakeLists.txt). @@ -136,7 +135,7 @@ virtual environment, that environment's packages will be used for the python module import process. In this case, make sure that the application was built while the `virtualenv` was active, so that the build system picks up the correct -python shared library and PySide2 package. +python shared library and PySide package. ## Linux Shared Libraries Notes @@ -155,12 +154,12 @@ work. In practice this means the only supported configurations are: 1. release config build of the application + - PySide2 `setup.py` without `--debug` flag + `python.exe` for the - PySide2 build process + `python36.dll` for the linked in shared + PySide `setup.py` without `--debug` flag + `python.exe` for the + PySide build process + `python36.dll` for the linked in shared library + release build of Qt. 2. debug config build of the application + - PySide2 `setup.py` **with** `--debug` flag + `python_d.exe` for the - PySide2 build process + `python36_d.dll` for the linked in shared + PySide `setup.py` **with** `--debug` flag + `python_d.exe` for the + PySide build process + `python36_d.dll` for the linked in shared library + debug build of Qt. This is necessary because all the shared libraries in question have to diff --git a/examples/scriptableapplication/pyside.pri b/examples/scriptableapplication/pyside.pri new file mode 100644 index 000000000..39c8a674d --- /dev/null +++ b/examples/scriptableapplication/pyside.pri @@ -0,0 +1,52 @@ +PYSIDE_CONFIG = $$PWD/../utils/pyside_config.py + +# Use provided python interpreter if given. +isEmpty(python_interpreter) { + python_interpreter = python +} +message(Using python interpreter: $$python_interpreter) + +SHIBOKEN_GENERATOR = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken-generator-path) +isEmpty(SHIBOKEN_GENERATOR): error(Unable to locate the shiboken-generator package location) + +SHIBOKEN_MODULE = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken-module-path) +isEmpty(SHIBOKEN_MODULE): error(Unable to locate the shiboken package location) + +PYSIDE = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside-path) +isEmpty(PYSIDE): error(Unable to locate the PySide package location) + +PYTHON_INCLUDE = $$system($$python_interpreter $$PYSIDE_CONFIG --python-include-path) +isEmpty(PYTHON_INCLUDE): error(Unable to locate the Python include headers directory) + +PYTHON_LFLAGS = $$system($$python_interpreter $$PYSIDE_CONFIG --python-link-flags-qmake) +isEmpty(PYTHON_LFLAGS): error(Unable to locate the Python library for linking) + +SHIBOKEN_INCLUDE = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken-generator-include-path) +isEmpty(SHIBOKEN_INCLUDE): error(Unable to locate the shiboken include headers directory) + +PYSIDE_INCLUDE = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside-include-path) +isEmpty(PYSIDE_INCLUDE): error(Unable to locate PySide include headers directory) + +SHIBOKEN_LFLAGS = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken-module-qmake-lflags) +isEmpty(SHIBOKEN_LFLAGS): error(Unable to locate the shiboken libraries for linking) + +PYSIDE_LFLAGS = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside-qmake-lflags) +isEmpty(PYSIDE_LFLAGS): error(Unable to locate the PySide libraries for linking) + +SHIBOKEN_SHARED_LIBRARIES = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken-module-shared-libraries-qmake) +isEmpty(SHIBOKEN_SHARED_LIBRARIES): error(Unable to locate the used shiboken module shared libraries) + +PYSIDE_SHARED_LIBRARIES = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside-shared-libraries-qmake) +isEmpty(PYSIDE_SHARED_LIBRARIES): error(Unable to locate the used PySide shared libraries) + +INCLUDEPATH += "$$PYTHON_INCLUDE" $$PYSIDE_INCLUDE $$SHIBOKEN_INCLUDE +LIBS += $$PYTHON_LFLAGS $$PYSIDE_LFLAGS $$SHIBOKEN_LFLAGS +!build_pass:message(INCLUDEPATH is $$INCLUDEPATH) +!build_pass:message(LIBS are $$LIBS) + +!build_pass:message(Using $$PYSIDE) + +!win32 { + !build_pass:message(RPATH will include $$PYSIDE and $$SHIBOKEN_MODULE) + QMAKE_RPATHDIR += $$PYSIDE $$SHIBOKEN_MODULE +} diff --git a/examples/scriptableapplication/pyside2.pri b/examples/scriptableapplication/pyside2.pri deleted file mode 100644 index d97ad229a..000000000 --- a/examples/scriptableapplication/pyside2.pri +++ /dev/null @@ -1,52 +0,0 @@ -PYSIDE_CONFIG = $$PWD/../utils/pyside2_config.py - -# Use provided python interpreter if given. -isEmpty(python_interpreter) { - python_interpreter = python -} -message(Using python interpreter: $$python_interpreter) - -SHIBOKEN6_GENERATOR = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken6-generator-path) -isEmpty(SHIBOKEN6_GENERATOR): error(Unable to locate the shiboken6-generator package location) - -SHIBOKEN6_MODULE = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken6-module-path) -isEmpty(SHIBOKEN6_MODULE): error(Unable to locate the shiboken6 package location) - -PYSIDE2 = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside2-path) -isEmpty(PYSIDE2): error(Unable to locate the PySide2 package location) - -PYTHON_INCLUDE = $$system($$python_interpreter $$PYSIDE_CONFIG --python-include-path) -isEmpty(PYTHON_INCLUDE): error(Unable to locate the Python include headers directory) - -PYTHON_LFLAGS = $$system($$python_interpreter $$PYSIDE_CONFIG --python-link-flags-qmake) -isEmpty(PYTHON_LFLAGS): error(Unable to locate the Python library for linking) - -SHIBOKEN6_INCLUDE = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken6-generator-include-path) -isEmpty(SHIBOKEN6_INCLUDE): error(Unable to locate the shiboken include headers directory) - -PYSIDE2_INCLUDE = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside2-include-path) -isEmpty(PYSIDE2_INCLUDE): error(Unable to locate the PySide2 include headers directory) - -SHIBOKEN6_LFLAGS = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken6-module-qmake-lflags) -isEmpty(SHIBOKEN6_LFLAGS): error(Unable to locate the shiboken libraries for linking) - -PYSIDE2_LFLAGS = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside2-qmake-lflags) -isEmpty(PYSIDE2_LFLAGS): error(Unable to locate the PySide2 libraries for linking) - -SHIBOKEN6_SHARED_LIBRARIES = $$system($$python_interpreter $$PYSIDE_CONFIG --shiboken6-module-shared-libraries-qmake) -isEmpty(SHIBOKEN6_SHARED_LIBRARIES): error(Unable to locate the used shiboken6 module shared libraries) - -PYSIDE2_SHARED_LIBRARIES = $$system($$python_interpreter $$PYSIDE_CONFIG --pyside2-shared-libraries-qmake) -isEmpty(PYSIDE2_SHARED_LIBRARIES): error(Unable to locate the used PySide2 shared libraries) - -INCLUDEPATH += "$$PYTHON_INCLUDE" $$PYSIDE2_INCLUDE $$SHIBOKEN6_INCLUDE -LIBS += $$PYTHON_LFLAGS $$PYSIDE2_LFLAGS $$SHIBOKEN6_LFLAGS -!build_pass:message(INCLUDEPATH is $$INCLUDEPATH) -!build_pass:message(LIBS are $$LIBS) - -!build_pass:message(Using $$PYSIDE2) - -!win32 { - !build_pass:message(RPATH will include $$PYSIDE2 and $$SHIBOKEN6_MODULE) - QMAKE_RPATHDIR += $$PYSIDE2 $$SHIBOKEN6_MODULE -} diff --git a/examples/scriptableapplication/scriptableapplication.pro b/examples/scriptableapplication/scriptableapplication.pro index 067d9141f..148a22546 100644 --- a/examples/scriptableapplication/scriptableapplication.pro +++ b/examples/scriptableapplication/scriptableapplication.pro @@ -3,7 +3,7 @@ CONFIG += no_keywords # avoid clash with slots in Python.h CONFIG += console force_debug_info QT += widgets -include(pyside2.pri) +include(pyside.pri) WRAPPED_HEADER = wrappedclasses.h WRAPPER_DIR = $$OUT_PWD/AppLib @@ -17,13 +17,13 @@ qtConfig(framework): QT_INCLUDEPATHS += --framework-include-paths=$$[QT_INSTALL_ SHIBOKEN_OPTIONS = --generator-set=shiboken --enable-parent-ctor-heuristic \ --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb_nonzero \ - $$QT_INCLUDEPATHS -I$$PWD -T$$PWD -T$$PYSIDE2/typesystems --output-directory=$$OUT_PWD + $$QT_INCLUDEPATHS -I$$PWD -T$$PWD -T$$PYSIDE/typesystems --output-directory=$$OUT_PWD # MSVC does not honor #define protected public... win32:SHIBOKEN_OPTIONS += --avoid-protected-hack # Prepare the shiboken tool -QT_TOOL.shiboken.binary = $$system_path($$SHIBOKEN6_GENERATOR/shiboken6) +QT_TOOL.shiboken.binary = $$system_path($$SHIBOKEN_GENERATOR/shiboken6) qtPrepareTool(SHIBOKEN, shiboken) # Shiboken run that adds the module wrapper to GENERATED_SOURCES @@ -51,7 +51,7 @@ defineReplace(getOutDir) { return($$out_dir) } -# Create hardlinks to the PySide2 shared libraries, so the example can be executed without manually +# Create hardlinks to the PySide shared libraries, so the example can be executed without manually # setting the PATH. win32 { out_dir = $$getOutDir() @@ -61,7 +61,7 @@ win32 { hard_link_libraries.CONFIG = no_link target_predeps explicit_dependencies hard_link_libraries.output = $$out_dir/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} hard_link_libraries.commands = mklink /H $$shell_path($$out_dir/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}) $$shell_path(${QMAKE_FILE_IN}) - hard_link_libraries.input = PYSIDE2_SHARED_LIBRARIES SHIBOKEN6_SHARED_LIBRARIES + hard_link_libraries.input = PYSIDE_SHARED_LIBRARIES SHIBOKEN6_SHARED_LIBRARIES } QMAKE_EXTRA_COMPILERS += shiboken module_wrapper_dummy_command @@ -69,7 +69,7 @@ win32:QMAKE_EXTRA_COMPILERS += hard_link_libraries INCLUDEPATH += $$WRAPPER_DIR -for(i, PYSIDE2_INCLUDE) { +for(i, PYSIDE_INCLUDE) { INCLUDEPATH += $$i/QtWidgets $$i/QtGui $$i/QtCore } @@ -82,4 +82,4 @@ HEADERS += \ mainwindow.h \ pythonutils.h -OTHER_FILES += $$TYPESYSTEM_FILE $$WRAPPED_HEADER pyside2_config.py README.md +OTHER_FILES += $$TYPESYSTEM_FILE $$WRAPPED_HEADER pyside_config.py README.md |