Skip to content

Check if one-file or one-dir #5946

Discussion options

You must be logged in to vote

I guess you could compare sys._MEIPASS and sys.executable. If you're in onedir mode then sys._MEIPASS == os.path.dirname(sys.executable). Does feel like a bit of a hack though.

# 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

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@dimitriepirghie
Comment options

Answer selected by dimitriepirghie
Comment options

You must be logged in to vote
3 replies
@rokm
Comment options

@Phxntxm
Comment options

@bwoodsend
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants