Search code examples
pyinstaller

pyinstaller - how to get the name of the random-generated temp folder?


Is there a way to import the name (or the path) of the random-generated temp folder?

I know about --runtime-tmpdir which only defines the base path, but a random-named folder will still be created in that temp dir.

I see two (hacky) workarounds:

  1. scan the temp folder and look for a folder that starts with "_MEI"
  2. have a (uncompiled) script in the package that can be called from main.py and tell its location

But, whats the proper way of doing this? Thanks


Solution

  • Update:

    Found a better way: getattr(sys, '_MEIPASS', 'NotRunningInPyInstaller')

    Old:

    Found a way ! The temporary path is added automatically to sys.path by pyinstaller. So it can easily be extracted from there.