I'm trying to "pack" a Python project into an executable with PyInstaller and I can't really seem to find a way to include resources with it
As a start, I need to include a single .ico that's on the root of the project, I do this with --add-data "icon.ico:icon.ico"
To get the resources, the code uses
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
But when running the executable, it just tries to find it alongside the execultable (I guess that the resource_path() doesn't work then)
I've looked up _MEIPASS and it seems like now there's a _PYI_APPLICATION_HOME_DIR instead? I tried changing it, same issue though...
What am I doing wrong?