问题
Nuitka is good at compiling Python to excutable binary. But the compiled binary finds other resource files from original absolute path. Thus, for moving to another computer requires to make the directory tree same as the original one.
For example, if I compile a project like this:
/home/me/myproj/
╠═ myprog.py
╚═ resource
╚═ foo.data
I should put the resulting binary and resource to the same location of another computer. How to solve this problem?
My simpler spike is:
# /home/me/myproj/spike.py
import os
print(os.path.dirname(__file__))
And after compiling it, moving to any other location, I always got the result of /home/me/myproj
.
I need a result like /another/path
if I move compiled myproj.bin
to /another/path
.
来源:https://stackoverflow.com/questions/59427353/how-to-get-the-current-path-of-compiled-binary-from-python-using-nuitka