From 86df657978d83c1254185dd16952d47a58abbe7c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 6 May 2021 22:35:13 +0200 Subject: 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 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit c5a0f829fcce841ed53e13218a6274ea1da9c678) Reviewed-by: Qt Cherry-pick Bot --- sources/pyside-tools/pyside_tool.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) -- cgit v1.2.3