Check if one-file or one-dir #5946
-
Hello, There is a way to check if the application is running on Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I guess you could compare # test.py
import sys
print(sys.executable)
print(sys._MEIPASS) > pyinstaller test.py
> ./dist/test/test
/e/notebooks/pyi-issues/5946/dist/test/test
/e/notebooks/pyi-issues/5946/dist/test
> pyinstaller --onefile --name=onefile test.py
> ./dist/onefile
/e/notebooks/pyi-issues/5946/dist/onefile
/tmp/_MEIOmfMMX |
Beta Was this translation helpful? Give feedback.
-
Just a small comment on this if this is the proper place for it, it would be nice if there was a supported way to do this that's not a "hack" My use case: I want to log information in case something goes wrong so users can provide me these logs. For dynamic uses (I'll be providing ways to build themselves, if they really want to) I want to then choose where the logging goes. If we're in onedir mode, then I can simply log there... if not though, that's the temp dir and I can't use it for logging because the log file will go bye bye too. So I need to know which mode I am so that I can choose where to put the log file. I can't dynamically just use |
Beta Was this translation helpful? Give feedback.
I guess you could compare
sys._MEIPASS
andsys.executable
. If you're inonedir
mode thensys._MEIPASS == os.path.dirname(sys.executable)
. Does feel like a bit of a hack though.