Merge pull request #11421 from Pesc0/vscode-split-4--upgrade-python-debugger

Vscode split 4  upgrade python debugger
This commit is contained in:
Chris Hennes
2023-11-20 11:18:36 -06:00
committed by GitHub
13 changed files with 134 additions and 87 deletions

View File

@@ -45,6 +45,7 @@ void DlgSettingsPythonConsole::saveSettings()
ui->PythonBlockCursor->onSave();
ui->PythonSaveHistory->onSave();
ui->ProfilerInterval->onSave();
ui->ExternalPythonExecutable->onSave();
}
void DlgSettingsPythonConsole::loadSettings()
@@ -53,6 +54,7 @@ void DlgSettingsPythonConsole::loadSettings()
ui->PythonBlockCursor->onRestore();
ui->PythonSaveHistory->onRestore();
ui->ProfilerInterval->onRestore();
ui->ExternalPythonExecutable->onRestore();
}
void DlgSettingsPythonConsole::changeEvent(QEvent* event)

View File

@@ -11,13 +11,13 @@
</rect>
</property>
<property name="windowTitle">
<string>Python console</string>
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox11">
<property name="title">
<string>Settings</string>
<string>Console</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
@@ -111,6 +111,47 @@ horizontal space in Python console</string>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="GroupBox11">
<property name="title">
<string>Other</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="fclabel">
<property name="text">
<string>Path to external Python executable (optional):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefFileChooser" name="ExternalPythonExecutable" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Used for package installation with pip and debugging with debugpy. Autodetected if needed and not specified.</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ExternalPythonExecutable</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>PythonConsole</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -135,6 +176,11 @@ horizontal space in Python console</string>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefFileChooser</class>
<extends>QWidget</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>

View File

@@ -25,6 +25,7 @@
import FreeCAD as App
import FreeCADGui as Gui
from PySide import QtGui
from freecad.utils import get_python_exe
class RemoteDebugger():
def __init__(self, parent=None):
@@ -46,11 +47,17 @@ class RemoteDebugger():
elif index == 1: # VS code
address = self.dialog.lineEditAddress.text()
port = self.dialog.spinBoxPort.value()
redirect = self.dialog.checkRedirectOutput.isChecked()
import ptvsd
ptvsd.enable_attach(address=(address, port), redirect_output=redirect)
ptvsd.wait_for_attach()
import debugpy
# get_python_exe is needed because debugpy needs a python interpreter to work.
# It does not have to be FC embedded interpreter.
# By default it attempts to use Freecad's PID mistaking it for python.
# https://github.com/microsoft/debugpy/issues/262
debugpy.configure(python=get_python_exe())
debugpy.listen((address, port))
debugpy.wait_for_client()
except Exception as e:
QtGui.QMessageBox.warning(self.dialog, "Failed to attach", str(e))

View File

@@ -89,16 +89,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkRedirectOutput">
<property name="text">
<string>Redirect output</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">