aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-05-06 22:35:13 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-07 16:30:16 +0000
commit86df657978d83c1254185dd16952d47a58abbe7c (patch)
tree572f0415b4cd1037ba5d39d945a67662f21ac280
parent4205f6b65e10ad0707fc8f667f7b0f1349a28c93 (diff)
Fix Designer plugin to load on Linux
Preload a python library to provide the Python symbols. Task-number: PYSIDE-1455 Change-Id: I8d84bd6f3129c500471653b54e415882d5c0bde1 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit c5a0f829fcce841ed53e13218a6274ea1da9c678) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/pyside-tools/pyside_tool.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/sources/pyside-tools/pyside_tool.py b/sources/pyside-tools/pyside_tool.py
index d4f283bfc..da29025c8 100644
--- a/sources/pyside-tools/pyside_tool.py
+++ b/sources/pyside-tools/pyside_tool.py
@@ -94,6 +94,19 @@ def designer():
# PySide6/scripts.
pyside_dir = Path(__file__).resolve().parents[1]
+ # https://www.python.org/dev/peps/pep-0384/#linkage :
+ # "On Unix systems, the ABI is typically provided by the python executable
+ # itself", that is, libshiboken does not link against any Python library
+ # and expects to get these symbols from a python executable. Since no
+ # python executable is involved when loading this plugin, pre-load python.so
+ # This should also help to work around a numpy issue, see
+ # https://stackoverflow.com/questions/49784583/numpy-import-fails-on-multiarray-extension-library-when-called-from-embedded-pyt
+ if sys.platform == 'linux':
+ # Determine library name (examples/utils/pyside_config.py)
+ version = f'{sys.version_info[0]}.{sys.version_info[1]}'
+ library_name = f'libpython{version}{sys.abiflags}.so'
+ os.environ['LD_PRELOAD'] = library_name
+
# Add the Wiggly Widget example
wiggly_dir = os.fspath(pyside_dir / 'examples' / 'widgetbinding')
_append_to_path_var('PYSIDE_DESIGNER_PLUGINS', wiggly_dir)