Is it possible to include source code (.py files)?
I've noticed in our app built with pyinstaller, if there are errors the tracebacks are missing the contextual source lines. Additionally if we include breakpoints with `pdb.post_mortem()` or `pdb.set_trace()` there's no way of showing the lines of code, only the line number.
As you can imagine this makes it difficult to debug problems with our app.
Is there any way of including any source .py files in the built app? I couldn't find anything in the documentation about this.
Re: Is it possible to include source code (.py files)?
Yes, but it requires #5697 which was released this morning in PyInstaller 4.3. Now if you also add your source files as data files then FrozenImporter.get_source() (and therefore Python’s tracebacks mechanisms) can find them.
For top level code or imports in the same folder as your top level code, it should just be a case of adding --add-data=path/to/file.py:. (Unix) or --add-data=path/to/file.py;. (Windows). (In both cases note the trailing dot.)
To include fully fledged packages containing an __init__.py you’ll likely have abandon the command line and to switch over to the spec file. Edit the .spec file generated by PyInstaller putting from PyInstaller.utils.hooks import collect_data_files at the top then set datas= to datas=collect_data_files('foo') (replacing foo with the real name of the library). Then rebuild using pyinstaller specfile-name.spec.