accessing files after setup.py install
Posted
by Matthew
on Stack Overflow
See other posts from Stack Overflow
or by Matthew
Published on 2010-06-06T20:17:05Z
Indexed on
2010/06/06
20:22 UTC
Read the original article
Hit count: 319
I'm developing a python application and have a question regarding coding it so that it still works after an user has installed it on his or her machine via setup.py install or similar.
In one of my files, I use the following:
file = "TestParser/View/MainWindow.ui" cwd = os.getcwd() argv_path = os.path.dirname(sys.argv[0]) file_path = os.path.join(cwd, argv_path, file)
in order to get the path to MainWindow.ui
, when I only know the path relative to the main script's location. This works regardless of from where I call the main script.
The issue is that after an user installs the application on his or her machine, the relative path is different, so this doesn't work. I could use __file__
, but according to this, py2exe doesn't have __file__
.
Is there a standard way of achieving this? Or a better way?
© Stack Overflow or respective owner