diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-02-23 16:23:48 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-02-23 16:23:52 +0100 |
commit | 4917f84cfa8d526e34e3a6d2164ecf2e23eab408 (patch) | |
tree | 21b6fc428ab75e38d1cee031ef767ed38e443044 | |
parent | 32a2eb95758f7beb13b54053bfa97c9bc973b9f0 (diff) | |
parent | 784df63e6be7339df3872a56baf89ca81c7e7199 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.9
Change-Id: I5d1a4734e8f44785898ba62beaa0bdd2004fca22
-rw-r--r-- | setup.py | 203 | ||||
-rw-r--r-- | sources/pyside2/CMakeLists.txt | 6 | ||||
-rw-r--r-- | sources/pyside2/PySide2/CMakeLists.txt | 11 | ||||
-rw-r--r-- | sources/pyside2/PySide2/__init__.py.in | 29 | ||||
-rw-r--r-- | sources/pyside2/PySide2/_built_modules.py.in | 3 | ||||
-rw-r--r-- | sources/pyside2/PySide2/_config.py.in | 6 | ||||
-rw-r--r-- | sources/pyside2/PySide2/_utils.py.in | 289 | ||||
-rw-r--r-- | sources/pyside2/PySide2/support/signature/parser.py | 14 | ||||
-rw-r--r-- | sources/pyside2/libpyside/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sources/pyside2/tests/pysidetest/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/pyside2/tests/pysidetest/utils_test.py | 51 | ||||
-rw-r--r-- | sources/shiboken2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/shiboken2/data/Shiboken2Config-spec.cmake.in | 1 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/CMakeLists.txt | 2 |
14 files changed, 192 insertions, 427 deletions
@@ -204,6 +204,7 @@ from distutils.sysconfig import get_python_lib from distutils.spawn import find_executable from distutils.command.build import build as _build from distutils.command.build_ext import build_ext as _build_ext +from distutils.util import get_platform from setuptools import setup, Extension from setuptools.command.install import install as _install @@ -212,6 +213,14 @@ from setuptools.command.bdist_egg import bdist_egg as _bdist_egg from setuptools.command.develop import develop as _develop from setuptools.command.build_py import build_py as _build_py +wheel_module_exists = False +try: + from wheel.bdist_wheel import bdist_wheel as _bdist_wheel + from wheel.bdist_wheel import safer_name as _safer_name + wheel_module_exists = True +except ImportError: + pass + from qtinfo import QtInfo from utils import rmtree, detectClang from utils import makefile @@ -289,7 +298,7 @@ OPTION_MODULE_SUBSET = option_value("module-subset") OPTION_RPATH_VALUES = option_value("rpath") OPTION_QT_CONF_PREFIX = option_value("qt-conf-prefix") OPTION_QT_SRC = option_value("qt-src-dir") -OPTION_ICULIB = option_value("iculib-url") +OPTION_ICULIB = option_value("iculib-url") # Deprecated OPTION_VERBOSE_BUILD = has_option("verbose-build") # This is used automatically by distutils.command.install object, to specify final installation @@ -359,11 +368,7 @@ else: if OPTION_ICULIB: if not OPTION_STANDALONE: - print("--iculib-url is usable only when creating standalone wheel with --standalone switch") - sys.exit(1) - if sys.platform != "linux": - print("--iculib-url is usable only when creating standalone wheels in Linux") - sys.exit(1) + print("--iculib-url option is a no-op option and will be removed soon.") # Show available versions if OPTION_LISTVERSIONS: @@ -491,10 +496,40 @@ def prepareBuild(): else: # SDK: Use 'Src' directory qtSrcDir = os.path.join(os.path.dirname(installPrefix), 'Src', 'qtbase') +def get_qt_version(computed_qtinfo = None): + if not computed_qtinfo: + qtinfo = QtInfo(QMAKE_COMMAND) + else: + qtinfo = computed_qtinfo + + qt_version = qtinfo.version + + if not qt_version: + log.error("Failed to query the Qt version with qmake %s" % self.qtinfo.qmake_command) + sys.exit(1) + + return qt_version + class pyside_install(_install): - def _init(self, *args, **kwargs): + def __init__(self, *args, **kwargs): _install.__init__(self, *args, **kwargs) + def initialize_options (self): + _install.initialize_options(self) + + if sys.platform == 'darwin': + # Because we change the plat_name to include a correct deployment target on macOS + # distutils thinks we are cross-compiling, and throws an exception when trying to + # execute setup.py install. + # The check looks like this + #if self.warn_dir and build_plat != get_platform(): + # raise DistutilsPlatformError("Can't install when " + # "cross-compiling") + # Obviously get_platform will return the old deployment target. + # The fix is to disable the warn_dir flag, which was created for bdist_* derived classes + # to override, for similar cases. + self.warn_dir = False + def run(self): _install.run(self) log.info('*** Install completed') @@ -525,6 +560,32 @@ class pyside_build_ext(_build_ext): def run(self): pass +if wheel_module_exists: + class pyside_build_wheel(_bdist_wheel): + def __init__(self, *args, **kwargs): + _bdist_wheel.__init__(self, *args, **kwargs) + + @property + def wheel_dist_name(self): + # Slightly modified version of wheel's wheel_dist_name method, to add the Qt version + # as well. + # Example: PySide2-5.6-5.6.4-cp27-cp27m-macosx_10_10_intel.whl + # The PySide2 version is "5.6. The built against Qt version is "5.6.4. + qt_version = get_qt_version() + wheel_version = "{}-{}".format(__version__, qt_version) + components = (_safer_name(self.distribution.get_name()), + wheel_version) + if self.build_number: + components += (self.build_number,) + return '-'.join(components) + + def finalize_options(self): + if sys.platform == 'darwin': + # Override the platform name to contain the correct minimum deployment target. + # This is used in the final wheel name. + self.plat_name = pyside_build.macos_plat_name() + _bdist_wheel.finalize_options(self) + # pyside_build_py and pyside_install_lib are reimplemented to preserve symlinks when # distutils / setuptools copy files to various directories through the different build stages. class pyside_build_py(_build_py): @@ -564,6 +625,22 @@ class pyside_build(_build): def __init__(self, *args, **kwargs): _build.__init__(self, *args, **kwargs) + def finalize_options(self): + os_name_backup = os.name + if sys.platform == 'darwin': + self.plat_name = pyside_build.macos_plat_name() + # This is a hack to circumvent the dubious check in distutils.commands.build -> + # finalize_options, which only allows setting the plat_name for windows NT. + # That is not the case for the wheel module though (which does allow setting plat_name), + # so we circumvent by faking the os name when finalizing the options, and then restoring + # the original os name. + os.name = "nt" + + _build.finalize_options(self) + + if sys.platform == 'darwin': + os.name = os_name_backup + def initialize_options(self): _build.initialize_options(self) self.make_path = None @@ -743,10 +820,7 @@ class pyside_build(_build): self.qtinfo = QtInfo(QMAKE_COMMAND) qt_dir = os.path.dirname(OPTION_QMAKE) - qt_version = self.qtinfo.version - if not qt_version: - log.error("Failed to query the Qt version with qmake %s" % self.qtinfo.qmake_command) - sys.exit(1) + qt_version = get_qt_version(self.qtinfo) # Update the PATH environment variable additionalPaths = [py_scripts_dir, qt_dir] @@ -890,6 +964,26 @@ class pyside_build(_build): log.info("Skipped preparing and building packages.") log.info('*** Build completed') + @staticmethod + def macos_min_deployment_target(): + # If no explicit minimum deployment target is provided to setup.py, then use the current + # build OS version. Otherwise use the provided version. + current_os_version, _, _ = platform.mac_ver() + current_os_version = '.'.join(current_os_version.split('.')[:2]) + deployment_target = current_os_version + if OPTION_OSX_DEPLOYMENT_TARGET: + deployment_target = OPTION_OSX_DEPLOYMENT_TARGET + + return deployment_target + + @staticmethod + def macos_plat_name(): + deployment_target = pyside_build.macos_min_deployment_target() + # Example triple "macosx-10.12-x86_64". + plat = get_platform().split("-") + plat_name = "{}-{}-{}".format(plat[0], deployment_target, plat[2]) + return plat_name + def build_patchelf(self): if not sys.platform.startswith('linux'): return @@ -1007,19 +1101,13 @@ class pyside_build(_build): latest_sdk_path = latest_sdk_path[0] cmake_cmd.append("-DCMAKE_OSX_SYSROOT={0}".format(latest_sdk_path)) - # If no explicit minimum deployment target is set, then use the current build OS - # version. Otherwise use the given version. + # Set macOS minimum deployment target (version). # This is required so that calling run_process -> distutils.spawn() does not - # set its own minimum deployment target environment variable, + # set its own minimum deployment target environment variable which is # based on the python interpreter sysconfig value. Doing so could break the # detected clang include paths for example. - current_os_version, _, _ = platform.mac_ver() - current_os_version = '.'.join(current_os_version.split('.')[:2]) - deployment_target = current_os_version - if OPTION_OSX_DEPLOYMENT_TARGET: - cmake_cmd.append("-DCMAKE_OSX_DEPLOYMENT_TARGET={0}" - .format(OPTION_OSX_DEPLOYMENT_TARGET)) - deployment_target = OPTION_OSX_DEPLOYMENT_TARGET + deployment_target = pyside_build.macos_min_deployment_target() + cmake_cmd.append("-DCMAKE_OSX_DEPLOYMENT_TARGET={0}".format(deployment_target)) os.environ['MACOSX_DEPLOYMENT_TARGET'] = deployment_target if not OPTION_SKIP_CMAKE: @@ -1093,29 +1181,27 @@ class pyside_build(_build): print('setup.py/prepare_packages: ', e) raise - def get_built_pyside_modules(self, vars): - # Get list of built modules, so that we copy only required Qt libraries. + def get_built_pyside_config(self, vars): + # Get config that contains list of built modules, and SOVERSIONs of the built libraries. pyside_package_dir = vars['pyside_package_dir'] - built_modules_path = os.path.join(pyside_package_dir, "PySide2", "_built_modules.py") + config_path = os.path.join(pyside_package_dir, "PySide2", "_config.py") try: - with open(built_modules_path) as f: + with open(config_path) as f: scoped_locals = {} - code = compile(f.read(), built_modules_path, 'exec') + code = compile(f.read(), config_path, 'exec') exec(code, scoped_locals, scoped_locals) - return scoped_locals['built_modules'] + config = {} + config['built_modules'] = scoped_locals['built_modules'] + config['shiboken_library_soversion'] = scoped_locals['shiboken_library_soversion'] + config['pyside_library_soversion'] = scoped_locals['pyside_library_soversion'] + return config except IOError as e: - print("get_built_pyside_modules: Couldn't find file: {}.".format(built_modules_path)) + print("get_built_pyside_config: Couldn't find file: {}.".format(config_path)) raise def prepare_packages_posix(self, vars): executables = [] - if sys.platform.startswith('linux'): - so_ext = '.so' - so_star = so_ext + '*' - elif sys.platform == 'darwin': - so_ext = '.dylib' - so_star = so_ext # <build>/shiboken2/doc/html/* -> <setup>/PySide2/docs/shiboken2 copydir( "{build_dir}/shiboken2/doc/html", @@ -1166,14 +1252,22 @@ class pyside_build(_build): ], recursive=False, vars=vars)) # <install>/lib/lib* -> PySide2/ + config = self.get_built_pyside_config(vars) + def adjusted_lib_name(name, version): + postfix = '' + if sys.platform.startswith('linux'): + postfix = '.so.' + version + elif sys.platform == 'darwin': + postfix = '.' + version + '.dylib' + return name + postfix copydir( "{install_dir}/lib/", "{pyside_package_dir}/PySide2", filter=[ - "libpyside*" + so_star, - "libshiboken*" + so_star, + adjusted_lib_name("libpyside*", config['pyside_library_soversion']), + adjusted_lib_name("libshiboken*", config['shiboken_library_soversion']), ], - recursive=False, vars=vars) + recursive=False, vars=vars, force_copy_symlinks=True) # <install>/share/PySide2/typesystems/* -> <setup>/PySide2/typesystems copydir( "{install_dir}/share/PySide2/typesystems", @@ -1203,7 +1297,7 @@ class pyside_build(_build): pyside_rcc_options) # Copy Qt libs to package if OPTION_STANDALONE: - vars['built_modules'] = self.get_built_pyside_modules(vars) + vars['built_modules'] = config['built_modules'] if sys.platform == 'darwin': self.prepare_standalone_package_osx(executables, vars) else: @@ -1323,13 +1417,15 @@ class pyside_build(_build): else: ignored_modules = [] if 'WebEngineWidgets' not in built_modules: - ignored_modules.extend(['*Qt5WebEngine*.dylib']) - accepted_modules = ['*Qt5*.dylib'] + ignored_modules.extend(['libQt5WebEngine*.dylib']) + if 'WebKit' not in built_modules: + ignored_modules.extend(['libQt5WebKit*.dylib']) + accepted_modules = ['libQt5*.5.dylib'] copydir("{qt_lib_dir}", "{pyside_package_dir}/PySide2/Qt/lib", filter=accepted_modules, ignore=ignored_modules, - recursive=True, vars=vars) + recursive=True, vars=vars, force_copy_symlinks=True) if 'WebEngineWidgets' in built_modules: copydir("{qt_lib_execs_dir}", "{pyside_package_dir}/PySide2/Qt/libexec", @@ -1370,7 +1466,7 @@ class pyside_build(_build): "{site_packages_dir}/PySide2", "{pyside_package_dir}/PySide2", vars=vars) - built_modules = self.get_built_pyside_modules(vars) + built_modules = self.get_built_pyside_config(vars)['built_modules'] if self.debug or self.build_type == 'RelWithDebInfo': # <build>/pyside2/PySide2/*.pdb -> <setup>/PySide2 @@ -1668,6 +1764,18 @@ except IOError: README = CHANGES = '' +cmd_class_dict = { + 'build': pyside_build, + 'build_py': pyside_build_py, + 'build_ext': pyside_build_ext, + 'bdist_egg': pyside_bdist_egg, + 'develop': pyside_develop, + 'install': pyside_install, + 'install_lib': pyside_install_lib +} +if wheel_module_exists: + cmd_class_dict['bdist_wheel'] = pyside_build_wheel + setup( name = "PySide2", version = __version__, @@ -1720,16 +1828,7 @@ setup( 'pyside2-uic = PySide2.scripts.uic:main', ] }, - cmdclass = { - 'build': pyside_build, - 'build_py': pyside_build_py, - 'build_ext': pyside_build_ext, - 'bdist_egg': pyside_bdist_egg, - 'develop': pyside_develop, - 'install': pyside_install, - 'install_lib': pyside_install_lib - }, - + cmdclass = cmd_class_dict, # Add a bogus extension module (will never be built here since we are # overriding the build command to do it using cmake) so things like # bdist_egg will know that there are extension modules and will name the diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index e3a95c33f..b16bcb55e 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -167,6 +167,7 @@ set(BINDING_API_MICRO_VERSION "0") set(BINDING_API_RELEASE_LEVEL "alpha") # alpha, beta, rc, or final set(BINDING_API_SERIAL 0) # leave as 0 when release level is final set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide version" FORCE) +set(PYSIDE_SO_VERSION ${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}) if (BINDING_API_RELEASE_LEVEL STREQUAL "final") set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide version [full]" FORCE) @@ -221,6 +222,11 @@ if(GIT_FOUND) endif() endif() +# Used by setup.py to know which symlink to resolve and copy in to the final package, in order to +# avoid resolving all symlinks and thus copying unnecessary duplicate files. +set(config_py_shiboken_library_version "") +set(config_py_pyside_library_version "") + include(PySideModules) macro(COLLECT_MODULE_IF_FOUND shortname) diff --git a/sources/pyside2/PySide2/CMakeLists.txt b/sources/pyside2/PySide2/CMakeLists.txt index d868e3172..21db337e9 100644 --- a/sources/pyside2/PySide2/CMakeLists.txt +++ b/sources/pyside2/PySide2/CMakeLists.txt @@ -7,11 +7,8 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in" "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_built_modules.py.in" - "${CMAKE_CURRENT_BINARY_DIR}/_built_modules.py" @ONLY) - -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_utils.py.in" - "${CMAKE_CURRENT_BINARY_DIR}/_utils.py" @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_config.py.in" + "${CMAKE_CURRENT_BINARY_DIR}/_config.py" @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/support/__init__.py" "${CMAKE_CURRENT_BINARY_DIR}/support/__init__.py" COPYONLY) @@ -70,9 +67,7 @@ endforeach() # install install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_built_modules.py" - DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_utils.py +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_config.py" DESTINATION "${PYTHON_SITE_PACKAGES}/${BINDING_NAME}${pyside2_SUFFIX}") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml DESTINATION share/PySide2${pyside_SUFFIX}/typesystems) diff --git a/sources/pyside2/PySide2/__init__.py.in b/sources/pyside2/PySide2/__init__.py.in index 77390af46..92e52a81a 100644 --- a/sources/pyside2/PySide2/__init__.py.in +++ b/sources/pyside2/PySide2/__init__.py.in @@ -12,31 +12,20 @@ __version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, def _setupQtDirectories(): import sys import os - from . import _utils - os.environ["PYSIDE_PACKAGE_DIR"] = os.path.abspath(os.path.dirname(__file__)) + pyside_package_dir = os.path.abspath(os.path.dirname(__file__)) + # Used by signature module. + os.environ["PYSIDE_PACKAGE_DIR"] = pyside_package_dir - pysideDir = _utils.get_pyside_dir() - - # Register PySide qt.conf to override the built-in - # configuration variables, if there is no default qt.conf in - # executable folder - prefix = pysideDir.replace('\\', '/') - _utils.register_qt_conf(prefix=prefix, - binaries=prefix, - plugins=prefix+"/plugins", - imports=prefix+"/imports", - translations=prefix+"/translations") - - # On Windows add the PySide\openssl folder (if it exists) to the - # PATH so the SSL DLLs can be found when Qt tries to dynamically - # load them. Tell Qt to load them and then reset the PATH. + # On Windows add the PySide2\openssl folder (if it exists) to the + # PATH so that the SSL DLLs can be found when Qt tries to dynamically + # load them. Tell Qt to load them and then reset the PATH. if sys.platform == 'win32': - opensslDir = os.path.join(pysideDir, 'openssl') - if os.path.exists(opensslDir): + openssl_dir = os.path.join(pyside_package_dir, 'openssl') + if os.path.exists(openssl_dir): path = os.environ['PATH'] try: - os.environ['PATH'] = opensslDir + os.pathsep + path + os.environ['PATH'] = os.path.join(openssl_dir, path) try: from . import QtNetwork except ImportError: diff --git a/sources/pyside2/PySide2/_built_modules.py.in b/sources/pyside2/PySide2/_built_modules.py.in deleted file mode 100644 index 4e491d081..000000000 --- a/sources/pyside2/PySide2/_built_modules.py.in +++ /dev/null @@ -1,3 +0,0 @@ -built_modules = list(name for name in - "@all_module_shortnames@" - .split(";")) diff --git a/sources/pyside2/PySide2/_config.py.in b/sources/pyside2/PySide2/_config.py.in new file mode 100644 index 000000000..db8a17210 --- /dev/null +++ b/sources/pyside2/PySide2/_config.py.in @@ -0,0 +1,6 @@ +built_modules = list(name for name in + "@all_module_shortnames@" + .split(";")) + +shiboken_library_soversion = str(@SHIBOKEN_SO_VERSION@) +pyside_library_soversion = str(@PYSIDE_SO_VERSION@) diff --git a/sources/pyside2/PySide2/_utils.py.in b/sources/pyside2/PySide2/_utils.py.in deleted file mode 100644 index 64a5a0567..000000000 --- a/sources/pyside2/PySide2/_utils.py.in +++ /dev/null @@ -1,289 +0,0 @@ -############################################################################# -## -## Copyright (C) 2017 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of PySide2. -## -## $QT_BEGIN_LICENSE:LGPL$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 3 as published by the Free Software -## Foundation and appearing in the file LICENSE.LGPL3 included in the -## packaging of this file. Please review the following information to -## ensure the GNU Lesser General Public License version 3 requirements -## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 2.0 or (at your option) the GNU General -## Public license version 3 or any later version approved by the KDE Free -## Qt Foundation. The licenses are as published by the Free Software -## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-2.0.html and -## https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -import sys -import os -import fnmatch - - -if sys.platform == 'win32': - # On Windows get the PySide package path in case sensitive format. - # Even if the file system on Windows is case insensitive, - # some parts in Qt environment such as qml imports path, - # requires to be in case sensitive format. - import ctypes - from ctypes import POINTER, WinError, sizeof, byref, create_unicode_buffer - from ctypes.wintypes import MAX_PATH, LPCWSTR, LPWSTR, DWORD - - GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW - GetShortPathNameW.argtypes = [LPCWSTR, LPWSTR, DWORD] - GetShortPathNameW.restype = DWORD - - GetLongPathNameW = ctypes.windll.kernel32.GetLongPathNameW - GetLongPathNameW.argtypes = [LPCWSTR, LPWSTR, DWORD] - GetLongPathNameW.restype = DWORD - - PY_2 = sys.version_info[0] < 3 - - if PY_2: - def u(x): - return unicode(x) - def u_fs(x): - return unicode(x, sys.getfilesystemencoding()) - else: - def u(x): - return x - def u_fs(x): - return x - - def _get_win32_short_name(s): - """ Returns short name """ - buf_size = MAX_PATH - for i in range(2): - buf = create_unicode_buffer(u('\0') * (buf_size + 1)) - r = GetShortPathNameW(u_fs(s), buf, buf_size) - if r == 0: - raise WinError() - if r < buf_size: - if PY_2: - return buf.value.encode(sys.getfilesystemencoding()) - return buf.value - buf_size = r - raise WinError() - - def _get_win32_long_name(s): - """ Returns long name """ - buf_size = MAX_PATH - for i in range(2): - buf = create_unicode_buffer(u('\0') * (buf_size + 1)) - r = GetLongPathNameW(u_fs(s), buf, buf_size) - if r == 0: - raise WinError() - if r < buf_size: - if PY_2: - return buf.value.encode(sys.getfilesystemencoding()) - return buf.value - buf_size = r - raise WinError() - - def _get_win32_case_sensitive_name(s): - """ Returns long name in case sensitive format """ - path = _get_win32_long_name(_get_win32_short_name(s)) - return path - - def get_pyside_dir(): - try: - from . import QtCore - except ImportError: - return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(__file__))) - else: - return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(QtCore.__file__))) - -else: - def get_pyside_dir(): - try: - from . import QtCore - except ImportError: - return os.path.abspath(os.path.dirname(__file__)) - else: - return os.path.abspath(os.path.dirname(QtCore.__file__)) - - -def _filter_match(name, patterns): - for pattern in patterns: - if pattern is None: - continue - if fnmatch.fnmatch(name, pattern): - return True - return False - - -def _dir_contains(dir, filter): - names = os.listdir(dir) - for name in names: - srcname = os.path.join(dir, name) - if not os.path.isdir(srcname) and _filter_match(name, filter): - return True - return False - - -def _rcc_write_number(out, number, width): - dividend = 1 - if width == 2: - dividend = 256 - elif width == 3: - dividend = 65536 - elif width == 4: - dividend = 16777216 - while dividend >= 1: - tmp = int(number / dividend) - out.append("%02x" % tmp) - number -= tmp * dividend - dividend = int(dividend / 256) - - -def _rcc_write_data(out, data): - _rcc_write_number(out, len(data), 4) - for d in data: - _rcc_write_number(out, ord(d), 1) - - -def _get_qt_conf_resource(prefix, binaries, plugins, imports, translations): - """ - Generate Qt resource with embedded qt.conf - """ - qt_conf_template = "\ -[Paths]\x0d\x0a\ -Prefix = %(prefix)s\x0d\x0a\ -Binaries = %(binaries)s\x0d\x0a\ -Imports = %(imports)s\x0d\x0a\ -Plugins = %(plugins)s\x0d\x0a\ -Translations = %(translations)s" - - rc_data_input = qt_conf_template % {"prefix": prefix, - "binaries": binaries, - "plugins": plugins, - "imports": imports, - "translations": translations} - rc_data_ouput = [] - _rcc_write_data(rc_data_ouput, rc_data_input) - - # The rc_struct and rc_name was pre-generated by pyside-rcc from file: - # <!DOCTYPE RCC><RCC version="1.0"> - # <qresource> - # <file>qt/etc/qt.conf</file> - # </qresource> - # </RCC> - PY_2 = sys.version_info[0] < 3 - if PY_2: - rc_struct = "\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x0a\x00\x02\x00\x00\ -\x00\x01\x00\x00\x00\x03\x00\x00\x00\x16\x00\x00\x00\x00\x00\x01\x00\x00\ -\x00\x00" - rc_name = "\ -\x00\x02\x00\x00\x07\x84\x00q\x00t\x00\x03\x00\x00l\xa3\x00e\x00t\x00c\x00\ -\x07\x08t\xa6\xa6\x00q\x00t\x00.\x00c\x00o\x00n\x00f" - rc_data = "".join(rc_data_ouput).decode('hex') - else: - rc_struct = b"\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x0a\x00\x02\x00\x00\ -\x00\x01\x00\x00\x00\x03\x00\x00\x00\x16\x00\x00\x00\x00\x00\x01\x00\x00\ -\x00\x00" - rc_name = b"\ -\x00\x02\x00\x00\x07\x84\x00q\x00t\x00\x03\x00\x00l\xa3\x00e\x00t\x00c\x00\ -\x07\x08t\xa6\xa6\x00q\x00t\x00.\x00c\x00o\x00n\x00f" - rc_data = bytes.fromhex("".join(rc_data_ouput)) - - return rc_struct, rc_name, rc_data - - -def register_qt_conf(prefix, binaries, plugins, imports, translations, - force=False): - """ - Register qt.conf in Qt resource system to override the built-in - configuration variables, if there is no default qt.conf in - executable folder and another qt.conf is not already registered in - Qt resource system. - """ - try: - from . import QtCore - except ImportError: - return - - # Check folder structure - if not prefix or not os.path.exists(prefix): - if force: - raise RuntimeError("Invalid prefix path specified: %s" % prefix) - else: - return - if not binaries or not os.path.exists(binaries): - if force: - raise RuntimeError("Invalid binaries path specified: %s" % binaries) - else: - return - else: - # Check if required Qt libs exists in binaries folder - if sys.platform == 'win32': - pattern = ["Qt5Core*.dll"] - else: - pattern = ["libQtCore.so.*"] - if not _dir_contains(binaries, pattern): - if force: - raise RuntimeError("QtCore lib not found in folder: %s" % \ - binaries) - else: - return - if not plugins or not os.path.exists(plugins): - if force: - raise RuntimeError("Invalid plugins path specified: %s" % plugins) - else: - return - if not imports or not os.path.exists(imports): - if force: - raise RuntimeError("Invalid imports path specified: %s" % imports) - else: - return - if not translations or not os.path.exists(translations): - if force: - raise RuntimeError("Invalid translations path specified: %s" \ - % translations) - else: - return - - # Check if there is no default qt.conf in executable folder - exec_prefix = os.path.dirname(sys.executable) - qtconf_path = os.path.join(exec_prefix, 'qt.conf') - if os.path.exists(qtconf_path) and not force: - return - - # Check if another qt.conf is not already registered in Qt resource system - if QtCore.QFile.exists(":/qt/etc/qt.conf") and not force: - return - - # Keep these variables alive - global rc_struct, rc_name, rc_data - rc_struct, rc_name, rc_data = _get_qt_conf_resource(prefix, binaries, - plugins, imports, - translations) - QtCore.qRegisterResourceData(0x01, rc_struct, rc_name, rc_data) - - # Initialize the Qt library by querying the QLibraryInfo - prefixPath = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PrefixPath) diff --git a/sources/pyside2/PySide2/support/signature/parser.py b/sources/pyside2/PySide2/support/signature/parser.py index c55973632..b067f245b 100644 --- a/sources/pyside2/PySide2/support/signature/parser.py +++ b/sources/pyside2/PySide2/support/signature/parser.py @@ -82,10 +82,18 @@ def _parse_line(line): """ ret = re.match(line_re, line, re.VERBOSE).groupdict() arglist = ret["arglist"] + # The following is a split re. The string is broken into pieces which are + # between the recognized strings. Because the re has groups, both the + # strings and the delimiters are returned, where the strings are not + # interesting at all: They are just the commata. + # Note that it is necessary to put the characters with special handling in + # the first group (comma, brace, angle bracket). + # Then they are not recognized there, and we can handle them differently + # in the following expressions. arglist = list(x.strip() for x in re.split(r""" ( (?: # inner group is not capturing - [^,()] # no commas or braces + [^,()<>] # no commas or braces or angle brackets | \( (?: @@ -96,6 +104,10 @@ def _parse_line(line): \) )* \) + | + < # or one angle bracket pair + [^<>]* + > )+ # longest possible span ) # this list is interspersed with "," and surrounded by "" """, arglist, flags=re.VERBOSE) diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt index 0e21f4063..3069b1ca2 100644 --- a/sources/pyside2/libpyside/CMakeLists.txt +++ b/sources/pyside2/libpyside/CMakeLists.txt @@ -96,7 +96,7 @@ target_link_libraries(pyside2 set_target_properties(pyside2 PROPERTIES VERSION ${BINDING_API_VERSION} - SOVERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}" + SOVERSION "${PYSIDE_SO_VERSION}" OUTPUT_NAME "pyside2${pyside2_SUFFIX}${SHIBOKEN_PYTHON_SHARED_LIBRARY_SUFFIX}" DEFINE_SYMBOL PYSIDE_EXPORTS) diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt index 9db55e524..c6d3bb13b 100644 --- a/sources/pyside2/tests/pysidetest/CMakeLists.txt +++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt @@ -138,7 +138,6 @@ PYSIDE_TEST(signalemissionfrompython_test.py) PYSIDE_TEST(version_test.py) PYSIDE_TEST(typedef_signal_test.py) PYSIDE_TEST(bug_1016.py) -PYSIDE_TEST(utils_test.py) PYSIDE_TEST(mixin_signal_slots_test.py) PYSIDE_TEST(signal_slot_warning.py) PYSIDE_TEST(all_modules_load_test.py) diff --git a/sources/pyside2/tests/pysidetest/utils_test.py b/sources/pyside2/tests/pysidetest/utils_test.py deleted file mode 100644 index 30f283312..000000000 --- a/sources/pyside2/tests/pysidetest/utils_test.py +++ /dev/null @@ -1,51 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of PySide2. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -import unittest -import sys -import os - - -if sys.platform == 'win32': - from PySide2._utils import _get_win32_case_sensitive_name - - class Win32UtilsTest(unittest.TestCase): - def testWin32CaseSensitiveName(self): - from tempfile import mkdtemp - caseSensitiveName = 'CaseSensitiveName' - tmpdir = mkdtemp(caseSensitiveName) - try: - path = _get_win32_case_sensitive_name(tmpdir.lower()) - self.assertTrue(path.endswith(caseSensitiveName)) - finally: - if os.path.exists(tmpdir): - os.rmdir(tmpdir) - - -if __name__ == '__main__': - unittest.main() diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index b9dd0a7f9..006924ad9 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -15,6 +15,7 @@ set(shiboken_MAJOR_VERSION "2") set(shiboken_MINOR_VERSION "0") set(shiboken_MICRO_VERSION "0") set(shiboken2_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}") +set(shiboken2_library_so_version "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}") option(BUILD_TESTS "Build tests." TRUE) option(USE_PYTHON_VERSION "Use specific python version to build shiboken2." "") diff --git a/sources/shiboken2/data/Shiboken2Config-spec.cmake.in b/sources/shiboken2/data/Shiboken2Config-spec.cmake.in index 9a30d7b4d..576bed0e2 100644 --- a/sources/shiboken2/data/Shiboken2Config-spec.cmake.in +++ b/sources/shiboken2/data/Shiboken2Config-spec.cmake.in @@ -25,6 +25,7 @@ SET(SHIBOKEN_PYTHON_LIBRARIES "@SBK_PYTHON_LIBRARIES@") SET(SHIBOKEN_PYTHON_EXTENSION_SUFFIX "@PYTHON_EXTENSION_SUFFIX@") SET(SHIBOKEN_PYTHON_SHARED_LIBRARY_SUFFIX "@PYTHON_SHARED_LIBRARY_SUFFIX@") SET(SHIBOKEN_PYTHON_CONFIG_SUFFIX "@PYTHON_CONFIG_SUFFIX@") +SET(SHIBOKEN_SO_VERSION "@shiboken2_library_so_version@") message(STATUS "libshiboken built for @SHIBOKEN_BUILD_TYPE@") @SBK_ADD_PY_DEBUG_DEFINITION@ diff --git a/sources/shiboken2/libshiboken/CMakeLists.txt b/sources/shiboken2/libshiboken/CMakeLists.txt index 90b44aa76..e87cf07fd 100644 --- a/sources/shiboken2/libshiboken/CMakeLists.txt +++ b/sources/shiboken2/libshiboken/CMakeLists.txt @@ -31,7 +31,7 @@ set(libshiboken_MAJOR_VERSION ${shiboken_MAJOR_VERSION}) set(libshiboken_MINOR_VERSION ${shiboken_MINOR_VERSION}) set(libshiboken_MICRO_VERSION ${shiboken_MICRO_VERSION}) set(libshiboken_VERSION "${libshiboken_MAJOR_VERSION}.${libshiboken_MINOR_VERSION}.${libshiboken_MICRO_VERSION}") -set(libshiboken_SOVERSION "${libshiboken_MAJOR_VERSION}.${libshiboken_MINOR_VERSION}") +set(libshiboken_SOVERSION "${shiboken2_library_so_version}") set(libshiboken_SRC basewrapper.cpp |