When using py2exe, I've found that os.path.dirname(__file__) is giving me a filepath with the exe file in it, which is not what I am looking for. I've done some research and found that I should replace it with sys.argv[0] or sys.path[0], but both of those only get the top-level directory of the program. If I have sub-directories in the program, and I don't know the names of them at compile time, what can I do to find their directories?
For example, suppose there's a file, /stages/arena.py and I need to get /arena/ from it. What can I do to find this in a py2exe executable file? dirname gets me /main.exe/stages/ and sys.argv[0] and sys.path[0] get me /
What can I replace my os.path.dirname(__file__) calls with?