accessing files after setup.py install
- by Matthew
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?