Debugger: fix debugger in modified python environment

We do not want to pick up any python environment variables for the
cdbext python initialization which might change the module search path,
because we already contain the needed python modules in the zip file
next to the extension.

Fixes: QTCREATORBUG-24859
Change-Id: I0d597f42042d249529309263d71b0e740e903a48
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-10-29 11:15:04 +01:00
parent 495dee98fc
commit fc39cf18e1
5 changed files with 16 additions and 8 deletions

View File

@@ -45,9 +45,9 @@ add_qtc_library(qtcreatorcdbext
qtc_library_enabled(_library_enabled qtcreatorcdbext)
if (_library_enabled)
find_package(PythonLibs 3.5)
find_package(PythonLibs 3.8)
if (NOT ${PYTHONLIBS_FOUND})
message(WARNING "PythonLibs (at least version 3.5) not found. qtcreatorcdbext will be built without Python support.")
message(WARNING "PythonLibs (at least version 3.8) not found. qtcreatorcdbext will be built without Python support.")
return()
endif()

View File

@@ -162,7 +162,14 @@ HRESULT ExtensionContext::initialize(PULONG Version, PULONG Flags)
#ifdef WITH_PYTHON
initCdbextPythonModule();
Py_Initialize();
PyStatus status;
PyConfig config;
PyConfig_InitIsolatedConfig(&config);
status = Py_InitializeFromConfig(&config);
PyConfig_Clear(&config);
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
}
PyRun_SimpleString("import cdbext");
PyRun_SimpleString("import sys");
#endif

View File

@@ -114,7 +114,7 @@ isEmpty(PYTHON_INSTALL_DIR):PYTHON_INSTALL_DIR=$$(PYTHON_INSTALL_DIR)
CONFIG(debug, debug|release): deploy_python.recurse = Debug
QMAKE_EXTRA_TARGETS += deploy_python
} else {
message("Set PYTHON_INSTALL_DIR pointing to Python 3.5 or greater to enable the python dumpers for cdb.")
message("Set PYTHON_INSTALL_DIR pointing to Python 3.8 or greater to enable the python dumpers for cdb.")
}
target.path = $$QTC_PREFIX/lib/$${DIRNAME} # TODO this should go to INSTALL_LIBRARY_PATH/$${DIRNAME}

View File

@@ -50,10 +50,11 @@ QtcLibrary {
+ output + "'");
return;
}
if (Utilities.versionCompare(versionNumberString, "3.5") < 0) {
var pythonMinVersion = "3.8";
if (Utilities.versionCompare(versionNumberString, pythonMinVersion) < 0) {
printWarning("The python installation at '" + pythonDir
+ "' has version " + versionNumberString + ", but 3.5 or higher "
+ "is required.");
+ "' has version " + versionNumberString + ", but "
+ pythonMinVersion + " or higher is required.");
return;
}
found = true;

View File

@@ -654,7 +654,7 @@ extern "C" HRESULT CALLBACK script(CIDebugClient *client, PCSTR argsIn)
ExtensionContext::instance().report('N', token, 0, "script",
"Python is not supported in this CDB extension.\n"
"You need to define PYTHON_INSTALL_DIR in your creator build environment "
"pointing to a Python 3.5 installation.");
"pointing to a Python 3.8 installation.");
#endif
return S_OK;
}