aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-05-10 21:23:06 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-11 07:48:57 +0000
commit95ab0000b2e8582ab7dec3826f5ef2ef110ba191 (patch)
tree9c12acf5e29b67a3fb5f928f6bffadf5bc80007a
parentdc34a24ffaf8cb76699cefc53d0ba8a1cfcbf08e (diff)
PySide6: Use the Python version the plugin is running under
Task-number: PYSIDE-1455 Change-Id: Iba9429d2c42f471661b250829aaf124a4b8b72b2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 1da27a40a71e61f4ac4bc83819ade1461efb17fc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/pyside-tools/pyside_tool.py6
-rw-r--r--sources/pyside6/plugins/designer/designercustomwidgets.cpp10
2 files changed, 14 insertions, 2 deletions
diff --git a/sources/pyside-tools/pyside_tool.py b/sources/pyside-tools/pyside_tool.py
index da29025c8..52716e308 100644
--- a/sources/pyside-tools/pyside_tool.py
+++ b/sources/pyside-tools/pyside_tool.py
@@ -101,9 +101,13 @@ def designer():
# 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
+ major_version = sys.version_info[0]
+ minor_version = sys.version_info[1]
+ os.environ['PY_MAJOR_VERSION'] = str(major_version)
+ os.environ['PY_MINOR_VERSION'] = str(minor_version)
if sys.platform == 'linux':
# Determine library name (examples/utils/pyside_config.py)
- version = f'{sys.version_info[0]}.{sys.version_info[1]}'
+ version = f'{major_version}.{minor_version}'
library_name = f'libpython{version}{sys.abiflags}.so'
os.environ['LD_PRELOAD'] = library_name
diff --git a/sources/pyside6/plugins/designer/designercustomwidgets.cpp b/sources/pyside6/plugins/designer/designercustomwidgets.cpp
index 92455cc24..65074c546 100644
--- a/sources/pyside6/plugins/designer/designercustomwidgets.cpp
+++ b/sources/pyside6/plugins/designer/designercustomwidgets.cpp
@@ -163,9 +163,17 @@ static void initVirtualEnvironment()
// As of Python 3.8/Windows, Python is no longer able to run stand-alone in
// a virtualenv due to missing libraries. Add the path to the modules
// instead.
+ bool ok;
+ int majorVersion = qEnvironmentVariableIntValue("PY_MAJOR_VERSION", &ok);
+ int minorVersion = qEnvironmentVariableIntValue("PY_MINOR_VERSION", &ok);
+ if (!ok) {
+ majorVersion = PY_MAJOR_VERSION;
+ minorVersion = PY_MINOR_VERSION;
+ }
+
if (!qEnvironmentVariableIsSet(virtualEnvVar)
|| QOperatingSystemVersion::currentType() != QOperatingSystemVersion::Windows
- || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 8)) {
+ || (majorVersion == 3 && minorVersion < 8)) {
return;
}