diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-11-17 13:06:37 +0100 |
---|---|---|
committer | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-11-25 21:50:17 +0100 |
commit | 69d511949fdf1da8309c9adab8b00ed6f80053a0 (patch) | |
tree | 313e4f8578fcd4797a8b411c31aedaf35f3ee9a7 /build_scripts | |
parent | 2914408d9017d192f254b4c7b2d298bb7b6e885e (diff) |
Improve code style with flake8
- We agreed on 100 columns time ago, so I move around a few things,
- Removing unused modules,
- Fix white-spaces tabs without being multiple of 4,
- Encourage the use of os.path.join when joining paths,
- Using .format() for string formatting,
- Remove white-spaces from default arguments,
- Adjusting white-spaces before inline comments,
- Adding extra newlines when expected,
- Adjust spaces for lines under-indented for visual indent,
- Remove white-spaces from parenthesis, and adding them for arithmetic operators.
Change-Id: I9cb28cefd114d63580b584a063c452f90d3ca885
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'build_scripts')
-rw-r--r-- | build_scripts/config.py | 2 | ||||
-rw-r--r-- | build_scripts/main.py | 227 | ||||
-rw-r--r-- | build_scripts/options.py | 13 | ||||
-rw-r--r-- | build_scripts/platforms/linux.py | 47 | ||||
-rw-r--r-- | build_scripts/platforms/macos.py | 79 | ||||
-rw-r--r-- | build_scripts/platforms/unix.py | 11 | ||||
-rw-r--r-- | build_scripts/platforms/windows_desktop.py | 84 | ||||
-rw-r--r-- | build_scripts/qp5_tool.py | 28 | ||||
-rw-r--r-- | build_scripts/qtinfo.py | 12 | ||||
-rw-r--r-- | build_scripts/setup_runner.py | 4 | ||||
-rw-r--r-- | build_scripts/utils.py | 250 | ||||
-rw-r--r-- | build_scripts/wheel_override.py | 17 |
12 files changed, 372 insertions, 402 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py index 739d88fe6..3a590ffb0 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -37,7 +37,7 @@ ## ############################################################################# -import sys, os +import os import distutils.log as log diff --git a/build_scripts/main.py b/build_scripts/main.py index 5f536792a..7877191fe 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -52,9 +52,11 @@ setup_py_path = os.path.join(setup_script_dir, "setup.py") start_time = int(time.time()) + def elapsed(): return int(time.time()) - start_time + @memoize def get_package_timestamp(): """ In a Coin CI build the returned timestamp will be the @@ -62,6 +64,7 @@ def get_package_timestamp(): just the current timestamp or a user provided one.""" return OPTION_PACKAGE_TIMESTAMP if OPTION_PACKAGE_TIMESTAMP else start_time + @memoize def get_package_version(): """ Returns the version string for the PySide2 package. """ @@ -82,6 +85,7 @@ def get_package_version(): final_version += ".dev{}".format(get_package_timestamp()) return final_version + def get_setuptools_extension_modules(): # Setting py_limited_api on the extension is the "correct" thing # to do, but it doesn't actually do anything, because we @@ -95,8 +99,7 @@ def get_setuptools_extension_modules(): return extension_modules -# Git submodules: ["submodule_name", -# "location_relative_to_sources_folder"] +# Git submodules: ["submodule_name", "location_relative_to_sources_folder"] submodules = [["pyside2-tools"]] try: @@ -151,7 +154,7 @@ def check_allowed_python_version(): if found: major = int(found.group(1)) minor = int(found.group(2)) - supported.append( (major, minor) ) + supported.append((major, minor)) this_py = sys.version_info[:2] if this_py not in supported: print("Unsupported python version detected. Only these python versions are supported: {}" @@ -207,9 +210,9 @@ available_mkspecs = ["msvc", "mingw", "ninja"] if sys.platform == "win32" else [ if OPTION_MAKESPEC is None: OPTION_MAKESPEC = available_mkspecs[0] -if not OPTION_MAKESPEC in available_mkspecs: - print('Invalid option --make-spec "{}". Available values are {}'.format( - OPTION_MAKESPEC, available_mkspecs)) +if OPTION_MAKESPEC not in available_mkspecs: + print('Invalid option --make-spec "{}". Available values are {}'.format(OPTION_MAKESPEC, + available_mkspecs)) sys.exit(1) if OPTION_JOBS: @@ -222,9 +225,11 @@ if OPTION_JOBS: else: OPTION_JOBS = '' + def is_debug_python(): return getattr(sys, "gettotalrefcount", None) is not None + # Return a prefix suitable for the _install/_build directory def prefix(): virtual_env_name = os.environ.get('VIRTUAL_ENV', None) @@ -241,6 +246,7 @@ def prefix(): name += "a" return name + # Initialize, pull and checkout submodules def prepare_sub_modules(): print("Initializing submodules for PySide2 version: {}".format( @@ -263,13 +269,11 @@ def prepare_sub_modules(): if need_init_sub_modules: git_update_cmd = ["git", "submodule", "update", "--init"] if run_process(git_update_cmd) != 0: - m = ("Failed to initialize the git submodules: " - "update --init failed") + m = "Failed to initialize the git submodules: update --init failed" raise DistutilsSetupError(m) git_pull_cmd = ["git", "submodule", "foreach", "git", "fetch", "--all"] if run_process(git_pull_cmd) != 0: - m = ("Failed to initialize the git submodules: " - "git fetch --all failed") + m = "Failed to initialize the git submodules: git fetch --all failed" raise DistutilsSetupError(m) else: print("All submodules present.") @@ -279,10 +283,12 @@ def prepare_sub_modules(): m = "Failed to checkout the correct git submodules SHA1s." raise DistutilsSetupError(m) + # Single global instance of QtInfo to be used later in multiple code # paths. qtinfo = QtInfo(QMAKE_COMMAND) + def get_qt_version(): qt_version = qtinfo.version @@ -291,16 +297,16 @@ def get_qt_version(): sys.exit(1) if LooseVersion(qtinfo.version) < LooseVersion("5.7"): - log.error("Incompatible Qt version detected: {}. " - "A Qt version >= 5.7 is required.".format(qt_version)) + log.error("Incompatible Qt version detected: {}. A Qt version >= 5.7 is " + "required.".format(qt_version)) sys.exit(1) return qt_version def prepare_build(): - if (os.path.isdir(".git") and not OPTION_IGNOREGIT and - not OPTION_ONLYPACKAGE and not OPTION_REUSE_BUILD): + if (os.path.isdir(".git") and not OPTION_IGNOREGIT and not OPTION_ONLYPACKAGE + and not OPTION_REUSE_BUILD): prepare_sub_modules() # Clean up temp build folder. for n in ["build"]: @@ -321,15 +327,15 @@ def prepare_build(): # In-source, developer build if install_prefix.endswith("qtbase"): qt_src_dir = install_prefix - else: # SDK: Use 'Src' directory - qt_src_dir = os.path.join(os.path.dirname(install_prefix), - 'Src', 'qtbase') + else: # SDK: Use 'Src' directory + qt_src_dir = os.path.join(os.path.dirname(install_prefix), 'Src', 'qtbase') + class PysideInstall(_install): def __init__(self, *args, **kwargs): _install.__init__(self, *args, **kwargs) - def initialize_options (self): + def initialize_options(self): _install.initialize_options(self) if sys.platform == 'darwin': @@ -350,6 +356,7 @@ class PysideInstall(_install): _install.run(self) print('*** Install completed ({}s)'.format(elapsed())) + class PysideDevelop(_develop): def __init__(self, *args, **kwargs): @@ -359,6 +366,7 @@ class PysideDevelop(_develop): self.run_command("build") _develop.run(self) + class PysideBdistEgg(_bdist_egg): def __init__(self, *args, **kwargs): @@ -368,6 +376,7 @@ class PysideBdistEgg(_bdist_egg): self.run_command("build") _bdist_egg.run(self) + class PysideBuildExt(_build_ext): def __init__(self, *args, **kwargs): @@ -399,14 +408,13 @@ class PysideInstallLib(_install_lib): if os.path.isdir(self.build_dir): # Using our own copydir makes sure to preserve symlinks. - outfiles = copydir(os.path.abspath(self.build_dir), - os.path.abspath(self.install_dir)) + outfiles = copydir(os.path.abspath(self.build_dir), os.path.abspath(self.install_dir)) else: - self.warn("'{}' does not exist -- " - "no Python modules to install".format(self.build_dir)) + self.warn("'{}' does not exist -- no Python modules to install".format(self.build_dir)) return return outfiles + class PysideBuild(_build): def __init__(self, *args, **kwargs): @@ -468,12 +476,10 @@ class PysideBuild(_build): elif OPTION_MAKESPEC == "msvc": nmake_path = find_executable("nmake") if nmake_path is None or not os.path.exists(nmake_path): - log.info("nmake not found. " - "Trying to initialize the MSVC env...") + log.info("nmake not found. Trying to initialize the MSVC env...") init_msvc_env(platform_arch, build_type) nmake_path = find_executable("nmake") - assert(nmake_path is not None and - os.path.exists(nmake_path)) + assert(nmake_path is not None and os.path.exists(nmake_path)) jom_path = None if OPTION_NO_JOM else find_executable("jom") if jom_path is not None and os.path.exists(jom_path): log.info("jom was found in {}".format(jom_path)) @@ -493,23 +499,20 @@ class PysideBuild(_build): make_name = "ninja" make_generator = "Ninja" else: - raise DistutilsSetupError( - "Invalid option --make-spec.") + raise DistutilsSetupError("Invalid option --make-spec.") make_path = find_executable(make_name) if make_path is None or not os.path.exists(make_path): - raise DistutilsSetupError("You need the program '{}' on your " - "system path to compile PySide2.".format(make_name)) + raise DistutilsSetupError("You need the program '{}' on your system path to " + "compile PySide2.".format(make_name)) if OPTION_CMAKE is None or not os.path.exists(OPTION_CMAKE): - raise DistutilsSetupError( - "Failed to find cmake." - " Please specify the path to cmake with " - "--cmake parameter.") + raise DistutilsSetupError("Failed to find cmake." + " Please specify the path to cmake with " + "--cmake parameter.") if OPTION_QMAKE is None or not os.path.exists(OPTION_QMAKE): - raise DistutilsSetupError( - "Failed to find qmake." - " Please specify the path to qmake with --qmake parameter.") + raise DistutilsSetupError("Failed to find qmake. " + "Please specify the path to qmake with --qmake parameter.") # Prepare parameters py_executable = sys.executable @@ -534,8 +537,7 @@ class PysideBuild(_build): if sys.platform == "win32": py_include_dir = os.path.join(py_prefix, "include") else: - py_include_dir = os.path.join(py_prefix, - "include/python{}".format(py_version)) + py_include_dir = os.path.join(py_prefix, "include/python{}".format(py_version)) dbg_postfix = "" if build_type == "Debug": dbg_postfix = "_d" @@ -554,7 +556,7 @@ class PysideBuild(_build): lib_exts.append('.dylib') if sys.version_info[0] > 2: lib_suff = getattr(sys, 'abiflags', None) - else: # Python 2 + else: # Python 2 lib_suff = '' lib_exts.append('.so.1') # Suffix for OpenSuSE 13.01 @@ -573,8 +575,7 @@ class PysideBuild(_build): python_library_found = False libs_tried = [] for lib_ext in lib_exts: - lib_name = "libpython{}{}{}".format(py_version, lib_suff, - lib_ext) + lib_name = "libpython{}{}{}".format(py_version, lib_suff, lib_ext) py_library = os.path.join(py_libdir, lib_name) if os.path.exists(py_library): python_library_found = True @@ -592,15 +593,12 @@ class PysideBuild(_build): # /System/Library/Frameworks/Python.framework/Versions/2.6/lib # to # /System/Library/Frameworks/Python.framework/Versions/2.6/Python - possible_framework_path = os.path.realpath( - os.path.join(py_libdir, '..')) - possible_framework_version = os.path.basename( - possible_framework_path) - possible_framework_library = os.path.join( - possible_framework_path, 'Python') - - if (possible_framework_version == '2.6' and - os.path.exists(possible_framework_library)): + possible_framework_path = os.path.realpath(os.path.join(py_libdir, '..')) + possible_framework_version = os.path.basename(possible_framework_path) + possible_framework_library = os.path.join(possible_framework_path, 'Python') + + if (possible_framework_version == '2.6' + and os.path.exists(possible_framework_library)): py_library = possible_framework_library python_library_found = True else: @@ -614,8 +612,7 @@ class PysideBuild(_build): try_py_libdir = os.path.join(py_libdir, py_multiarch) libs_tried = [] for lib_ext in lib_exts: - lib_name = "libpython{}{}{}".format( - py_version, lib_suff, lib_ext) + lib_name = "libpython{}{}{}".format(py_version, lib_suff, lib_ext) py_library = os.path.join(try_py_libdir, lib_name) if os.path.exists(py_library): py_libdir = try_py_libdir @@ -625,13 +622,11 @@ class PysideBuild(_build): if not python_library_found: raise DistutilsSetupError( - "Failed to locate the Python library with {}".format( - ", ".join(libs_tried))) + "Failed to locate the Python library with {}".format(", ".join(libs_tried))) if py_library.endswith('.a'): # Python was compiled as a static library - log.error("Failed to locate a dynamic Python library, " - "using {}".format(py_library)) + log.error("Failed to locate a dynamic Python library, using {}".format(py_library)) self.qtinfo = qtinfo qt_dir = os.path.dirname(OPTION_QMAKE) @@ -642,14 +637,14 @@ class PysideBuild(_build): # Add Clang to path for Windows. # Revisit once Clang is bundled with Qt. - if (sys.platform == "win32" and - LooseVersion(self.qtinfo.version) >= LooseVersion("5.7.0")): + if (sys.platform == "win32" + and LooseVersion(self.qtinfo.version) >= LooseVersion("5.7.0")): clang_dir = detect_clang() if clang_dir[0]: clangBinDir = os.path.join(clang_dir[0], 'bin') - if not clangBinDir in os.environ.get('PATH'): - log.info("Adding {} as detected by {} to PATH".format( - clangBinDir, clang_dir[1])) + if clangBinDir not in os.environ.get('PATH'): + log.info("Adding {} as detected by {} to PATH".format(clangBinDir, + clang_dir[1])) additional_paths.append(clangBinDir) else: raise DistutilsSetupError("Failed to detect Clang when checking " @@ -659,7 +654,8 @@ class PysideBuild(_build): # Used for test blacklists and registry test. self.build_classifiers = "py{}-qt{}-{}-{}".format(py_version, qt_version, - platform.architecture()[0], build_type.lower()) + platform.architecture()[0], + build_type.lower()) if OPTION_SHORTER_PATHS: build_name = "p{}".format(py_version) else: @@ -667,10 +663,8 @@ class PysideBuild(_build): script_dir = setup_script_dir sources_dir = os.path.join(script_dir, "sources") - build_dir = os.path.join(script_dir, prefix() + "_build", - "{}".format(build_name)) - install_dir = os.path.join(script_dir, prefix() + "_install", - "{}".format(build_name)) + build_dir = os.path.join(script_dir, prefix() + "_build", "{}".format(build_name)) + install_dir = os.path.join(script_dir, prefix() + "_install", "{}".format(build_name)) self.make_path = make_path self.make_generator = make_generator @@ -803,8 +797,7 @@ class PysideBuild(_build): target = qtinfo.macos_min_deployment_target if not target: - raise DistutilsSetupError("Failed to query for Qt's " - "QMAKE_MACOSX_DEPLOYMENT_TARGET.") + raise DistutilsSetupError("Failed to query for Qt's QMAKE_MACOSX_DEPLOYMENT_TARGET.") return target @staticmethod @@ -831,24 +824,23 @@ class PysideBuild(_build): setup_target_split = [int(x) for x in setup_target.split('.')] message = ("Can't set MACOSX_DEPLOYMENT_TARGET value to {} because " - "{} was built with minimum deployment target set to {}.") + "{} was built with minimum deployment target set to {}.") # setup.py provided OPTION_MACOS_DEPLOYMENT_TARGET value takes # precedence. if setup_target: if python_target and setup_target_split < python_target_split: - raise DistutilsSetupError(message.format(setup_target, - "Python", python_target)) + raise DistutilsSetupError(message.format(setup_target, "Python", + python_target)) if setup_target_split < qt_target_split: - raise DistutilsSetupError(message.format(setup_target, - "Qt", qt_target)) + raise DistutilsSetupError(message.format(setup_target, "Qt", + qt_target)) # All checks clear, use setup.py provided value. return setup_target # Setup.py value not provided, # use same value as provided by Qt. if python_target: - maximum_target = '.'.join([str(e) for e in max(python_target_split, - qt_target_split)]) + maximum_target = '.'.join([str(e) for e in max(python_target_split, qt_target_split)]) else: maximum_target = qt_target return maximum_target @@ -868,18 +860,12 @@ class PysideBuild(_build): self._patchelf_path = find_executable('patchelf') if self._patchelf_path: if not os.path.isabs(self._patchelf_path): - self._patchelf_path = os.path.join(os.getcwd(), - self._patchelf_path) + self._patchelf_path = os.path.join(os.getcwd(), self._patchelf_path) log.info("Using {} ...".format(self._patchelf_path)) return log.info("Building patchelf...") module_src_dir = os.path.join(self.sources_dir, "patchelf") - build_cmd = [ - "g++", - "{}/patchelf.cc".format(module_src_dir), - "-o", - "patchelf", - ] + build_cmd = ["g++", "{}/patchelf.cc".format(module_src_dir), "-o", "patchelf"] if run_process(build_cmd) != 0: raise DistutilsSetupError("Error building patchelf") self._patchelf_path = os.path.join(self.script_dir, "patchelf") @@ -891,30 +877,25 @@ class PysideBuild(_build): # Prepare folders os.chdir(self.build_dir) - module_build_dir = os.path.join(self.build_dir, extension) - skipflag_file = module_build_dir + '-skip' + module_build_dir = os.path.join(self.build_dir, extension) + skipflag_file = "{} -skip".format(module_build_dir) if os.path.exists(skipflag_file): - log.info("Skipping {} because {} exists".format(extension, - skipflag_file)) + log.info("Skipping {} because {} exists".format(extension, skipflag_file)) return module_build_exists = os.path.exists(module_build_dir) if module_build_exists: if not OPTION_REUSE_BUILD: - log.info("Deleting module build folder {}...".format( - module_build_dir)) + log.info("Deleting module build folder {}...".format(module_build_dir)) try: rmtree(module_build_dir) except Exception as e: - print('***** problem removing "{}"'.format( - module_build_dir)) + print('***** problem removing "{}"'.format(module_build_dir)) print('ignored error: {}'.format(e)) else: - log.info("Reusing module build folder {}...".format( - module_build_dir)) + log.info("Reusing module build folder {}...".format(module_build_dir)) if not os.path.exists(module_build_dir): - log.info("Creating module build folder {}...".format( - module_build_dir)) + log.info("Creating module build folder {}...".format(module_build_dir)) os.makedirs(module_build_dir) os.chdir(module_build_dir) @@ -995,12 +976,11 @@ class PysideBuild(_build): if OPTION_SANITIZE_ADDRESS: # Some simple sanity checking. Only use at your own risk. - if (sys.platform.startswith('linux') or - sys.platform.startswith('darwin')): + if (sys.platform.startswith('linux') + or sys.platform.startswith('darwin')): cmake_cmd.append("-DSANITIZE_ADDRESS=ON") else: - raise DistutilsSetupError("Address sanitizer can only be used " - "on Linux and macOS.") + raise DistutilsSetupError("Address sanitizer can only be used on Linux and macOS.") if extension.lower() == "pyside2": pyside_qt_conf_prefix = '' @@ -1017,8 +997,7 @@ class PysideBuild(_build): # Pass package version to CMake, so this string can be # embedded into _config.py file. package_version = get_package_version() - cmake_cmd.append("-DPACKAGE_SETUP_PY_PACKAGE_VERSION={}".format( - package_version)) + cmake_cmd.append("-DPACKAGE_SETUP_PY_PACKAGE_VERSION={}".format(package_version)) # In case if this is a snapshot build, also pass the # timestamp as a separate value, because it is the only @@ -1026,8 +1005,7 @@ class PysideBuild(_build): timestamp = '' if OPTION_SNAPSHOT_BUILD: timestamp = get_package_timestamp() - cmake_cmd.append("-DPACKAGE_SETUP_PY_PACKAGE_TIMESTAMP={}".format( - timestamp)) + cmake_cmd.append("-DPACKAGE_SETUP_PY_PACKAGE_TIMESTAMP={}".format(timestamp)) if extension.lower() in ["shiboken2", "pyside2-tools"]: cmake_cmd.append("-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=yes") @@ -1037,8 +1015,7 @@ class PysideBuild(_build): if sys.platform == 'darwin': if OPTION_MACOS_ARCH: # also tell cmake which architecture to use - cmake_cmd.append("-DCMAKE_OSX_ARCHITECTURES:STRING={}".format( - OPTION_MACOS_ARCH)) + cmake_cmd.append("-DCMAKE_OSX_ARCHITECTURES:STRING={}".format(OPTION_MACOS_ARCH)) if OPTION_MACOS_USE_LIBCPP: # Explicitly link the libc++ standard library (useful @@ -1053,10 +1030,10 @@ class PysideBuild(_build): if OPTION_MACOS_SYSROOT: cmake_cmd.append("-DCMAKE_OSX_SYSROOT={}".format( - OPTION_MACOS_SYSROOT)) + OPTION_MACOS_SYSROOT)) else: - latest_sdk_path = run_process_output(['xcrun', - '--sdk', 'macosx', '--show-sdk-path']) + latest_sdk_path = run_process_output(['xcrun', '--sdk', 'macosx', + '--show-sdk-path']) if latest_sdk_path: latest_sdk_path = latest_sdk_path[0] cmake_cmd.append("-DCMAKE_OSX_SYSROOT={}".format( @@ -1070,18 +1047,14 @@ class PysideBuild(_build): # interpreter sysconfig value. # Doing so could break the detected clang include paths # for example. - deployment_target = \ - PysideBuild.macos_pyside_min_deployment_target() - cmake_cmd.append("-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format( - deployment_target)) + deployment_target = PysideBuild.macos_pyside_min_deployment_target() + cmake_cmd.append("-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(deployment_target)) os.environ['MACOSX_DEPLOYMENT_TARGET'] = deployment_target if not OPTION_SKIP_CMAKE: - log.info("Configuring module {} ({})...".format(extension, - module_src_dir)) + log.info("Configuring module {} ({})...".format(extension, module_src_dir)) if run_process(cmake_cmd) != 0: - raise DistutilsSetupError("Error configuring {}".format( - extension)) + raise DistutilsSetupError("Error configuring {}".format(extension)) else: log.info("Reusing old configuration for module {} ({})...".format( extension, module_src_dir)) @@ -1101,15 +1074,13 @@ class PysideBuild(_build): log.info("Generating Shiboken documentation") if run_process([self.make_path, "doc"]) != 0: - raise DistutilsSetupError( - "Error generating documentation for {}".format( - extension)) + raise DistutilsSetupError("Error generating documentation " + "for {}".format(extension)) except ImportError: log.info("Sphinx not found, skipping documentation build") else: log.info("Skipped documentation generation") - if not OPTION_SKIP_MAKE_INSTALL: log.info("Installing module {}...".format(extension)) # Need to wait a second, so installed file timestamps are @@ -1117,8 +1088,7 @@ class PysideBuild(_build): # See https://gitlab.kitware.com/cmake/cmake/issues/16155 # for issue details. if sys.platform == 'darwin': - log.info("Waiting 1 second, to ensure installation is " - "successful...") + log.info("Waiting 1 second, to ensure installation is successful...") time.sleep(1) # ninja: error: unknown target 'install/fast' target = 'install/fast' if self.make_generator != 'Ninja' else 'install' @@ -1195,8 +1165,9 @@ class PysideBuild(_build): return temp_config def is_webengine_built(self, built_modules): - return ('WebEngineWidgets' in built_modules or 'WebEngineCore' in built_modules - or 'WebEngine' in built_modules) + return ('WebEngineWidgets' in built_modules + or 'WebEngineCore' in built_modules + or 'WebEngine' in built_modules) def prepare_standalone_clang(self, is_win=False): """ @@ -1274,8 +1245,7 @@ class PysideBuild(_build): make_writable_by_owner=True) else: raise RuntimeError("Error copying libclang library " - "from {} to {}. ".format( - clang_lib_path, destination_dir)) + "from {} to {}. ".format(clang_lib_path, destination_dir)) def update_rpath(self, package_path, executables): if sys.platform.startswith('linux'): @@ -1316,8 +1286,7 @@ class PysideBuild(_build): macos_fix_rpaths_for_library(srcpath, final_rpath) else: - raise RuntimeError('Not configured for platform ' + - sys.platform) + raise RuntimeError('Not configured for platform {}'.format(sys.platform)) pyside_libs.extend(executables) diff --git a/build_scripts/options.py b/build_scripts/options.py index c17f6a100..0e38566d5 100644 --- a/build_scripts/options.py +++ b/build_scripts/options.py @@ -44,8 +44,8 @@ import warnings def _warn_multiple_option(option): - w = 'Option "{}" occurs multiple times on the command line.'.format(option) - warnings.warn(w) + warnings.warn('Option "{}" occurs multiple times on the command line.'.format(option)) + def _warn_deprecated_option(option, replacement=None): w = 'Option "{}" is deprecated and may be removed in a future release.'.format(option) @@ -53,6 +53,7 @@ def _warn_deprecated_option(option, replacement=None): w = '{}\nUse "{}" instead.'.format(w, replacement) warnings.warn(w) + class Options(object): def __init__(self): @@ -62,13 +63,13 @@ class Options(object): def has_option(self, name, remove=True): """ Returns True if argument '--name' was passed on the command line. """ - option = '--' + name + option = '--{}'.format(name) count = sys.argv.count(option) remove_count = count if not remove and count > 0: remove_count -= 1 for i in range(remove_count): - sys.argv.remove(option) + sys.argv.remove(option) if count > 1: _warn_multiple_option(option) return count > 0 @@ -127,8 +128,8 @@ def has_option(*args, **kwargs): return options.has_option(*args, **kwargs) -def option_value(*args,**kwargs): - return options.option_value(*args,**kwargs) +def option_value(*args, **kwargs): + return options.option_value(*args, **kwargs) # Declare options diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py index 067179cdc..e1c2dd5a1 100644 --- a/build_scripts/platforms/linux.py +++ b/build_scripts/platforms/linux.py @@ -75,8 +75,7 @@ def prepare_standalone_package_linux(self, vars): # Check if ICU libraries were copied over to the destination # Qt libdir. resolved_destination_lib_dir = destination_lib_dir.format(**vars) - maybe_icu_libs = find_files_using_glob(resolved_destination_lib_dir, - "libicu*") + maybe_icu_libs = find_files_using_glob(resolved_destination_lib_dir, "libicu*") # If no ICU libraries are present in the Qt libdir (like when # Qt is built against system ICU, or in the Coin CI where ICU @@ -90,43 +89,43 @@ def prepare_standalone_package_linux(self, vars): if self.is_webengine_built(built_modules): copydir("{qt_lib_execs_dir}", - "{st_build_dir}/{st_package_name}/Qt/libexec", - filter=None, - recursive=False, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/libexec", + filter=None, + recursive=False, + vars=vars) copydir("{qt_prefix_dir}/resources", - "{st_build_dir}/{st_package_name}/Qt/resources", - filter=None, - recursive=False, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/resources", + filter=None, + recursive=False, + vars=vars) if copy_plugins: # <qt>/plugins/* -> <setup>/{st_package_name}/Qt/plugins copydir("{qt_plugins_dir}", - "{st_build_dir}/{st_package_name}/Qt/plugins", - filter=["*.so"], - recursive=True, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/plugins", + filter=["*.so"], + recursive=True, + vars=vars) if copy_qml: # <qt>/qml/* -> <setup>/{st_package_name}/Qt/qml copydir("{qt_qml_dir}", - "{st_build_dir}/{st_package_name}/Qt/qml", - filter=None, - force=False, - recursive=True, - ignore=["*.so.debug"], - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/qml", + filter=None, + force=False, + recursive=True, + ignore=["*.so.debug"], + vars=vars) if copy_translations: # <qt>/translations/* -> # <setup>/{st_package_name}/Qt/translations copydir("{qt_translations_dir}", - "{st_build_dir}/{st_package_name}/Qt/translations", - filter=["*.qm", "*.pak"], - force=False, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/translations", + filter=["*.qm", "*.pak"], + force=False, + vars=vars) if copy_qt_conf: # Copy the qt.conf file to libexec. diff --git a/build_scripts/platforms/macos.py b/build_scripts/platforms/macos.py index 49f02754d..159364d9a 100644 --- a/build_scripts/platforms/macos.py +++ b/build_scripts/platforms/macos.py @@ -81,8 +81,8 @@ def prepare_standalone_package_macos(self, vars): if self.qt_is_framework_build(): def framework_dir_filter(dir_name, parent_full_path, dir_full_path): if '.framework' in dir_name: - if (dir_name.startswith('QtWebEngine') and - not self.is_webengine_built(built_modules)): + if (dir_name.startswith('QtWebEngine') + and not self.is_webengine_built(built_modules)): return False if constrain_modules and dir_name not in constrain_frameworks: return False @@ -95,8 +95,7 @@ def prepare_standalone_package_macos(self, vars): return False if dir_full_path.endswith('Versions/5/Helpers'): return False - return general_dir_filter(dir_name, parent_full_path, - dir_full_path) + return general_dir_filter(dir_name, parent_full_path, dir_full_path) # Filter out debug frameworks in the # debug_and_release config. @@ -112,18 +111,17 @@ def prepare_standalone_package_macos(self, vars): return True copydir("{qt_lib_dir}", "{st_build_dir}/{st_package_name}/Qt/lib", - recursive=True, vars=vars, - ignore=["*.la", "*.a", "*.cmake", "*.pc", "*.prl"], - dir_filter_function=framework_dir_filter, - file_filter_function=framework_variant_filter) + recursive=True, vars=vars, + ignore=["*.la", "*.a", "*.cmake", "*.pc", "*.prl"], + dir_filter_function=framework_dir_filter, + file_filter_function=framework_variant_filter) # Fix rpath for WebEngine process executable. The already # present rpath does not work because it assumes a symlink # from Versions/5/Helpers, thus adding two more levels of # directory hierarchy. if self.is_webengine_built(built_modules): - qt_lib_path = "{st_build_dir}/{st_package_name}/Qt/lib".format( - **vars) + qt_lib_path = "{st_build_dir}/{st_package_name}/Qt/lib".format(**vars) bundle = "QtWebEngineCore.framework/Helpers/" bundle += "QtWebEngineProcess.app" binary = "Contents/MacOS/QtWebEngineProcess" @@ -142,24 +140,24 @@ def prepare_standalone_package_macos(self, vars): accepted_modules = ["libQt5" + module + "*.5.dylib" for module in constrain_modules] copydir("{qt_lib_dir}", - "{st_build_dir}/{st_package_name}/Qt/lib", - filter=accepted_modules, - ignore=ignored_modules, - file_filter_function=file_variant_filter, - recursive=True, vars=vars, force_copy_symlinks=True) + "{st_build_dir}/{st_package_name}/Qt/lib", + filter=accepted_modules, + ignore=ignored_modules, + file_filter_function=file_variant_filter, + recursive=True, vars=vars, force_copy_symlinks=True) if self.is_webengine_built(built_modules): copydir("{qt_lib_execs_dir}", - "{st_build_dir}/{st_package_name}/Qt/libexec", - filter=None, - recursive=False, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/libexec", + filter=None, + recursive=False, + vars=vars) copydir("{qt_prefix_dir}/resources", - "{st_build_dir}/{st_package_name}/Qt/resources", - filter=None, - recursive=False, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/resources", + filter=None, + recursive=False, + vars=vars) # Fix rpath for WebEngine process executable. qt_libexec_path = "{st_build_dir}/{st_package_name}/Qt/libexec".format(**vars) @@ -178,30 +176,29 @@ def prepare_standalone_package_macos(self, vars): if copy_plugins: # <qt>/plugins/* -> <setup>/{st_package_name}/Qt/plugins copydir("{qt_plugins_dir}", - "{st_build_dir}/{st_package_name}/Qt/plugins", - filter=["*.dylib"], - recursive=True, - dir_filter_function=general_dir_filter, - file_filter_function=file_variant_filter, - vars=vars) - + "{st_build_dir}/{st_package_name}/Qt/plugins", + filter=["*.dylib"], + recursive=True, + dir_filter_function=general_dir_filter, + file_filter_function=file_variant_filter, + vars=vars) if copy_qml: # <qt>/qml/* -> <setup>/{st_package_name}/Qt/qml copydir("{qt_qml_dir}", - "{st_build_dir}/{st_package_name}/Qt/qml", - filter=None, - recursive=True, - force=False, - dir_filter_function=general_dir_filter, - file_filter_function=file_variant_filter, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/qml", + filter=None, + recursive=True, + force=False, + dir_filter_function=general_dir_filter, + file_filter_function=file_variant_filter, + vars=vars) if copy_translations: # <qt>/translations/* -> # <setup>/{st_package_name}/Qt/translations copydir("{qt_translations_dir}", - "{st_build_dir}/{st_package_name}/Qt/translations", - filter=["*.qm", "*.pak"], - force=False, - vars=vars) + "{st_build_dir}/{st_package_name}/Qt/translations", + filter=["*.qm", "*.pak"], + force=False, + vars=vars) diff --git a/build_scripts/platforms/unix.py b/build_scripts/platforms/unix.py index 9327e8bd7..7f9a6ba94 100644 --- a/build_scripts/platforms/unix.py +++ b/build_scripts/platforms/unix.py @@ -45,7 +45,7 @@ from .macos import prepare_standalone_package_macos from ..config import config from ..options import * -from ..utils import copydir, copyfile, rmtree, makefile +from ..utils import copydir, copyfile, makefile from ..utils import regenerate_qt_resources @@ -203,13 +203,10 @@ def prepare_packages_posix(self, vars): # Re-generate examples Qt resource files for Python 3 # compatibility if sys.version_info[0] == 3: - examples_path = "{st_build_dir}/{st_package_name}/examples".format( - **vars) - pyside_rcc_path = "{install_dir}/bin/rcc".format( - **vars) + examples_path = "{st_build_dir}/{st_package_name}/examples".format(**vars) + pyside_rcc_path = "{install_dir}/bin/rcc".format(**vars) pyside_rcc_options = ['-g', 'python'] - regenerate_qt_resources(examples_path, pyside_rcc_path, - pyside_rcc_options) + regenerate_qt_resources(examples_path, pyside_rcc_path, pyside_rcc_options) # Copy Qt libs to package if OPTION_STANDALONE: diff --git a/build_scripts/platforms/windows_desktop.py b/build_scripts/platforms/windows_desktop.py index a5a5b8fd2..0e7dd766f 100644 --- a/build_scripts/platforms/windows_desktop.py +++ b/build_scripts/platforms/windows_desktop.py @@ -44,7 +44,7 @@ import fnmatch from ..config import config from ..options import * -from ..utils import copydir, copyfile, rmtree, makefile +from ..utils import copydir, copyfile, makefile from ..utils import regenerate_qt_resources, filter_match from ..utils import download_and_extract_7z @@ -223,16 +223,15 @@ def prepare_packages_win32(self, vars): pyside_rcc_path = "{install_dir}/bin/rcc.exe".format( **vars) pyside_rcc_options = ['-g', 'python'] - regenerate_qt_resources(examples_path, pyside_rcc_path, - pyside_rcc_options) + regenerate_qt_resources(examples_path, pyside_rcc_path, pyside_rcc_options) if vars['ssl_libs_dir']: # <ssl_libs>/* -> <setup>/{st_package_name}/openssl copydir("{ssl_libs_dir}", "{st_build_dir}/{st_package_name}/openssl", - filter=[ - "libeay32.dll", - "ssleay32.dll"], - force=False, vars=vars) + filter=[ + "libeay32.dll", + "ssleay32.dll"], + force=False, vars=vars) if config.is_internal_shiboken_module_build(): # The C++ std library dlls need to be packaged with the @@ -382,19 +381,21 @@ def copy_qt_artifacts(self, copy_pdbs, vars): # e.g. "/home/work/qt/qtbase/bin" file_path_dir_name = os.path.dirname(file_full_path) # e.g. "Qt5Coredd" - maybe_debug_name = file_base_name + 'd' + maybe_debug_name = "{}d".format(file_base_name) if self.debug: filter = debug - def predicate(path): return not os.path.exists(path) + + def predicate(path): + return not os.path.exists(path) else: filter = release - def predicate(path): return os.path.exists(path) + + def predicate(path): + return os.path.exists(path) # e.g. "/home/work/qt/qtbase/bin/Qt5Coredd.dll" - other_config_path = os.path.join(file_path_dir_name, - maybe_debug_name + file_ext) + other_config_path = os.path.join(file_path_dir_name, maybe_debug_name + file_ext) - if (filter_match(file_name, filter) and - predicate(other_config_path)): + if (filter_match(file_name, filter) and predicate(other_config_path)): return True return False @@ -411,19 +412,18 @@ def copy_qt_artifacts(self, copy_pdbs, vars): pdb_pattern = "*{}.pdb" if copy_pdbs: plugin_dll_patterns += [pdb_pattern] - plugin_dll_filter = functools.partial(qt_build_config_filter, - plugin_dll_patterns) + plugin_dll_filter = functools.partial(qt_build_config_filter, plugin_dll_patterns) copydir("{qt_plugins_dir}", "{st_build_dir}/{st_package_name}/plugins", - file_filter_function=plugin_dll_filter, - vars=vars) + file_filter_function=plugin_dll_filter, + vars=vars) if copy_translations: # <qt>/translations/* -> <setup>/{st_package_name}/translations copydir("{qt_translations_dir}", - "{st_build_dir}/{st_package_name}/translations", - filter=["*.qm", "*.pak"], - force=False, - vars=vars) + "{st_build_dir}/{st_package_name}/translations", + filter=["*.qm", "*.pak"], + force=False, + vars=vars) if copy_qml: # <qt>/qml/* -> <setup>/{st_package_name}/qml @@ -433,43 +433,41 @@ def copy_qt_artifacts(self, copy_pdbs, vars): # Copy all files that are not dlls and pdbs (.qml, qmldir). copydir("{qt_qml_dir}", "{st_build_dir}/{st_package_name}/qml", - ignore=qml_ignore, - force=False, - recursive=True, - vars=vars) + ignore=qml_ignore, + force=False, + recursive=True, + vars=vars) if copy_pdbs: qml_dll_patterns += [pdb_pattern] - qml_dll_filter = functools.partial(qt_build_config_filter, - qml_dll_patterns) + qml_dll_filter = functools.partial(qt_build_config_filter, qml_dll_patterns) # Copy all dlls (and possibly pdbs). copydir("{qt_qml_dir}", "{st_build_dir}/{st_package_name}/qml", - file_filter_function=qml_dll_filter, - force=False, - recursive=True, - vars=vars) + file_filter_function=qml_dll_filter, + force=False, + recursive=True, + vars=vars) if self.is_webengine_built(built_modules): copydir("{qt_prefix_dir}/resources", - "{st_build_dir}/{st_package_name}/resources", - filter=None, - recursive=False, - vars=vars) + "{st_build_dir}/{st_package_name}/resources", + filter=None, + recursive=False, + vars=vars) filter = 'QtWebEngineProcess{}.exe'.format( 'd' if self.debug else '') copydir("{qt_bin_dir}", - "{st_build_dir}/{st_package_name}", - filter=[filter], - recursive=False, vars=vars) + "{st_build_dir}/{st_package_name}", + filter=[filter], + recursive=False, vars=vars) if copy_qt_conf: # Copy the qt.conf file to prefix dir. - copyfile( - "{build_dir}/pyside2/{st_package_name}/qt.conf", - "{st_build_dir}/{st_package_name}", - vars=vars) + copyfile("{build_dir}/pyside2/{st_package_name}/qt.conf", + "{st_build_dir}/{st_package_name}", + vars=vars) if copy_clang: self.prepare_standalone_clang(is_win=True) diff --git a/build_scripts/qp5_tool.py b/build_scripts/qp5_tool.py index aca8cf7f6..108e38d87 100644 --- a/build_scripts/qp5_tool.py +++ b/build_scripts/qp5_tool.py @@ -72,6 +72,7 @@ Modules=$(MinimalModules),Multimedia Modules-pyside-setup-minimal=$(MinimalModules) """ + def which(needle): """Perform a path search""" needles = [needle] @@ -86,6 +87,7 @@ def which(needle): return binary return None + def execute(args): """Execute a command and print to log""" log_string = '[{}] {}'.format(os.path.basename(os.getcwd()), ' '.join(args)) @@ -94,31 +96,34 @@ def execute(args): if exit_code != 0: raise RuntimeError('FAIL({}): {}'.format(exit_code, log_string)) + def run_git(args): """Run git in the current directory and its submodules""" - args.insert(0, git) # run in repo + args.insert(0, git) # run in repo execute(args) # run for submodules module_args = [git, "submodule", "foreach"] module_args.extend(args) execute(module_args) + def expand_reference(dict, value): """Expand references to other keys in config files $(name) by value.""" pattern = re.compile(r"\$\([^)]+\)") while True: - match = pattern.match(value) - if not match: - break - key = match.group(0)[2:-1] - value = value[:match.start(0)] + dict[key] + value[match.end(0):] + match = pattern.match(value) + if not match: + break + key = match.group(0)[2:-1] + value = value[:match.start(0)] + dict[key] + value[match.end(0):] return value + """ Config file handling, cache and read function """ - config_dict = {} + def read_config_file(fileName): global config_dict keyPattern = re.compile(r'^\s*([A-Za-z0-9\_\-]+)\s*=\s*(.*)$') @@ -136,6 +141,7 @@ def read_config_file(fileName): value += f.readline().rstrip() config_dict[key] = expand_reference(config_dict, value) + def read_tool_config(key): """ Read a value from the '$HOME/.qp5_tool' configuration file. When given @@ -147,11 +153,13 @@ def read_tool_config(key): repo_value = config_dict.get(key + '-' + base_dir) return repo_value if repo_value else config_dict.get(key) + def read_config_build_arguments(): value = read_tool_config('BuildArguments') if value: return re.split(r'\s+', value) - return default_build_args; + return default_build_args + def read_config_modules_argument(): value = read_tool_config('Modules') @@ -159,10 +167,12 @@ def read_config_modules_argument(): return '--module-subset=' + value return None + def read_config_python_binary(): binary = read_tool_config('Python') return binary if binary else 'python' + def get_config_file(): home = os.getenv('HOME') if is_windows: @@ -182,6 +192,7 @@ def get_config_file(): config_file = os.path.join(home, '.' + config_file_name) return config_file + def get_options(desc): parser = ArgumentParser(description=desc, formatter_class=RawTextHelpFormatter) parser.add_argument('--reset', '-r', action='store_true', @@ -199,6 +210,7 @@ def get_options(desc): return parser.parse_args() + if __name__ == '__main__': git = None diff --git a/build_scripts/qtinfo.py b/build_scripts/qtinfo.py index fbe8e68ad..7680dad02 100644 --- a/build_scripts/qtinfo.py +++ b/build_scripts/qtinfo.py @@ -37,9 +37,13 @@ ## ############################################################################# -import os, sys, re, subprocess +import os +import sys +import re +import subprocess from distutils.spawn import find_executable + class QtInfo(object): def __init__(self, qmake_command=None): self.initialized = False @@ -47,7 +51,7 @@ class QtInfo(object): if qmake_command: self._qmake_command = qmake_command else: - self._qmake_command = [find_executable("qmake"),] + self._qmake_command = [find_executable("qmake"), ] # Dict to cache qmake values. self._query_dict = {} @@ -120,9 +124,9 @@ class QtInfo(object): def get_mkspecs_variables(self): return self._mkspecs_dict - def _get_qmake_output(self, args_list = []): + def _get_qmake_output(self, args_list=[]): cmd = self._qmake_command + args_list - proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, shell=False) + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=False) output = proc.communicate()[0] proc.wait() if proc.returncode != 0: diff --git a/build_scripts/setup_runner.py b/build_scripts/setup_runner.py index 0e45a13f4..522d053a2 100644 --- a/build_scripts/setup_runner.py +++ b/build_scripts/setup_runner.py @@ -37,7 +37,9 @@ ## ############################################################################# -import sys, os, textwrap +import sys +import os +import textwrap from build_scripts.config import config from build_scripts.main import get_package_version, get_setuptools_extension_modules diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 56ec8e350..ca67cc9cf 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -55,7 +55,6 @@ except ImportError: import urllib import distutils.log as log -from distutils.errors import DistutilsOptionError from distutils.errors import DistutilsSetupError try: @@ -79,7 +78,7 @@ def update_env_path(newpaths): if not path.lower() in paths: log.info("Inserting path '{}' to environment".format(path)) paths.insert(0, path) - os.environ['PATH'] = path + os.pathsep + os.environ['PATH'] + os.environ['PATH'] = "{}{}{}".format(path, os.pathsep, os.environ['PATH']) def winsdk_setenv(platform_arch, build_type): @@ -96,30 +95,27 @@ def winsdk_setenv(platform_arch, build_type): "v7.1": 10.0 } - log.info("Searching Windows SDK with MSVC compiler version {}".format( - MSVC_VERSION)) + log.info("Searching Windows SDK with MSVC compiler version {}".format(MSVC_VERSION)) setenv_paths = [] for base in HKEYS: sdk_versions = Reg.read_keys(base, WINSDK_BASE) if sdk_versions: for sdk_version in sdk_versions: - installationfolder = Reg.get_value(WINSDK_BASE + "\\" + - sdk_version, "installationfolder") - productversion = Reg.get_value(WINSDK_BASE + "\\" + - sdk_version, "productversion") - setenv_path = os.path.join(installationfolder, os.path.join( - 'bin', 'SetEnv.cmd')) + installationfolder = Reg.get_value("{}\\{}".format(WINSDK_BASE, sdk_version), + "installationfolder") + # productversion = Reg.get_value("{}\\{}".format(WINSDK_BASE, sdk_version), + # "productversion") + setenv_path = os.path.join(installationfolder, os.path.join('bin', 'SetEnv.cmd')) if not os.path.exists(setenv_path): continue - if not sdk_version in sdk_version_map: + if sdk_version not in sdk_version_map: continue if sdk_version_map[sdk_version] != MSVC_VERSION: continue setenv_paths.append(setenv_path) if len(setenv_paths) == 0: - raise DistutilsSetupError( - "Failed to find the Windows SDK with MSVC compiler " - "version {}".format(MSVC_VERSION)) + raise DistutilsSetupError("Failed to find the Windows SDK with MSVC compiler " + "version {}".format(MSVC_VERSION)) for setenv_path in setenv_paths: log.info("Found {}".format(setenv_path)) @@ -165,14 +161,13 @@ def find_vcdir(version): else: vsbase = VSEXPRESS_BASE % version try: - productdir = Reg.get_value(r"{}\Setup\VC".format(vsbase), - "productdir") + productdir = Reg.get_value(r"{}\Setup\VC".format(vsbase), "productdir") except KeyError: productdir = None log.debug("Unable to find productdir in registry") if not productdir or not os.path.isdir(productdir): - toolskey = "VS%0.f0COMNTOOLS" % version + toolskey = "VS{:0.0f}0COMNTOOLS".format(version) toolsdir = os.environ.get(toolskey, None) if toolsdir and os.path.isdir(toolsdir): @@ -195,29 +190,25 @@ def init_msvc_env(platform_arch, build_type): log.info("Searching MSVC compiler version {}".format(MSVC_VERSION)) vcdir_path = find_vcdir(MSVC_VERSION) if not vcdir_path: - raise DistutilsSetupError( - "Failed to find the MSVC compiler version {} on your " - "system.".format(MSVC_VERSION)) + raise DistutilsSetupError("Failed to find the MSVC compiler version {} on your " + "system.".format(MSVC_VERSION)) else: log.info("Found {}".format(vcdir_path)) - log.info("Searching MSVC compiler {} environment init script".format( - MSVC_VERSION)) + log.info("Searching MSVC compiler {} environment init script".format(MSVC_VERSION)) if platform_arch.startswith("32"): vcvars_path = os.path.join(vcdir_path, "bin", "vcvars32.bat") else: vcvars_path = os.path.join(vcdir_path, "bin", "vcvars64.bat") if not os.path.exists(vcvars_path): - vcvars_path = os.path.join(vcdir_path, "bin", "amd64", - "vcvars64.bat") + vcvars_path = os.path.join(vcdir_path, "bin", "amd64", "vcvars64.bat") if not os.path.exists(vcvars_path): - vcvars_path = os.path.join(vcdir_path, "bin", "amd64", - "vcvarsamd64.bat") + vcvars_path = os.path.join(vcdir_path, "bin", "amd64", "vcvarsamd64.bat") if not os.path.exists(vcvars_path): # MSVC init script not found, try to find and init Windows SDK env log.error("Failed to find the MSVC compiler environment init script " - "(vcvars.bat) on your system.") + "(vcvars.bat) on your system.") winsdk_setenv(platform_arch, build_type) return else: @@ -249,8 +240,7 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False, dst = dst.format(**vars) if not os.path.exists(src) and not force: - log.info("**Skiping copy file {} to {}. " - "Source does not exists.".format(src, dst)) + log.info("**Skiping copy file {} to {}. Source does not exists.".format(src, dst)) return if not os.path.islink(src) or force_copy_symlink: @@ -270,17 +260,15 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False, os.chdir(target_dir) if os.path.exists(link_name): os.remove(link_name) - log.info("Symlinking {} -> {} in {}.".format(link_name, - link_target, target_dir)) + log.info("Symlinking {} -> {} in {}.".format(link_name, link_target, target_dir)) os.symlink(link_target, link_name) except OSError: - log.error("{} -> {}: Error creating symlink".format(link_name, - link_target)) + log.error("{} -> {}: Error creating symlink".format(link_name, link_target)) finally: os.chdir(current_directory) else: log.error("{} -> {}: Can only create symlinks within the same " - "directory".format(src, link_target_path)) + "directory".format(src, link_target_path)) return dst @@ -297,15 +285,13 @@ def makefile(dst, content=None, vars=None): if not os.path.exists(dstdir): os.makedirs(dstdir) - f = open(dst, "wt") - if content is not None: - f.write(content) - f.close() + with open(dst, "wt") as f: + if content is not None: + f.write(content) -def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, - vars=None, dir_filter_function=None, file_filter_function=None, - force_copy_symlinks=False): +def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, vars=None, + dir_filter_function=None, file_filter_function=None, force_copy_symlinks=False): if vars is not None: src = src.format(**vars) @@ -319,11 +305,10 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, if not os.path.exists(src) and not force: log.info("**Skiping copy tree {} to {}. Source does not exists. " - "filter={}. ignore={}.".format(src, dst, filter, ignore)) + "filter={}. ignore={}.".format(src, dst, filter, ignore)) return [] - log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src, - dst, filter, ignore)) + log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src, dst, filter, ignore)) names = os.listdir(src) @@ -334,25 +319,20 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, dstname = os.path.join(dst, name) try: if os.path.isdir(srcname): - if (dir_filter_function and - not dir_filter_function(name, src, srcname)): + if (dir_filter_function and not dir_filter_function(name, src, srcname)): continue if recursive: - results.extend( - copydir(srcname, dstname, filter, ignore, force, - recursive, vars, dir_filter_function, - file_filter_function, force_copy_symlinks)) + results.extend(copydir(srcname, dstname, filter, ignore, force, recursive, + vars, dir_filter_function, file_filter_function, + force_copy_symlinks)) else: - if ((file_filter_function is not None and - not file_filter_function(name, srcname)) or - (filter is not None and - not filter_match(name, filter)) or - (ignore is not None and filter_match(name, ignore))): + if ((file_filter_function is not None and not file_filter_function(name, srcname)) + or (filter is not None and not filter_match(name, filter)) + or (ignore is not None and filter_match(name, ignore))): continue if not os.path.exists(dst): os.makedirs(dst) - results.append(copyfile(srcname, dstname, True, vars, - force_copy_symlinks)) + results.append(copyfile(srcname, dstname, True, vars, force_copy_symlinks)) # catch the Error from the recursive copytree so that we can # continue with other files except shutil.Error as err: @@ -372,26 +352,27 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, raise EnvironmentError(errors) return results + def make_file_writable_by_owner(path): current_permissions = stat.S_IMODE(os.lstat(path).st_mode) os.chmod(path, current_permissions | stat.S_IWUSR) + def rmtree(dirname, ignore=False): def handle_remove_readonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: - os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777 + os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 func(path) else: raise IOError shutil.rmtree(dirname, ignore_errors=ignore, onerror=handle_remove_readonly) + def run_process_output(args, initial_env=None): if initial_env is None: initial_env = os.environ - std_out = subprocess.Popen(args, - env = initial_env, - universal_newlines = 1, + std_out = subprocess.Popen(args, env=initial_env, universal_newlines=1, stdout=subprocess.PIPE).stdout result = [] for raw_line in std_out.readlines(): @@ -399,15 +380,14 @@ def run_process_output(args, initial_env=None): result.append(line.rstrip()) return result + def run_process(args, initial_env=None): """ Run process until completion and return the process exit code. No output is captured. """ - log.info("Running process in directory {0}: command {1}".format( - os.getcwd(), - " ".join([(" " in x and '"{0}"'.format(x) or x) for x in args])) - ) + command = " ".join([(" " in x and '"{}"'.format(x) or x) for x in args]) + log.info("Running process in directory {}: command {}".format(os.getcwd(), command)) if initial_env is None: initial_env = os.environ @@ -441,7 +421,8 @@ def get_environment_from_batch_command(env_cmd, initial=None): def consume(iter): try: - while True: next(iter) + while True: + next(iter) except StopIteration: pass @@ -452,22 +433,19 @@ def get_environment_from_batch_command(env_cmd, initial=None): # create a tag so we can tell in the output when the proc is done tag = 'Done running command' # construct a cmd.exe command to do accomplish this - cmd = 'cmd.exe /E:ON /V:ON /s /c "{} && echo "{}" && set"'.format(env_cmd, - tag) + cmd = 'cmd.exe /E:ON /V:ON /s /c "{} && echo "{}" && set"'.format(env_cmd, tag) # launch the process proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial) # parse the output sent to stdout lines = proc.stdout if sys.version_info[0] > 2: # make sure the lines are strings - make_str = lambda s: s.decode() - lines = map(make_str, lines) + lines = map(lambda s: s.decode(), lines) # consume whatever output occurs until the tag is reached consume(itertools.takewhile(lambda l: tag not in l, lines)) # define a way to handle each KEY=VALUE line - handle_line = lambda l: l.rstrip().split('=',1) # parse key/values into pairs - pairs = map(handle_line, lines) + pairs = map(lambda l: l.rstrip().split('=', 1), lines) # make sure the pairs are valid valid_pairs = filter(validate_pair, pairs) # construct a dictionary of the pairs @@ -482,19 +460,14 @@ def regenerate_qt_resources(src, pyside_rcc_path, pyside_rcc_options): for name in names: srcname = os.path.join(src, name) if os.path.isdir(srcname): - regenerate_qt_resources(srcname, - pyside_rcc_path, - pyside_rcc_options) + regenerate_qt_resources(srcname, pyside_rcc_path, pyside_rcc_options) elif srcname.endswith('.qrc'): # Replace last occurence of '.qrc' in srcname srcname_split = srcname.rsplit('.qrc', 1) dstname = '_rc.py'.join(srcname_split) if os.path.exists(dstname): - log.info('Regenerating {} from {}'.format(dstname, - os.path.basename(srcname))) - run_process([pyside_rcc_path] + - pyside_rcc_options - + [srcname, '-o', dstname]) + log.info('Regenerating {} from {}'.format(dstname, os.path.basename(srcname))) + run_process([pyside_rcc_path] + pyside_rcc_options + [srcname, '-o', dstname]) def back_tick(cmd, ret_err=False): @@ -526,8 +499,7 @@ def back_tick(cmd, ret_err=False): Raises RuntimeError if command returns non-zero exit code when ret_err isn't set. """ - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, shell=True) + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) out, err = proc.communicate() if not isinstance(out, str): # python 3 @@ -536,7 +508,7 @@ def back_tick(cmd, ret_err=False): retcode = proc.returncode if retcode is None and not ret_err: proc.terminate() - raise RuntimeError(cmd + ' process did not terminate') + raise RuntimeError("{} process did not terminate".format(cmd)) if retcode != 0 and not ret_err: raise RuntimeError("{} process returned code {}\n*** {}".format( (cmd, retcode, err))) @@ -548,6 +520,7 @@ def back_tick(cmd, ret_err=False): MACOS_OUTNAME_RE = re.compile(r'\(compatibility version [\d.]+, current version [\d.]+\)') + def macos_get_install_names(libpath): """ Get macOS library install names from library `libpath` using ``otool`` @@ -562,13 +535,14 @@ def macos_get_install_names(libpath): install_names : list of str install names in library `libpath` """ - out = back_tick('otool -L ' + libpath) + out = back_tick("otool -L {}".format(libpath)) libs = [line for line in out.split('\n')][1:] return [MACOS_OUTNAME_RE.sub('', lib).strip() for lib in libs] MACOS_RPATH_RE = re.compile(r"path (.+) \(offset \d+\)") + def macos_get_rpaths(libpath): """ Get rpath load commands from library `libpath` using ``otool`` @@ -586,7 +560,7 @@ def macos_get_rpaths(libpath): ----- See ``man dyld`` for more information on rpaths in libraries """ - lines = back_tick('otool -l ' + libpath).split('\n') + lines = back_tick('otool -l {}'.format(libpath)).split('\n') ctr = 0 rpaths = [] while ctr < len(lines): @@ -598,14 +572,15 @@ def macos_get_rpaths(libpath): rpath_line = lines[ctr + 2].strip() match = MACOS_RPATH_RE.match(rpath_line) if match is None: - raise RuntimeError('Unexpected path line: ' + rpath_line) + raise RuntimeError("Unexpected path line: {}".format(rpath_line)) rpaths.append(match.groups()[0]) ctr += 3 return rpaths + def macos_add_rpath(rpath, library_path): - back_tick('install_name_tool -add_rpath {rpath} {library_path}'.format( - rpath=rpath, library_path=library_path)) + back_tick("install_name_tool -add_rpath {} {}".format(rpath, library_path)) + def macos_fix_rpaths_for_library(library_path, qt_lib_dir): """ Adds required rpath load commands to given library. @@ -648,11 +623,11 @@ def macos_fix_rpaths_for_library(library_path, qt_lib_dir): # If the library depends on a Qt library, add an rpath load comment # pointing to the Qt lib directory. - macos_add_qt_rpath(library_path, qt_lib_dir, existing_rpath_commands, - install_names) + macos_add_qt_rpath(library_path, qt_lib_dir, existing_rpath_commands, install_names) + -def macos_add_qt_rpath(library_path, qt_lib_dir, - existing_rpath_commands = [], library_dependencies = []): +def macos_add_qt_rpath(library_path, qt_lib_dir, existing_rpath_commands=[], + library_dependencies=[]): """ Adds an rpath load command to the Qt lib directory if necessary @@ -680,6 +655,7 @@ def macos_add_qt_rpath(library_path, qt_lib_dir, if needs_qt_rpath: macos_add_rpath(qt_lib_dir, library_path) + # Find an executable specified by a glob pattern ('foo*') in the OS path def find_glob_in_path(pattern): result = [] @@ -691,6 +667,7 @@ def find_glob_in_path(pattern): result.append(match) return result + # Locate the most recent version of llvm_config in the path. def find_llvm_config(): version_re = re.compile(r'(\d+)\.(\d+)\.(\d+)') @@ -702,8 +679,9 @@ def find_llvm_config(): if output: match = version_re.match(output[0]) if match: - version_string = '%02d%02d%02d' % (int(match.group(1)), - int(match.group(2)), int(match.group(3))) + version_string = "{:02d}{:02d}{:02d}".format(int(match.group(1)), + int(match.group(2)), + int(match.group(3))) if (version_string > last_version_string): result = llvm_config last_version_string = version_string @@ -711,6 +689,7 @@ def find_llvm_config(): pass return result + # Add Clang to path for Windows for the shiboken ApiExtractor tests. # Revisit once Clang is bundled with Qt. def detect_clang(): @@ -729,12 +708,14 @@ def detect_clang(): except OSError: pass if clang_dir: - arch = '64' if sys.maxsize > 2**31-1 else '32' + arch = '64' if sys.maxsize > 2 ** 31 - 1 else '32' clang_dir = clang_dir.replace('_ARCH_', arch) return (clang_dir, source) + _7z_binary = None + def download_and_extract_7z(fileurl, target): """ Downloads 7z file from fileurl and extract to target """ info = "" @@ -752,12 +733,12 @@ def download_and_extract_7z(fileurl, target): try: global _7z_binary - outputDir = "-o" + target + outputDir = "-o{}".format(target) if not _7z_binary: if sys.platform == 'win32': candidate = 'c:\\Program Files\\7-Zip\\7z.exe' if os.path.exists(candidate): - _7z_binary = candidate + _7z_binary = candidate if not _7z_binary: _7z_binary = '7z' print("calling {} x {} {}".format(_7z_binary, localfile, outputDir)) @@ -765,10 +746,12 @@ def download_and_extract_7z(fileurl, target): except: raise RuntimeError(' Error extracting {}'.format(localfile)) -def split_and_strip(input): - lines = [s.strip() for s in input.splitlines()] + +def split_and_strip(sinput): + lines = [s.strip() for s in sinput.splitlines()] return lines + def ldd_get_dependencies(executable_path): """ Returns a dictionary of dependencies that `executable_path` @@ -787,8 +770,8 @@ def ldd_get_dependencies(executable_path): dependencies[match.group(1)] = match.group(2) return dependencies -def ldd_get_paths_for_dependencies(dependencies_regex, executable_path = None, - dependencies = None): + +def ldd_get_paths_for_dependencies(dependencies_regex, executable_path=None, dependencies=None): """ Returns file paths to shared library dependencies that match given `dependencies_regex` against given `executable_path`. @@ -818,6 +801,7 @@ def ldd_get_paths_for_dependencies(dependencies_regex, executable_path = None, return paths + def ldd(executable_path): """ Returns ld.so output of shared library dependencies for given @@ -848,8 +832,7 @@ def ldd(executable_path): chosen_rtld = None # List of ld's considered by ldd on Ubuntu (here's hoping it's the # same on all distros). - rtld_list = ["/lib/ld-linux.so.2", "/lib64/ld-linux-x86-64.so.2", - "/libx32/ld-linux-x32.so.2"] + rtld_list = ["/lib/ld-linux.so.2", "/lib64/ld-linux-x86-64.so.2", "/libx32/ld-linux-x32.so.2"] # Choose appropriate runtime dynamic linker. for rtld in rtld_list: @@ -858,8 +841,7 @@ def ldd(executable_path): # Code 127 is returned by ld.so when called without any # arguments (some kind of sanity check I guess). if code == 127: - (_, _, code) = back_tick("{} --verify {}".format(rtld, - executable_path), True) + (_, _, code) = back_tick("{} --verify {}".format(rtld, executable_path), True) # Codes 0 and 2 mean given executable_path can be # understood by ld.so. if code in [0, 2]: @@ -867,8 +849,7 @@ def ldd(executable_path): break if not chosen_rtld: - raise RuntimeError("Could not find appropriate ld.so to query " - "for dependencies.") + raise RuntimeError("Could not find appropriate ld.so to query for dependencies.") # Query for shared library dependencies. rtld_env = "LD_TRACE_LOADED_OBJECTS=1" @@ -878,7 +859,8 @@ def ldd(executable_path): return out else: raise RuntimeError("ld.so failed to query for dependent shared " - "libraries of {} ".format(executable_path)) + "libraries of {} ".format(executable_path)) + def find_files_using_glob(path, pattern): """ Returns list of files that matched glob `pattern` in `path`. """ @@ -886,6 +868,7 @@ def find_files_using_glob(path, pattern): maybe_files = glob.glob(final_pattern) return maybe_files + def find_qt_core_library_glob(lib_dir): """ Returns path to the QtCore library found in `lib_dir`. """ maybe_file = find_files_using_glob(lib_dir, "libQt5Core.so.?") @@ -893,6 +876,7 @@ def find_qt_core_library_glob(lib_dir): return maybe_file[0] return None + # @TODO: Possibly fix ICU library copying on macOS and Windows. # This would require to implement the equivalent of the custom written # ldd for the specified platforms. @@ -907,7 +891,7 @@ def copy_icu_libs(patchelf, destination_lib_dir): if not qt_core_library_path or not os.path.exists(qt_core_library_path): raise RuntimeError('QtCore library does not exist at path: {}. ' - 'Failed to copy ICU libraries.'.format(qt_core_library_path)) + 'Failed to copy ICU libraries.'.format(qt_core_library_path)) dependencies = ldd_get_dependencies(qt_core_library_path) @@ -921,11 +905,9 @@ def copy_icu_libs(patchelf, destination_lib_dir): break if icu_required: - paths = ldd_get_paths_for_dependencies(icu_regex, - dependencies=dependencies) + paths = ldd_get_paths_for_dependencies(icu_regex, dependencies=dependencies) if not paths: - raise RuntimeError("Failed to find the necessary ICU libraries " - "required by QtCore.") + raise RuntimeError("Failed to find the necessary ICU libraries required by QtCore.") log.info('Copying the detected ICU libraries required by QtCore.') if not os.path.exists(destination_lib_dir): @@ -941,8 +923,7 @@ def copy_icu_libs(patchelf, destination_lib_dir): # Patch the QtCore library to find the copied over ICU libraries # (if necessary). - log.info("Checking if QtCore library needs a new rpath to make it " - "work with ICU libs.") + log.info("Checking if QtCore library needs a new rpath to make it work with ICU libs.") rpaths = linux_get_rpaths(qt_core_library_path) if not rpaths or not rpaths_has_origin(rpaths): log.info('Patching QtCore library to contain $ORIGIN rpath.') @@ -967,8 +948,7 @@ def linux_set_rpaths(patchelf, executable_path, rpath_string): cmd = [patchelf, '--set-rpath', rpath_string, executable_path] if run_process(cmd) != 0: - raise RuntimeError("Error patching rpath in {}".format( - executable_path)) + raise RuntimeError("Error patching rpath in {}".format(executable_path)) def linux_get_dependent_libraries(executable_path): @@ -1061,6 +1041,7 @@ def linux_fix_rpaths_for_library(patchelf, executable_path, qt_rpath, override=F rpaths_string = ':'.join(rpaths) linux_set_rpaths(patchelf, executable_path, rpaths_string) + def memoize(function): """ Decorator to wrap a function with a memoizing callable. @@ -1068,6 +1049,7 @@ def memoize(function): the same arguments. """ memo = {} + def wrapper(*args): if args in memo: return memo[args] @@ -1077,6 +1059,7 @@ def memoize(function): return rv return wrapper + def get_python_dict(python_script_path): try: with open(python_script_path) as f: @@ -1086,9 +1069,10 @@ def get_python_dict(python_script_path): return python_dict except IOError as e: print("get_python_dict: Couldn't get dict from python " - "file: {}.".format(python_script_path)) + "file: {}.".format(python_script_path)) raise + def install_pip_package_from_url_specifier(env_pip, url, upgrade=True): args = [env_pip, "install", url] if upgrade: @@ -1096,22 +1080,24 @@ def install_pip_package_from_url_specifier(env_pip, url, upgrade=True): args.append(url) run_instruction(args, "Failed to install {}".format(url)) + def install_pip_dependencies(env_pip, packages, upgrade=True): for p in packages: args = [env_pip, "install"] if upgrade: args.append("--upgrade") args.append(p) - run_instruction(args, "Failed to install " + p) + run_instruction(args, "Failed to install {}".format(p)) + def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): _pExe = "python" - _env = "env" + str(python_ver) + _env = "env{}".format(str(python_ver)) env_python = _env + "/bin/python" env_pip = _env + "/bin/pip" if host == "Windows": - print("New virtualenv to build " + targetArch + " in " + hostArch + " host.") + print("New virtualenv to build {} in {} host".format(targetArch, hostArch)) _pExe = "python.exe" # With windows we are creating building 32-bit target in 64-bit host if hostArch == "X86_64" and targetArch == "X86": @@ -1129,26 +1115,30 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): _pExe = "python3" return(_pExe, _env, env_pip, env_python) + def run_instruction(instruction, error, initial_env=None): if initial_env is None: initial_env = os.environ - print("Running Coin instruction: " + ' '.join(str(e) for e in instruction)) + print("Running Coin instruction: {}".format(' '.join(str(e) for e in instruction))) result = subprocess.call(instruction, env=initial_env) if result != 0: - print("ERROR : " + error) + print("ERROR : {}".format(error)) exit(result) + def acceptCITestConfiguration(hostOS, hostOSVer, targetArch, compiler): # Disable unsupported CI configs for now # NOTE: String must match with QT CI's storagestruct thrift - if hostOSVer in ["WinRT_10", "WebAssembly", "Ubuntu_18_04", "Android_ANY"] \ - or hostOSVer.startswith("SLES_"): - print("Disabled " + hostOSVer + " from Coin configuration") + if (hostOSVer in ["WinRT_10", "WebAssembly", "Ubuntu_18_04", "Android_ANY"] + or hostOSVer.startswith("SLES_")): + print("Disabled {} from Coin configuration".format(hostOSVer)) return False - # With 5.11 CI will create two sets of release binaries, one with msvc 2015 and one with msvc 2017 - # we shouldn't release the 2015 version. BUT, 32 bit build is done only on msvc 2015... + # With 5.11 CI will create two sets of release binaries, + # one with msvc 2015 and one with msvc 2017 + # we shouldn't release the 2015 version. + # BUT, 32 bit build is done only on msvc 2015... if compiler in ["MSVC2015"] and targetArch in ["X86_64"]: - print("Disabled " + compiler + " to " + targetArch + " from Coin configuration") + print("Disabled {} to {} from Coin configuration".format(compiler, targetArch)) return False return True @@ -1158,6 +1148,6 @@ def get_ci_qmake_path(ci_install_dir, ci_host_os): if ci_host_os == "MacOS": return qmake_path + "/bin/qmake" elif ci_host_os == "Windows": - return qmake_path + "\\bin\\qmake.exe" + return qmake_path + "\\bin\\qmake.exe" else: return qmake_path + "/bin/qmake" diff --git a/build_scripts/wheel_override.py b/build_scripts/wheel_override.py index b06628b3b..c6eb87d39 100644 --- a/build_scripts/wheel_override.py +++ b/build_scripts/wheel_override.py @@ -41,7 +41,8 @@ wheel_module_exists = False try: - import os, sys + import os + import sys from distutils import log as logger from wheel import pep425tags @@ -60,6 +61,7 @@ except Exception as e: print('***** Exception while trying to prepare bdist_wheel override class: {}. ' 'Skipping wheel overriding.'.format(e)) + def get_bdist_wheel_override(params): if wheel_module_exists: class PysideBuildWheelDecorated(PysideBuildWheel): @@ -70,6 +72,7 @@ def get_bdist_wheel_override(params): else: return None + class PysideBuildWheel(_bdist_wheel): def __init__(self, *args, **kwargs): self.pyside_params = None @@ -101,8 +104,7 @@ class PysideBuildWheel(_bdist_wheel): qt_version = self.params['qt_version'] package_version = self.params['package_version'] wheel_version = "{}-{}".format(package_version, qt_version) - components = (_safer_name(self.distribution.get_name()), - wheel_version) + components = (_safer_name(self.distribution.get_name()), wheel_version) if self.build_number: components += (self.build_number,) return '-'.join(components) @@ -135,8 +137,9 @@ class PysideBuildWheel(_bdist_wheel): # pypi). # TODO: Add actual distro detection, instead of # relying on limited_api option. - if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize > 2147483647 \ - and (self.py_limited_api or sys.version_info[0] == 2): + if (plat_name in ('linux-x86_64', 'linux_x86_64') + and sys.maxsize > 2147483647 + and (self.py_limited_api or sys.version_info[0] == 2)): plat_name = 'manylinux1_x86_64' plat_name = plat_name.replace('-', '_').replace('.', '_') @@ -163,8 +166,7 @@ class PysideBuildWheel(_bdist_wheel): if (self.py_limited_api) or (plat_name in ('manylinux1_x86_64') and sys.version_info[0] == 2): return tag assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0]) - assert tag in supported_tags, ( - "would build wheel with unsupported tag {}".format(tag)) + assert tag in supported_tags, ("would build wheel with unsupported tag {}".format(tag)) return tag # Copy of get_tag from bdist_wheel.py, to write a triplet Tag @@ -201,4 +203,3 @@ class PysideBuildWheel(_bdist_wheel): if not wheel_module_exists: del PysideBuildWheel - |