diff -r f23c43e18046 -r 906485dcd210 src/eric7/Debugger/DebuggerInterfacePython.py --- a/src/eric7/Debugger/DebuggerInterfacePython.py Sun Oct 02 11:44:07 2022 +0200 +++ b/src/eric7/Debugger/DebuggerInterfacePython.py Sat Oct 29 15:24:59 2022 +0200 @@ -14,14 +14,12 @@ from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer -from EricWidgets.EricApplication import ericApp -from EricWidgets import EricMessageBox +from eric7.EricWidgets.EricApplication import ericApp +from eric7.EricWidgets import EricMessageBox from . import DebugClientCapabilities -import Globals -import Preferences -import Utilities +from eric7 import Globals, Preferences, Utilities from eric7config import getConfig @@ -183,9 +181,15 @@ if not venvName: venvName = Preferences.getDebugger("Python3VirtualEnv") - venvManager = ericApp().getObject("VirtualEnvManager") - interpreter = venvManager.getVirtualenvInterpreter(venvName) - execPath = venvManager.getVirtualenvExecPath(venvName) + if venvName == self.debugServer.getProjectEnvironmentString(): + project = ericApp().getObject("Project") + venvName = project.getProjectVenv() + execPath = project.getProjectExecPath() + interpreter = project.getProjectInterpreter() + else: + venvManager = ericApp().getObject("VirtualEnvManager") + interpreter = venvManager.getVirtualenvInterpreter(venvName) + execPath = venvManager.getVirtualenvExecPath(venvName) if interpreter == "": # use the interpreter used to run eric for identical variants interpreter = Globals.getPythonExecutable() @@ -199,18 +203,7 @@ self.__inShutdown = False - debugClientType = Preferences.getDebugger("DebugClientType3") - if debugClientType == "standard": - debugClient = os.path.join( - getConfig("ericDir"), "DebugClients", "Python", "DebugClient.py" - ) - else: - debugClient = Preferences.getDebugger("DebugClient3") - if debugClient == "": - # use the 'standard' debug client if no custom one was configured - debugClient = os.path.join( - getConfig("ericDir"), "DebugClients", "Python", "DebugClient.py" - ) + debugClient = self.__determineDebugClient() redirect = ( str(configOverride["redirect"]) @@ -346,6 +339,28 @@ return process, self.__isNetworked, interpreter + def __determineDebugClient(self): + """ + Private method to determine the debug client to be started. + + @return path of the debug client + @rtype str + """ + debugClientType = Preferences.getDebugger("DebugClientType3") + if debugClientType == "standard": + debugClient = os.path.join( + getConfig("ericDir"), "DebugClients", "Python", "DebugClient.py" + ) + else: + debugClient = Preferences.getDebugger("DebugClient3") + if debugClient == "": + # use the 'standard' debug client if no custom one was configured + debugClient = os.path.join( + getConfig("ericDir"), "DebugClients", "Python", "DebugClient.py" + ) + + return debugClient + def startRemoteForProject( self, port, @@ -384,6 +399,8 @@ # start debugger with project specific settings debugClient = project.getDebugProperty("DEBUGCLIENT") + if not bool(debugClient) or not os.path.exists(debugClient): + debugClient = self.__determineDebugClient() redirect = ( str(configOverride["redirect"]) @@ -395,7 +412,7 @@ "--multiprocess" if Preferences.getDebugger("MultiProcessEnabled") else "" ) - if venvName: + if venvName and venvName != self.debugServer.getProjectEnvironmentString(): venvManager = ericApp().getObject("VirtualEnvManager") interpreter = venvManager.getVirtualenvInterpreter(venvName) execPath = venvManager.getVirtualenvExecPath(venvName) @@ -622,11 +639,12 @@ if not self.__connections: # no active connections anymore with contextlib.suppress(RuntimeError): - self.debugServer.signalLastClientExited() # debug server object might have been deleted already # ignore this - self.__autoContinued.clear() - self.debugServer.startClient() + self.debugServer.signalLastClientExited() + self.__autoContinued.clear() + if not self.__inShutdown: + self.debugServer.startClient() def getDebuggerIds(self): """