From 98734790ded3e99189d5556cd89d11e0cf1a2180 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sun, 30 Nov 2025 20:36:44 -0600 Subject: [PATCH] Utils: Don't save location of Python executable --- src/Ext/freecad/utils.py | 7 +++---- src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp | 4 ++-- src/Gui/PreferencePages/DlgSettingsPythonConsole.ui | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Ext/freecad/utils.py b/src/Ext/freecad/utils.py index 7aae7f3b59..b490a908bc 100644 --- a/src/Ext/freecad/utils.py +++ b/src/Ext/freecad/utils.py @@ -32,15 +32,15 @@ import FreeCAD def get_python_exe() -> str: """Find Python. In preference order - A) The value of the BaseApp/Preferences/PythonConsole/ExternalPythonExecutable user preference + A) The value of the BaseApp/Preferences/PythonConsole/PathToPythonExecutable user preference B) The executable located in the same bin directory as FreeCAD and called "python3" C) The executable located in the same bin directory as FreeCAD and called "python" D) The result of a shutil search for your system's "python3" executable E) The result of a shutil search for your system's "python" executable""" prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/PythonConsole") - python_exe = prefs.GetString("ExternalPythonExecutable", "Not set") + python_exe = prefs.GetString("PathToPythonExecutable", "") fc_dir = FreeCAD.getHomePath() - if not python_exe or python_exe == "Not set" or not os.path.exists(python_exe): + if not python_exe or not os.path.exists(python_exe): python_exe = os.path.join(fc_dir, "bin", "python3") if "Windows" in platform.system(): python_exe += ".exe" @@ -60,5 +60,4 @@ def get_python_exe() -> str: return "" python_exe = python_exe.replace("/", os.path.sep) - prefs.SetString("ExternalPythonExecutable", python_exe) return python_exe diff --git a/src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp b/src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp index 65bd9ef497..fc06a3f8c0 100644 --- a/src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp +++ b/src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp @@ -44,7 +44,7 @@ void DlgSettingsPythonConsole::saveSettings() ui->PythonBlockCursor->onSave(); ui->PythonSaveHistory->onSave(); ui->ProfilerInterval->onSave(); - ui->ExternalPythonExecutable->onSave(); + ui->PathToPythonExecutable->onSave(); } void DlgSettingsPythonConsole::loadSettings() @@ -53,7 +53,7 @@ void DlgSettingsPythonConsole::loadSettings() ui->PythonBlockCursor->onRestore(); ui->PythonSaveHistory->onRestore(); ui->ProfilerInterval->onRestore(); - ui->ExternalPythonExecutable->onRestore(); + ui->PathToPythonExecutable->onRestore(); } void DlgSettingsPythonConsole::changeEvent(QEvent* event) diff --git a/src/Gui/PreferencePages/DlgSettingsPythonConsole.ui b/src/Gui/PreferencePages/DlgSettingsPythonConsole.ui index 77c1745a70..c2506f5264 100644 --- a/src/Gui/PreferencePages/DlgSettingsPythonConsole.ui +++ b/src/Gui/PreferencePages/DlgSettingsPythonConsole.ui @@ -127,7 +127,7 @@ horizontal space in Python console - + 0 @@ -144,7 +144,7 @@ horizontal space in Python console Used for package installation with pip and debugging with debugpy. Autodetected if needed and not specified. - ExternalPythonExecutable + PathToPythonExecutable PythonConsole