python-web-pdb
python-web-pdb copied to clipboard
use pyinstaller pack web_pdb can't show PDB Console normally
it can show line change, but can't show other log, such as print information
The project was not tested with pyinstalled so it is not guaranteed to work.
@romanvm fyi I've managed to combine pyinstaller and web_pdb with the following recipe:
- Add an option flag to the packaged script to trigger debugging: e.g.
--debugto runweb_pdb.set_trace(host="127.0.0.1") - Put most of the code in a package separated from the packaged script, since that script won't be debuggable
- Create a hook file for your package (and all the dependencies that you want to debug): https://pyinstaller.org/en/stable/hooks.html
- The key setting is to make sure that your package is included as a py file only (i.e. not as a pyc file or alongside a pyc file), using the
module_collection_mode = "py"ormodule_collection_mode = { <my_package>: "py" }option in the hook file - I also do a
collect_allcall (from `PyInstaller.utils.hooks ) for each package of interest in the hook file (but that might be an overkill) - Make sure the hook file is actually used by pyinstaller (use a dummy import of your package in your script if necessary)
- Set breakpoints with
b <package>/<module>/<file>.py:<line number>