diff options
author | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2018-04-17 17:51:11 +0200 |
---|---|---|
committer | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2018-05-04 15:25:32 +0000 |
commit | e124f12e95cbf44bc5fc391846ddeedf2c042680 (patch) | |
tree | 39eed87665c53c4694b81a3103313a160ce0c10a /examples/scriptableapplication/pyside2_config.py | |
parent | 8ed37563888f7956da99636c62f18459729d5966 (diff) |
Update scriptableapplication example
Absolute paths are used to link the PySide2 libraries on Linux,
since it's not possible to ship symbolic links inside a wheel.
The README.txt was renamed to README.md to allow
syntax highlight on modern editors and also to be
compatible with online platforms.
The README.CMake.txt was merge to the README.md to include the
instruction on the same file.
Change-Id: Ie0fcb8cda770ff552576f6014b5822f8d278bfe6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'examples/scriptableapplication/pyside2_config.py')
-rw-r--r-- | examples/scriptableapplication/pyside2_config.py | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/examples/scriptableapplication/pyside2_config.py b/examples/scriptableapplication/pyside2_config.py index a26d2b490..781c30b64 100644 --- a/examples/scriptableapplication/pyside2_config.py +++ b/examples/scriptableapplication/pyside2_config.py @@ -67,7 +67,9 @@ def sharedLibrarySuffix(): return 'lib' elif sys.platform == 'darwin': return 'dylib' - return 'so' + # Linux + else: + return 'so.*' def sharedLibraryGlobPattern(): glob = '*.' + sharedLibrarySuffix() @@ -84,12 +86,18 @@ def filterPySide2SharedLibraries(list): # Return qmake link option for a library file name def linkOption(lib): - baseName = os.path.splitext(os.path.basename(lib))[0] + # On Linux: + # Since we cannot include symlinks with wheel packages + # we are using an absolute path for the libpyside and libshiboken + # libraries when compiling the project + baseName = os.path.basename(lib) link = ' -l' - if sys.platform in ['linux', 'linux2', 'darwin']: # Linux: 'libfoo.so' -> '-lfoo' - link += baseName[3:] + if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '-lfoo' + link = lib + elif sys.platform in ['darwin']: # Linux: 'libfoo.so' -> '-lfoo' + link += os.path.splitext(baseName[3:])[0] else: - link += baseName + link += os.path.splitext(baseName)[0] return link # Locate PySide2 via package path @@ -110,17 +118,30 @@ def pythonInclude(): def pythonLinkQmake(): flags = pythonLinkData() - if sys.platform == 'win32' or sys.platform == 'darwin': + if sys.platform == 'win32': + libdir = flags['libdir'] + # This will add the "~1" shortcut for directories that + # contain white spaces + # e.g.: "Program Files" to "Progra~1" + for d in libdir.split("\\"): + if " " in d: + libdir = libdir.replace(d, d.split(" ")[0][:-1]+"~1") + return '-L{} -l{}'.format(libdir, flags['lib']) + elif sys.platform == 'darwin': return '-L{} -l{}'.format(flags['libdir'], flags['lib']) - # Linux and anything else - return '-l{}'.format(flags['lib']) + else: + # Linux and anything else + return '-L{} -l{}'.format(flags['libdir'], flags['lib']) def pythonLinkCmake(): flags = pythonLinkData() libdir = flags['libdir'] lib = re.sub(r'.dll$', '.lib', flags['lib']) - return '{} {}'.format(libdir, lib) + if sys.platform == 'win32': + return '{};{}'.format(libdir, lib) + else: + return '{} {}'.format(libdir, lib) def pythonLinkData(): # @TODO Fix to work with static builds of Python |