I have a python script that needs to be executed from within the folder where it is located. I am distributing it as PyInstaller compiled executable (wrapped into an AppImage for Linux). I will probably migrate to Platypus for OSX, so that I get a .app file.
The problem is that the executable isn't executed from within the correct directory when being double-clicked (because the AppImage / .app bundle add some folders to the path).
I want to add an os.chdir() command so that it goes to the correct path on all platforms, no matter if run as .py file, bundled as .exe, bundled as .app, or bundled as AppImage. What is the best way to do that?
Note: The reason why I need it to be executed from the correct directory is some log / data / config files being located there.
I ended up using full paths, like /opt/foobar on Linux or c:\opt\foobar on windows. Simple and stable solution, only drawback is the user might require admin rights.