Hello,
I am using py2exe on windows, py2app on mac and custom tool (similar
to pyinstaller ) on linux.
I need to know, how you can get correct full path of app or executable
inside your scripts.
A nice article here:
http://us.pycon.org/media/2010/talkdata/PyCon2010/038/paper.html
suggests a function like this:
if CONTEXT == ('mac', 'frozen'):
DATA = os.path.join(APP_ROOT, 'Contents','Resources') # py2app
elif CONTEXT == ('windows', 'frozen'):
DATA = os.path.join(APP_ROOT, 'data') # py2exe
elif CONTEXT == ('linux', 'package'):
DATA = os.path.join(sys.prefix, 'share', APP_NAME) # linux
else:
DATA = os.path.join(...) # when run from source
I don't know what's 'APP_ROOT' here.
On various platform you can execute app using three ways:
1. Using terminal ( you are not in exe directory) by giving complete
path of application.
for example c:/temp c:/app/app.exe (on windows)
2. Using terminal (you are in same directory where the .exe is) by
typing .exe name.
3. By mouse click (either .exe or it's shortcut) windows and linux
Considering above three situation how do I get full path of app/.exe
inside scripts?
If I know what is 'APP_ROOT' in function above then I think this will
get you correct path
if CONTEXT == ('mac', 'frozen'):
PATH = os.path.join(APP_ROOT, 'Contents','Resources') # py2app
elif CONTEXT == ('windows', 'frozen'):
PATH = APP_ROOT # py2exe
elif CONTEXT == ('linux', 'package'):
PATH = sys.prefix # linux
else:
PATH = os.path.join(...) # when run from source
any pointers?
Prashant