From 8ae4d5827d1ccd463b99aaf54c2e8cb482094c91 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 24 May 2017 14:15:17 +0200 Subject: Improve suffix names for shared libraries and cmake config files This change decouples the naming of general shared libraries, python module extensions, and cmake configuration files. All of them are now computed depending on the python version and python build configuration, and can also be manually set via CMake variables. The module extensions names now use the most detailed 'import' prefix, which usually informs whether a debug or release python was used, or the Python ABI flags (for Python >= 3.2). When a debug Python interpreter is used for building PySide2, the preprocessor define Py_Debug is now correctly propagated to PySide2 sources, which fixes previous crashes in debug builds. This affects only Linux and macOS builds. There is a subsequent change for making it work for Windows builds. All in all, this now allows proper mixing of debug / release versions of the Python interpreter with debug / release versions of PySide2 on Linux and macOS. Task-number: PYSIDE-508 Change-Id: I88a05c3ada0fb32c7c29bdb86d7a2c15acc963b8 Reviewed-by: Friedemann Kleint --- setup.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 0b566545f..771a9c538 100644 --- a/setup.py +++ b/setup.py @@ -146,6 +146,7 @@ import os import sys import platform import time +import re import difflib # for a close match of dirname and module @@ -919,7 +920,7 @@ class pyside_build(_build): return self.prepare_packages_win32(vars) else: return self.prepare_packages_posix(vars) - except FileNotFoundError as e: + except IOError as e: print('setup.py/prepare_packages: ', e) raise @@ -942,9 +943,16 @@ class pyside_build(_build): "{dist_dir}/PySide2", vars=vars) # /lib/site-packages/shiboken2.so -> /PySide2/shiboken2.so + shiboken_module_name = 'shiboken2.so' + shiboken_src_path = "{site_packages_dir}".format(**vars) + maybe_shiboken_names = [f for f in os.listdir(shiboken_src_path) + if re.match(r'shiboken.*\.so', f)] + if maybe_shiboken_names: + shiboken_module_name = maybe_shiboken_names[0] + vars.update({'shiboken_module_name': shiboken_module_name}) copyfile( - "{site_packages_dir}/shiboken2.so", - "{dist_dir}/PySide2/shiboken2.so", + "{site_packages_dir}/{shiboken_module_name}", + "{dist_dir}/PySide2/{shiboken_module_name}", vars=vars) # /lib/site-packages/pyside2uic/* -> /pyside2uic copydir( -- cgit v1.2.3 From 5337435edaa10518c4495d480f934e87b2ccd444 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 24 May 2017 18:50:44 +0200 Subject: Fix Windows module extensions and tests to work with --debug build Use the same imp.get_suffixes() mechanism as on Unix, to determine the suffix part of module extension files. This fixes debug builds to work on Windows. Note that the whole build stack has to use the same configuration, no mixing is allowed on Windows. For release build you need: python.exe + setup.py without --debug flag + release build of Qt5. For debug build you need: python_d.exe + setup.py with --debug flag + debug build of Qt5. Change-Id: I6188c859b5757d11e87d6a9e32b9ba558f7f609e Reviewed-by: Friedemann Kleint --- setup.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 771a9c538..af33254ca 100644 --- a/setup.py +++ b/setup.py @@ -1067,15 +1067,23 @@ class pyside_build(_build): "{dist_dir}/PySide2/docs/shiboken2", force=False, vars=vars) # /lib/site-packages/shiboken2.pyd -> /PySide2/shiboken2.pyd + shiboken_module_name = 'shiboken2.pyd' + shiboken_src_path = "{site_packages_dir}".format(**vars) + maybe_shiboken_names = [f for f in os.listdir(shiboken_src_path) + if re.match(r'shiboken.*\.pyd', f)] + if maybe_shiboken_names: + shiboken_module_name = maybe_shiboken_names[0] + vars.update({'shiboken_module_name': shiboken_module_name}) copyfile( - "{site_packages_dir}/shiboken2{dbgPostfix}.pyd", - "{dist_dir}/PySide2/shiboken2{dbgPostfix}.pyd", + "{site_packages_dir}/{shiboken_module_name}", + "{dist_dir}/PySide2/{shiboken_module_name}", vars=vars) if self.debug or self.build_type == 'RelWithDebInfo': - copyfile( - "{build_dir}/shiboken2/shibokenmodule/shiboken2{dbgPostfix}.pdb", - "{dist_dir}/PySide2/shiboken2{dbgPostfix}.pdb", - vars=vars) + copydir( + "{build_dir}/shiboken2/shibokenmodule", + "{dist_dir}/PySide2", + filter=pdbs, + recursive=False, vars=vars) # /lib/site-packages/pyside2uic/* -> /pyside2uic copydir( "{site_packages_dir}/pyside2uic", @@ -1189,14 +1197,21 @@ class pyside_build(_build): # pdb files for libshiboken and libpyside if self.debug or self.build_type == 'RelWithDebInfo': # XXX dbgPostfix gives problems - the structure in shiboken2/data should be re-written! - copyfile( - "{build_dir}/shiboken2/libshiboken/shiboken2.pdb", - "{dist_dir}/PySide2/shiboken2.pdb", # omitted dbgPostfix - vars=vars) - copyfile( - "{build_dir}/pyside2/libpyside/pyside2.pdb", - "{dist_dir}/PySide2/pyside2.pdb", # omitted dbgPostfix - vars=vars) + # Not sure what the above refers to, but because both the extension module + # (shiboken2.pyd) and the shared library (shiboken2.dll) have the same basename, + # the pdb file gets overwritten. This doesn't happen on Unix because the shared library + # has a 'lib' prefix in the basename. + # @TODO Change the shared library name on Windows. + copydir( + "{build_dir}/shiboken2/libshiboken", + "{dist_dir}/PySide2", + filter=pdbs, + recursive=False, vars=vars) + copydir( + "{build_dir}/pyside2/libpyside", + "{dist_dir}/PySide2", + filter=pdbs, + recursive=False, vars=vars) def update_rpath(self, package_path, executables): if sys.platform.startswith('linux'): -- cgit v1.2.3