breakpoint() using ipdb by default
Asked Answered
N

1

29

Is it possible that installing ipdb (or some other package written to do it explicitely) will result in breakpoint() running ipdb instead of pdb without binding sys.breakpointhook() to ipdb?

https://www.python.org/dev/peps/pep-0553/

I'm not asking if ipdb does that or if it will, but if its possible to code that. I know that I can set environment variable PYTHONBREAKPOINT=ipdb.set_trace. The question is if its possible to trigger this behavior by just installing ipdb.

Numerical answered 22/1, 2018 at 11:22 Comment(0)
S
5

During the installation one could programmatically create either a usercustomize.py or a sitecustomize.py in the correct directories and alter os.environ['PYTHONBREAKPOINT'] in there.

These modules are imported by site.py early in the startup sequence and are suited for this sort of customization. Personally, I've never seen a package alter/create these files so I wouldn't expect ipdb to ever do it.

Steere answered 22/1, 2018 at 15:0 Comment(2)
usercustomize.py sounds like a perfect place for this. Unfortunately, on my machines when using virtualenv site.ENABLE_USER_SITE is always False as if python was started with -S option or PYTHONNOUSERSITE environment variable was set.Numerical
While site customize is the correct place, it's not really the installer's business to be dumping stuff there. User or sysadmin should do this manually.Uticas

© 2022 - 2024 — McMap. All rights reserved.