Just as reference imagine the following project structure:
/testapp
| __main__.py
| firstclass.py
| secondclass.py
To make installation and deploy easier I decided to bundle these files using the trick below:
- zip the .py files
- echo '#!/usr/bin/env python3' | cat - testapp.zip > testapp
The issue now is that "firstclass.py" needs the abspath of "testapp".
If I run this bundled testapp and asks for __file__ it returns the script path, for example the path for "firstclass.py" not "testapp" (the executable).
I also tried using sys.executable, it returns the path for "/usr/bin/python3".
Is there an easy way to get the abspath of "testapp"? I only care for linux environments.
Also the whole point of this is due to the fact that I cannot rely on the name of "testapp", final installer can change that name and I need a reference to it.
Thanks.