python-web-pdb icon indicating copy to clipboard operation
python-web-pdb copied to clipboard

use pyinstaller pack web_pdb can't show PDB Console normally

Open kangss88 opened this issue 1 year ago • 2 comments

it can show line change, but can't show other log, such as print information

kangss88 avatar Jul 30 '24 07:07 kangss88

The project was not tested with pyinstalled so it is not guaranteed to work.

romanvm avatar Aug 28 '24 15:08 romanvm

@romanvm fyi I've managed to combine pyinstaller and web_pdb with the following recipe:

  1. Add an option flag to the packaged script to trigger debugging: e.g. --debug to run web_pdb.set_trace(host="127.0.0.1")
  2. Put most of the code in a package separated from the packaged script, since that script won't be debuggable
  3. Create a hook file for your package (and all the dependencies that you want to debug): https://pyinstaller.org/en/stable/hooks.html
  4. 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" or module_collection_mode = { <my_package>: "py" } option in the hook file
  5. I also do a collect_all call (from `PyInstaller.utils.hooks ) for each package of interest in the hook file (but that might be an overkill)
  6. Make sure the hook file is actually used by pyinstaller (use a dummy import of your package in your script if necessary)
  7. Set breakpoints with b <package>/<module>/<file>.py:<line number>

jxrossel avatar Dec 30 '24 10:12 jxrossel