UAlbanyArchives / mailbagit

A tool for creating and managing Mailbags, a package for preserving email using multiple preservation formats
https://archives.albany.edu/mailbag/
MIT License
46 stars 2 forks source link

Pyinstaller executables not loading choices #160

Closed gwiedeman closed 2 years ago

gwiedeman commented 2 years ago

Describe the bug The GUI works fine natively in python, but after compiling it with pyinstaller, the format and derivative registries don't load correctly, so the input_types and derivative_types variables in __init__.py are empty lists. This makes no options available in the GUI. This also affects mailbagit.exe as well since it checks against those empty lists and raises an error when it doesn't include them, but I think that is more easily addressed.

To Reproduce Steps to reproduce the behavior:

  1. Install dev dependency (pyinstaller) with pip install -e .[dev]
  2. make a .exe with pyinstaller --onefile mailbagit-gui.py (same without --onefile)
  3. Run mailbagit-gui.exe

Expected behavior The GUI should list all possible parsers and derivatives for users. I imaging that it would be tough to have the .exe detect if wkhtmltopdf or google-chrome are installed, but I'd expect it to show all the formats and derivatives available at build time.

Screenshots

pyinstaller_error

Environment (please complete the following information): _ GUI or command line?: GUI

gwiedeman commented 2 years ago

Poked at this a bit more and it looks like with pyinstaller the formats and derivative registries don't load.

If you have $MAILBAG_LOG_LEVEL set to debug, then it logs these registries. It logs both registries correctly when building the .exe, but when you actually run the .exe, it logs them both as empty dicts.

In other words, this issue prevents both mailbagit and mailbagit-gui from running as pyinstaller executables and I don't know a work around at this point.

pobocks commented 2 years ago

Hmmmm. It's weird that the same problem happens without --onefile - I'd honestly expect it to happen with --onefile, due to it packing everything into the exe...

So, I think there's one way potentially around it - we could import the derivatives and formats included with mailbag directly (rather than using the mechanism we use for ones provided by users. It's a little cumbersome and we'd need to keep track as we added them rather than just automatically getting new ones picked up bc of the registry, but it should eliminate the issue (because they'll be imported normally)

gwiedeman commented 2 years ago

addressed by #182