diff options
author | Simo Fält <simo.falt@qt.io> | 2017-11-28 14:07:48 +0200 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2018-01-11 16:36:06 +0000 |
commit | 73594da7ba14a5847e14ab871adb5b9ffe3d10dd (patch) | |
tree | 782edbbfbb9e4ab2ef1a2f936261965b72820ce2 | |
parent | 750b8886ad441f2aa189a9a009e978b02a166aa1 (diff) |
Extract iculibs for linux standalone wheel
When creating PIP wheel for linux from Qt CI binaries we have to
include ICU libs among Qt binaries.
Change-Id: I30adf7041784cf3558c064d6ab6ad295ed1f5551
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | setup.py | 46 | ||||
-rw-r--r-- | utils.py | 21 |
2 files changed, 67 insertions, 0 deletions
@@ -195,6 +195,8 @@ from utils import init_msvc_env from utils import regenerate_qt_resources from utils import filter_match from utils import osx_fix_rpaths_for_library +from utils import download_and_extract_7z +from textwrap import dedent # guess a close folder name for extensions def get_extension_folder(ext): @@ -253,6 +255,7 @@ OPTION_SKIP_MAKE_INSTALL = has_option("skip-make-install") OPTION_SKIP_PACKAGING = has_option("skip-packaging") OPTION_RPATH_VALUES = option_value("rpath") OPTION_QT_CONF_PREFIX = option_value("qt-conf-prefix") +OPTION_ICULIB = option_value("iculib-url") if OPTION_QT_VERSION is None: OPTION_QT_VERSION = "5" @@ -314,6 +317,14 @@ if OPTION_JOBS: else: OPTION_JOBS = '' +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) + # Show available versions if OPTION_LISTVERSIONS: for v in submodules: @@ -1106,6 +1117,41 @@ class pyside_build(_build): def prepare_standalone_package_linux(self, executables, vars): built_modules = vars['built_modules'] + def _print_warn(): + print(dedent("""\ + *********************************************************** + If one is using Qt binaries provided by QtCompany's CI, + those aren't working as expected! + *********************************************************** + """)) + + # To get working QtCompany Qt CI binaries we have to extract the ICU libs + # If no link provided we'll use the libs from qt-project + icuUrl = "" + if OPTION_ICULIB: + icuUrl = OPTION_ICULIB + else: + qt_version = self.qtinfo.version + url_pre = "http://master.qt.io/development_releases/prebuilt/icu/prebuilt/" + if qt_version.startswith("5.6"): + icuUrl = url_pre + "56.1/icu-linux-g++-Rhel6.6-x64.7z" + else: + icuUrl = url_pre + "56.1/icu-linux-g++-Rhel7.2-x64.7z" + + if find_executable("7z"): + try: + download_and_extract_7z(icuUrl, "{qt_lib_dir}".format(**vars)) + except RuntimeError as e: + # The Qt libs now requires patching to system ICU + # OR it is possible that Qt was built without ICU and + # Works as such + print("Failed to download and extract %s" % icuUrl) + print(str(e)) + _print_warn() + else: + print("Install 7z into PATH to extract ICU libs") + _print_warn() + # <qt>/lib/* -> <setup>/PySide2/Qt/lib copydir("{qt_lib_dir}", "{dist_dir}/PySide2/Qt/lib", filter=[ @@ -9,6 +9,11 @@ import subprocess import fnmatch import itertools import popenasync +# There is no urllib.request in Python2 +try: + import urllib.request as urllib +except ImportError: + import urllib from distutils import log from distutils.errors import DistutilsOptionError @@ -657,4 +662,20 @@ def osx_add_qt_rpath(library_path, qt_lib_dir, back_tick('install_name_tool -add_rpath {rpath} {library_path}'.format( rpath=qt_lib_dir, library_path=library_path)) +def download_and_extract_7z(fileurl, target): + """ Downloads 7z file from fileurl and extract to target """ + + print("Downloading fileUrl %s " % fileurl) + info = "" + try: + localfile, info = urllib.urlretrieve(fileurl) + except: + print("Error downloading %r : %r" % (fileurl, info)) + raise RuntimeError(' Error downloading ' + fileurl) + try: + outputDir = "-o" + target + print("calling 7z x %s %s" % (localfile, outputDir)) + subprocess.call(["7z", "x", "-y", localfile, outputDir]) + except: + raise RuntimeError(' Error extracting ' + localfile) |