aboutsummaryrefslogtreecommitdiffstats
path: root/examples/scriptableapplication/pyside2_config.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-05-07 17:45:51 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-05-08 08:28:00 +0000
commit65afd324370d2a9788d52ef5213dc88f5e3912a0 (patch)
tree47c252cbd1ea07b82f693d9e9b6db8d5036e88f9 /examples/scriptableapplication/pyside2_config.py
parent928a5249dad9543a669ab07a0108aca26c0642cb (diff)
Fix a few scriptableapplication bugs
1) Remove LIBPATH because that causes linker warnings on macOS, and its usage is deprecated on Windows. 2) Remove all qmake clang related code, as well as clang code from pyside2_config.py. It used to be needed on Windows because we didn't deploy libclang.dll to the PySide2 dir. Now that we do, the code is unnecessary. 3) Remove README.txt reference. 4) Add clarifying comments in README.md. 5) Remove NO_DEFAULT_PATH from find_library because that causes a failure to find the python library on Ubuntu (makes sense because the specified libdir is /usr/lib, but the actual library is under /usr/lib/[arch], and disabling the option forces CMake not to look under the arch dir. 6) Fix rpath to PySide2 dir not being embedded on Linux (presumably because the link flags style changed to absolute paths, not sure). 7) Fix README to be more precise about how MSBuild needs to be invoked, and how to run the executable. 8) Improve the error handling in the project files. 9) Refactor pyside2_config.py usage. Change-Id: I402d5c42ef7e01e94d3827682564e95ee280b40b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/scriptableapplication/pyside2_config.py')
-rw-r--r--examples/scriptableapplication/pyside2_config.py68
1 files changed, 23 insertions, 45 deletions
diff --git a/examples/scriptableapplication/pyside2_config.py b/examples/scriptableapplication/pyside2_config.py
index 781c30b64..ce9c707c1 100644
--- a/examples/scriptableapplication/pyside2_config.py
+++ b/examples/scriptableapplication/pyside2_config.py
@@ -1,6 +1,6 @@
#############################################################################
##
-## Copyright (C) 2017 The Qt Company Ltd.
+## Copyright (C) 2018 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing/
##
## This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -40,8 +40,6 @@
import os, glob, re, sys, imp
from distutils import sysconfig
-if sys.platform == 'win32':
- import winreg
usage = """
Utility to determine include/link options of PySide2 and Python for qmake
@@ -54,7 +52,6 @@ Options:
--pyside2-include Print PySide2 include paths
--pyside2-link Print PySide2 link flags
--pyside2-shared-libraries Print paths of PySide2 shared libraries (.so's, .dylib's, .dll's)
- --clang-bin-dir Print path to the clang bin directory
-a Print all
--help/-h Print this help
"""
@@ -92,11 +89,11 @@ def linkOption(lib):
# libraries when compiling the project
baseName = os.path.basename(lib)
link = ' -l'
- if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '-lfoo'
+ if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '/absolute/path/libfoo.so'
link = lib
- elif sys.platform in ['darwin']: # Linux: 'libfoo.so' -> '-lfoo'
+ elif sys.platform in ['darwin']: # Darwin: 'libfoo.so' -> '-lfoo'
link += os.path.splitext(baseName[3:])[0]
- else:
+ else: # Windows: 'libfoo.dll' -> 'libfoo.dll'
link += os.path.splitext(baseName)[0]
return link
@@ -138,10 +135,7 @@ def pythonLinkCmake():
flags = pythonLinkData()
libdir = flags['libdir']
lib = re.sub(r'.dll$', '.lib', flags['lib'])
- if sys.platform == 'win32':
- return '{};{}'.format(libdir, lib)
- else:
- return '{} {}'.format(libdir, lib)
+ return '{};{}'.format(libdir, lib)
def pythonLinkData():
# @TODO Fix to work with static builds of Python
@@ -221,87 +215,71 @@ def pyside2SharedLibraries():
else:
libs_string = ''
for lib in libs:
- libs_string += ' ' + lib
+ libs_string += lib + ' '
return libs_string
def pyside2SharedLibrariesCmake():
libs = pyside2SharedLibrariesData()
- result = ' '.join(libs)
+ result = ';'.join(libs)
return result
-def clangBinPath():
- source = 'LLVM_INSTALL_DIR'
- clangDir = os.environ.get(source, None)
- if not clangDir:
- source = 'CLANG_INSTALL_DIR'
- clangDir = os.environ.get(source, None)
- if not clangDir:
- source = 'llvm-config'
- try:
- output = run_process_output([source, '--prefix'])
- if output:
- clangDir = output[0]
- except OSError:
- pass
- if clangDir:
- return os.path.realpath(clangDir + os.path.sep + 'bin')
- return ''
-
option = sys.argv[1] if len(sys.argv) == 2 else '-a'
if option == '-h' or option == '--help':
print(usage)
sys.exit(0)
+generic_error = (' Did you forget to activate your virtualenv? Or perhaps'
+ ' you forgot to build / install PySide2 into your currently active Python'
+ ' environment?')
+pyside2_error = 'Unable to locate PySide2.' + generic_error
+pyside2_libs_error = 'Unable to locate the PySide2 shared libraries.' + generic_error
+python_link_error = 'Unable to locate the Python library for linking.'
+
if option == '--pyside2' or option == '-a':
pySide2 = findPySide2()
if pySide2 is None:
- sys.exit('Unable to locate PySide2')
+ sys.exit(pyside2_error)
print(pySide2)
if option == '--pyside2-link' or option == '-a':
l = pyside2Link()
if l is None:
- sys.exit('Unable to locate PySide2')
+ sys.exit(pyside2_error)
+
print(l)
if option == '--pyside2-include' or option == '-a':
i = pyside2Include()
if i is None:
- sys.exit('Unable to locate PySide2')
+ sys.exit(pyside2_error)
print(i)
if option == '--python-include' or option == '-a':
i = pythonInclude()
if i is None:
- sys.exit('Unable to locate Python')
+ sys.exit('Unable to locate the Python include headers directory.')
print(i)
if option == '--python-link' or option == '-a':
l = pythonLinkQmake()
if l is None:
- sys.exit('Unable to locate Python')
+ sys.exit(python_link_error)
print(l)
if option == '--python-link-cmake' or option == '-a':
l = pythonLinkCmake()
if l is None:
- sys.exit('Unable to locate Python')
+ sys.exit(python_link_error)
print(l)
if option == '--pyside2-shared-libraries' or option == '-a':
l = pyside2SharedLibraries()
if l is None:
- sys.exit('Unable to locate the PySide2 shared libraries')
+ sys.exit(pyside2_libs_error)
print(l)
if option == '--pyside2-shared-libraries-cmake' or option == '-a':
l = pyside2SharedLibrariesCmake()
if l is None:
- sys.exit('Unable to locate the PySide2 shared libraries')
- print(l)
-
-if option == '--clang-bin-dir' or option == '-a':
- l = clangBinPath()
- if l is None:
- sys.exit('Unable to locate Clang')
+ sys.exit(pyside2_libs_error)
print(l)