From 91d37a1381b77c12a1c99ea43f5b1bf464a0ff40 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 23 Aug 2017 16:47:14 +0200 Subject: Streamline Qt5 detection on macOS This consists of a few things: - Remove the detection and usage of ALTERNATIVE_QT_INCLUDE_DIR in setup.py, because CMake takes care of finding the correct Qt include headers. - Add detection of framework / non-framework includes in the CMake rules, instead of in the setup.py script. - Don't pass QT_QMAKE_EXECUTABLE from setup.py to CMake, because it is not being used. It was previously used for detecting Qt4 via the CMake FindQt4.cmake file. Now it is done by find_package() which detects qmake from the environment. - Get rid of the old "/Library/Frameworks" QT_INCLUDE_DIR, which was where the official Qt 4.8.x packages installed Qt. - Deprecate usage of ALTERNATIVE_QT_INCLUDE_DIR. Now it is only used if CMake fails to detect the proper include headers of Qt5 (which should not happen). Change-Id: I829b92bc0d40ae7eb418be27c735fc095e557820 Reviewed-by: Christian Tismer --- setup.py | 13 ------------- sources/pyside2/CMakeLists.txt | 39 +++++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index af33254ca..ce67ef942 100644 --- a/setup.py +++ b/setup.py @@ -801,7 +801,6 @@ class pyside_build(_build): cmake_cmd = [ OPTION_CMAKE, "-G", self.make_generator, - "-DQT_QMAKE_EXECUTABLE='%s'" % self.qtinfo.qmake_command, "-DBUILD_TESTS=%s" % self.build_tests, "-DQt5Help_DIR=%s" % self.qtinfo.docs_dir, "-DCMAKE_BUILD_TYPE=%s" % self.build_type, @@ -823,18 +822,6 @@ class pyside_build(_build): cmake_cmd.append("-DUSE_PYTHON_VERSION=3.3") if sys.platform == 'darwin': - # Shiboken supports specifying multiple include paths separated by a colon on *nix - # systems. - # In a framework build, two paths should be included: - # path_to_qt/lib -> which contains framework folders with headers, and - # path_to_qt/include -> which contains headers for static libraries. - # A non-framework build contains all headers in the path_to_qt/include folder. - path_separator = ":" - includes_dir = '-DALTERNATIVE_QT_INCLUDE_DIR=' + self.qtinfo.headers_dir - if os.path.isdir(self.qtinfo.headers_dir + "/../lib/QtCore.framework"): - includes_dir += path_separator + self.qtinfo.headers_dir + "/../lib/" - cmake_cmd.append(includes_dir) - if OPTION_OSXARCH: # also tell cmake which architecture to use cmake_cmd.append("-DCMAKE_OSX_ARCHITECTURES:STRING={}".format(OPTION_OSXARCH)) diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index f5e4102c4..5b7de8d24 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -97,19 +97,34 @@ option(ENABLE_VERSION_SUFFIX "Used to use current version in suffix to generated set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) if(CMAKE_HOST_APPLE) - set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "The Alternative value to QT_INCLUDE_DIR. Necessary to fix bug on cmake 2.8 MACOS users") + set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "Deprecated. CMake now finds the proper include dir itself.") set(OSX_USE_LIBCPP "OFF" CACHE BOOL "Explicitly link the libc++ standard library (useful for osx deployment targets lower than 10.9.") if(OSX_USE_LIBCPP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() -if(NOT CMAKE_HOST_APPLE) - # Qt5: QT_INCLUDE_DIR does no longer exist. - # On Windows and Linux, it can be computed from Qt5Core_INCLUDE_DIRS - message("Qt5Core_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS}") - list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR) - message(STATUS "*** computed QT_INCLUDE_DIR as ${QT_INCLUDE_DIR}") +# Qt5: QT_INCLUDE_DIR does no longer exist. +# On Windows, macOS, and Linux it can be computed from Qt5Core_INCLUDE_DIRS, which contains +# a list of include directories. We take the first one. +message(STATUS "*** Qt5Core_INCLUDE_DIRS = ${Qt5Core_INCLUDE_DIRS}") +list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR) + +# On macOS, check if Qt is a framework build. This affects how include paths should be handled. +get_target_property(QtCore_is_framework Qt5::Core FRAMEWORK) + +if (QtCore_is_framework) + # Get the path to the framework dir. + get_filename_component(QT_FRAMEWORK_INCLUDE_DIR "${QT_INCLUDE_DIR}/../" ABSOLUTE) + message(STATUS "*** QT_FRAMEWORK_INCLUDE_DIR is ${QT_FRAMEWORK_INCLUDE_DIR}") + + # QT_INCLUDE_DIR points to the QtCore.framework directory, so we need to adjust this to point + # to the actual include directory, which has include files for non-framework parts of Qt. + get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}/../../include" ABSOLUTE) + + # And then we append the framework dir, to mimic the way setup.py passed that in before to + # the old shiboken parser. + set(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}:${QT_FRAMEWORK_INCLUDE_DIR}") endif() if(MSVC) @@ -130,15 +145,15 @@ else() endif() if(CMAKE_HOST_APPLE) - if (NOT QT_INCLUDE_DIR) - set(QT_INCLUDE_DIR "/Library/Frameworks") - endif() - if(ALTERNATIVE_QT_INCLUDE_DIR) + # ALTERNATIVE_QT_INCLUDE_DIR is deprecated, because CMake takes care of finding the proper + # include folders using the qmake found in the environment. Only use it for now in case + # something goes wrong with the cmake process. + if(ALTERNATIVE_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) set(QT_INCLUDE_DIR ${ALTERNATIVE_QT_INCLUDE_DIR}) endif() - string(REPLACE " " ":" QT_INCLUDE_DIR ${QT_INCLUDE_DIR}) endif() endif() +message(STATUS "*** computed QT_INCLUDE_DIR as ${QT_INCLUDE_DIR}") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${SHIBOKEN_BUILD_TYPE}) -- cgit v1.2.3 From a86078e015d9daaa50d97a888e12a29b7f5105d3 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 24 Aug 2017 11:54:26 +0200 Subject: Blacklist QtQml_qquickitem_grabToImage because it's flaky Change-Id: If2c134595efbb1fab29e92c67afa1d58f3831df6 Reviewed-by: Friedemann Kleint --- build_history/blacklist.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build_history/blacklist.txt b/build_history/blacklist.txt index 90168464c..06afea97e 100644 --- a/build_history/blacklist.txt +++ b/build_history/blacklist.txt @@ -62,5 +62,7 @@ # Crashes with Python 2 on Windows [QtQml::qqmlnetwork_test] py2 win32 +[QtQml::qquickitem_grabToImage] + darwin [smart::smart_pointer] win32 -- cgit v1.2.3 From c14949413fac467a94ba7dbc0e613fa1c3594358 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 24 Aug 2017 11:38:19 +0200 Subject: consistently name site-packages in Shiboken and PySide The variable used for the python site-packages is inconsistent. Instead of "SITE_PACKAGE", we use "PYTHON_SITE_PACKAGES" everywhere. Task-number: PYSIDE-563 Change-Id: I4d2d49f20f5a0a13439bc7b8c79ab318cd831cb9 Reviewed-by: Friedemann Kleint Reviewed-by: Julien Schueller Reviewed-by: Alexandru Croitor --- sources/pyside2/CMakeLists.txt | 8 ++++---- sources/pyside2/PySide2/CMakeLists.txt | 4 ++-- sources/pyside2/cmake/Macros/PySideModules.cmake | 2 +- sources/pyside2/libpyside/PySide2Config-spec.cmake.in | 2 +- sources/pyside2/libpyside/pyside2.pc.in | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index 5b7de8d24..cde163690 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -369,19 +369,19 @@ add_custom_target(dist echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2.\n" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -if (NOT SITE_PACKAGE) +if (NOT PYTHON_SITE_PACKAGES) execute_process( COMMAND ${SHIBOKEN_PYTHON_INTERPRETER} -c "if True: from distutils import sysconfig from os.path import sep print(sysconfig.get_python_lib(1, 0, prefix='${CMAKE_INSTALL_PREFIX}').replace(sep, '/')) " - OUTPUT_VARIABLE SITE_PACKAGE + OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT SITE_PACKAGE) + if (NOT PYTHON_SITE_PACKAGES) message(FATAL_ERROR "Could not detect Python module installation directory.") elseif (APPLE) - message(STATUS "!!! The generated bindings will be installed on ${SITE_PACKAGE}, is it right!?") + message(STATUS "!!! The generated bindings will be installed on ${PYTHON_SITE_PACKAGES}, is it right!?") endif() endif() diff --git a/sources/pyside2/PySide2/CMakeLists.txt b/sources/pyside2/PySide2/CMakeLists.txt index 01d9f64c2..31810b68f 100644 --- a/sources/pyside2/PySide2/CMakeLists.txt +++ b/sources/pyside2/PySide2/CMakeLists.txt @@ -23,9 +23,9 @@ endforeach() # install install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" - DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside2_SUFFIX}") + DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_utils.py - DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside2_SUFFIX}") + DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pyside2_global.h diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake index 468ce51bc..77653925e 100644 --- a/sources/pyside2/cmake/Macros/PySideModules.cmake +++ b/sources/pyside2/cmake/Macros/PySideModules.cmake @@ -108,7 +108,7 @@ macro(create_pyside_module endif() # install - install(TARGETS ${module_name} LIBRARY DESTINATION ${SITE_PACKAGE}/PySide2) + install(TARGETS ${module_name} LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}/PySide2) string(TOLOWER ${module_name} lower_module_name) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide2/${module_name}/pyside2_${lower_module_name}_python.h DESTINATION include/PySide2${pyside2_SUFFIX}/${module_name}/) diff --git a/sources/pyside2/libpyside/PySide2Config-spec.cmake.in b/sources/pyside2/libpyside/PySide2Config-spec.cmake.in index 822b8e4c2..4281ade5b 100644 --- a/sources/pyside2/libpyside/PySide2Config-spec.cmake.in +++ b/sources/pyside2/libpyside/PySide2Config-spec.cmake.in @@ -14,5 +14,5 @@ elseif(WIN32) else() SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside2@pyside2_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@PYTHON_SHARED_LIBRARY_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@") endif() -SET(PYSIDE_PYTHONPATH "@SITE_PACKAGE@") +SET(PYSIDE_PYTHONPATH "@PYTHON_SITE_PACKAGES@") SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide2@pyside2_SUFFIX@/typesystems") diff --git a/sources/pyside2/libpyside/pyside2.pc.in b/sources/pyside2/libpyside/pyside2.pc.in index 4f8b5e6e6..37a115989 100644 --- a/sources/pyside2/libpyside/pyside2.pc.in +++ b/sources/pyside2/libpyside/pyside2.pc.in @@ -3,7 +3,7 @@ exec_prefix=@CMAKE_INSTALL_PREFIX@ libdir=@LIB_INSTALL_DIR@ includedir=@CMAKE_INSTALL_PREFIX@/include/PySide2@pyside2_SUFFIX@ typesystemdir=@CMAKE_INSTALL_PREFIX@/share/PySide2@pyside2_SUFFIX@/typesystems -pythonpath=@SITE_PACKAGE@ +pythonpath=@PYTHON_SITE_PACKAGES@ Name: PySide2@pyside2_SUFFIX@ Description: Support library for Python bindings of Qt5-based libraries. -- cgit v1.2.3 From 117e0ff91275b4bc06dd5383f19e7028c5ef6ff8 Mon Sep 17 00:00:00 2001 From: Janus Troelsen Date: Thu, 24 Aug 2017 13:26:55 +0200 Subject: Fix QtUiTools not to depend on Qt5Designer being present Task-number: PYSIDE-552 Change-Id: Iff8dd7247bfec94be0cf4f5cbcfbfca1eb44d209 Reviewed-by: Christian Tismer --- sources/pyside2/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index cde163690..c4b97e860 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -287,7 +287,8 @@ else() set(DISABLE_QtScriptTools 1) ENDIF() COLLECT_MODULE_IF_FOUND(Svg opt) -if(Qt5Designer_FOUND) +find_package(Qt5UiTools) +if(Qt5UiTools_FOUND) COLLECT_MODULE_IF_FOUND(UiTools opt) else() set(DISABLE_QtUiTools 1) @@ -402,7 +403,6 @@ else() endif() add_subdirectory(libpyside) -find_package(Qt5UiTools) find_package(Qt5Designer) if(Qt5UiTools_FOUND AND Qt5Designer_FOUND) add_subdirectory(plugins) -- cgit v1.2.3