diff options
author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2020-10-27 16:21:18 +0100 |
---|---|---|
committer | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2020-10-27 16:38:07 +0000 |
commit | 844f1cc2541fe7213ebf2d72039ef28a04e200b4 (patch) | |
tree | aa13653009c1669952c5f64e5d668cfdc26b8a86 /build_scripts | |
parent | 07b74c8fde23db33d55b17b08d1d81e1f83b3291 (diff) |
build_scripts: remove references to python 2
* Removing all the special cases for Python 2.7
* Removing Python >=3 conditions
* Keeping Python 3.6+ as the allowed Python
Change-Id: Ie48cafe952ae7a11bea997da2a35e7df5fea9a44
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'build_scripts')
-rw-r--r-- | build_scripts/config.py | 5 | ||||
-rw-r--r-- | build_scripts/main.py | 36 | ||||
-rw-r--r-- | build_scripts/platforms/unix.py | 9 | ||||
-rw-r--r-- | build_scripts/platforms/windows_desktop.py | 11 | ||||
-rw-r--r-- | build_scripts/qtinfo.py | 5 | ||||
-rw-r--r-- | build_scripts/utils.py | 15 | ||||
-rw-r--r-- | build_scripts/wheel_override.py | 11 |
7 files changed, 24 insertions, 68 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py index 86482a043..a69e8fe81 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -85,10 +85,7 @@ class Config(object): # interpreter version. self.python_version_classifiers = [ 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', @@ -135,7 +132,7 @@ class Config(object): setup_kwargs['zip_safe'] = False setup_kwargs['cmdclass'] = cmd_class_dict setup_kwargs['version'] = package_version - setup_kwargs['python_requires'] = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.10" + setup_kwargs['python_requires'] = ">=3.6, <3.10" if quiet: # Tells distutils / setuptools to be quiet, and only print warnings or errors. diff --git a/build_scripts/main.py b/build_scripts/main.py index 988743b8b..384ae6785 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -155,23 +155,13 @@ def _get_py_library_unix(build_type, py_version, py_prefix, py_libdir, lib_exts = ['.so'] if sys.platform == 'darwin': lib_exts.append('.dylib') - if sys.version_info[0] > 2: - lib_suff = getattr(sys, 'abiflags', None) - else: # Python 2 - lib_suff = '' + lib_suff = getattr(sys, 'abiflags', None) lib_exts.append('.so.1') # Suffix for OpenSuSE 13.01 lib_exts.append('.so.1.0') # static library as last gasp lib_exts.append('.a') - if sys.version_info[0] == 2 and dbg_postfix: - # For Python2 add a duplicate set of extensions combined with the - # dbg_postfix, so we test for both the debug version of the lib - # and the normal one. This allows a debug PySide2 to be built with a - # non-debug Python. - lib_exts = [dbg_postfix + e for e in lib_exts] + lib_exts - libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython{}{}{}".format(py_version, lib_suff, lib_ext) @@ -179,23 +169,6 @@ def _get_py_library_unix(build_type, py_version, py_prefix, py_libdir, if os.path.exists(py_library): return py_library libs_tried.append(py_library) - # At least on macOS 10.11, the system Python 2.6 does not include a - # symlink to the framework file disguised as a .dylib file, thus finding - # the library would fail. Manually check if a framework file "Python" - # exists in the Python framework bundle. - if sys.platform == 'darwin' and sys.version_info[:2] == (2, 6): - # These manipulations essentially transform - # /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)): - return possible_framework_library - libs_tried.append(possible_framework_library) # Try to find shared libraries which have a multi arch # suffix. @@ -298,7 +271,7 @@ def prefix(): name += "d" if is_debug_python(): name += "p" - if OPTION["LIMITED_API"] == "yes" and sys.version_info[0] == 3: + if OPTION["LIMITED_API"] == "yes": name += "a" return name @@ -810,7 +783,7 @@ class PysideBuild(_build, DistUtilsCommandMixin): pass else: raise DistutilsSetupError("option limited-api must be 'yes' or 'no' " - "(default yes if applicable, i.e. python version >= 3.5)") + "(default yes if applicable, i.e. python version >= 3.6)") if OPTION["VERBOSE_BUILD"]: cmake_cmd.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON") @@ -850,8 +823,7 @@ class PysideBuild(_build, DistUtilsCommandMixin): if extension.lower() in ["shiboken2"]: cmake_cmd.append("-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=yes") - if sys.version_info[0] > 2: - cmake_cmd.append("-DUSE_PYTHON_VERSION=3.3") + cmake_cmd.append("-DUSE_PYTHON_VERSION=3.6") if sys.platform == 'darwin': if OPTION["MACOS_ARCH"]: diff --git a/build_scripts/platforms/unix.py b/build_scripts/platforms/unix.py index 754cdc961..30fa237c7 100644 --- a/build_scripts/platforms/unix.py +++ b/build_scripts/platforms/unix.py @@ -202,11 +202,10 @@ def prepare_packages_posix(self, vars): force=False, vars=vars, dir_filter_function=pycache_dir_filter) # 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 = "rcc" - pyside_rcc_options = ['-g', 'python'] - regenerate_qt_resources(examples_path, pyside_rcc_path, pyside_rcc_options) + examples_path = "{st_build_dir}/{st_package_name}/examples".format(**vars) + pyside_rcc_path = "rcc" + pyside_rcc_options = ['-g', 'python'] + 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 112bd436f..77bf9bfd2 100644 --- a/build_scripts/platforms/windows_desktop.py +++ b/build_scripts/platforms/windows_desktop.py @@ -217,12 +217,11 @@ def prepare_packages_win32(self, vars): force=False, vars=vars, dir_filter_function=pycache_dir_filter) # 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 = "rcc.exe" - pyside_rcc_options = ['-g', 'python'] - regenerate_qt_resources(examples_path, pyside_rcc_path, pyside_rcc_options) + examples_path = "{st_build_dir}/{st_package_name}/examples".format( + **vars) + pyside_rcc_path = "rcc.exe" + pyside_rcc_options = ['-g', 'python'] + regenerate_qt_resources(examples_path, pyside_rcc_path, pyside_rcc_options) if vars['ssl_libs_dir']: # <ssl_libs>/* -> <setup>/{st_package_name}/openssl diff --git a/build_scripts/qtinfo.py b/build_scripts/qtinfo.py index 62bfee812..4ab3b8ede 100644 --- a/build_scripts/qtinfo.py +++ b/build_scripts/qtinfo.py @@ -143,10 +143,7 @@ class QtInfo(object): proc.wait() if proc.returncode != 0: return "" - if sys.version_info >= (3,): - output = str(output, 'ascii').strip() - else: - output = output.strip() + output = str(output, 'ascii').strip() return output def _parse_query_properties(self, process_output): diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 220d32efe..54b181399 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -48,11 +48,7 @@ import fnmatch import itertools import glob -# There is no urllib.request in Python2 -try: - import urllib.request as urllib -except ImportError: - import urllib +import urllib.request as urllib import distutils.log as log from distutils.errors import DistutilsSetupError @@ -376,7 +372,7 @@ def run_process_output(args, initial_env=None): stdout=subprocess.PIPE).stdout result = [] for raw_line in std_out.readlines(): - line = raw_line if sys.version_info >= (3,) else raw_line.decode('utf-8') + line = raw_line result.append(line.rstrip()) std_out.close() return result @@ -439,9 +435,8 @@ def get_environment_from_batch_command(env_cmd, initial=None): 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 - lines = map(lambda s: s.decode(), lines) + # make sure the lines are strings + 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 @@ -476,8 +471,6 @@ def back_tick(cmd, ret_err=False): Run command `cmd`, return stdout, or stdout, stderr, return_code if `ret_err` is True. - Roughly equivalent to ``check_output`` in Python 2.7 - Parameters ---------- cmd : str diff --git a/build_scripts/wheel_override.py b/build_scripts/wheel_override.py index 66141763b..0a631911b 100644 --- a/build_scripts/wheel_override.py +++ b/build_scripts/wheel_override.py @@ -87,10 +87,9 @@ class PysideBuildWheel(_bdist_wheel, DistUtilsCommandMixin): # When limited API is requested, notify bdist_wheel to # create a properly named package. - limited_api_enabled = (OPTION["LIMITED_API"] == 'yes' - and sys.version_info[0] >= 3) + limited_api_enabled = OPTION["LIMITED_API"] == 'yes' if limited_api_enabled: - self.py_limited_api = "cp35.cp36.cp37.cp38.cp39" + self.py_limited_api = "cp36.cp37.cp38.cp39" self._package_version = get_package_version() @@ -151,7 +150,7 @@ class PysideBuildWheel(_bdist_wheel, DistUtilsCommandMixin): # 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)): + and (self.py_limited_api)): plat_name = 'manylinux1_x86_64' plat_name = plat_name.replace('-', '_').replace('.', '_') @@ -175,7 +174,7 @@ class PysideBuildWheel(_bdist_wheel, DistUtilsCommandMixin): supported_tags = [(t.interpreter, t.abi, t.platform) for t in tags.sys_tags()] # XXX switch to this alternate implementation for non-pure: - if (self.py_limited_api) or (plat_name in ('manylinux1_x86_64') and sys.version_info[0] == 2): + if (self.py_limited_api) or (plat_name in ('manylinux1_x86_64')): return tag assert tag in supported_tags, ("would build wheel with unsupported tag {}".format(tag)) return tag @@ -194,7 +193,7 @@ class PysideBuildWheel(_bdist_wheel, DistUtilsCommandMixin): # Doesn't work for bdist_wininst impl_tag, abi_tag, plat_tag = self.get_tag() # To enable pypi upload we are adjusting the wheel name - pypi_ready = (OPTION["LIMITED_API"] and sys.version_info[0] >= 3) or (sys.version_info[0] == 2) + pypi_ready = True if OPTION["LIMITED_API"] else False def writeTag(impl): for abi in abi_tag.split('.'): |