From ae526fb6b3f5b13f1c69649a3bee711ded5a435d Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Fri, 9 Aug 2024 05:22:26 -0600 Subject: [PATCH] feat: support executables passed to ipdb3 For instance, if your project has a script section a bin/ entry in your venv will be generated. It's helpful to be able to pass the command reference to ipdb for debugging. --- ipdb/__main__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ipdb/__main__.py b/ipdb/__main__.py index c4b649a..66dcede 100644 --- a/ipdb/__main__.py +++ b/ipdb/__main__.py @@ -12,6 +12,7 @@ __version__ = "0.13.14.dev0" +from shutil import which from IPython import get_ipython from IPython.core.debugger import BdbQuit_excepthook from IPython.terminal.ipapp import TerminalIPythonApp @@ -300,6 +301,11 @@ class Restart(Exception): sys.exit(2) mainpyfile = args[0] # Get script filename + + # a executable command in $PATH may be passed + if not os.path.exists(mainpyfile): + mainpyfile = which(mainpyfile) + if not run_as_module and not os.path.exists(mainpyfile): print("Error:", mainpyfile, "does not exist") sys.exit(1)