Hey everyone, I'm trying to package this library into an executable for the first time and I'm running into some relative pathing issues. It looks like the first thing the executable runs into is this line of code in
__init__.py
:
with open(Path(__file__).absolute().parents[0] / "VERSION") as _f:
__version__ = _f.read().strip()
From what I understand, accessing files needs to be guarded with a check to see if it is running as a binary to correct the pathing with a piece of code like this:
def resolve_path(relative_path):
"""
Determines if the app is running standalone (binary) or script
and chooses current working directory or application directory
then converts relative path to absolute path accordingly
"""
if getattr(sys, "frozen", False):
# If the 'frozen' flag is set, we are in bundled-app mode!
absolute_path = os.path.abspath(os.path.join(sys._MEIPASS, relative_path))
else:
# Normal development mode. Use os.getcwd() or __file__ as appropriate in your case...
absolute_path = os.path.abspath(os.path.join(os.getcwd(), relative_path))
return absolute_path
Does anyone know if there is a way to get around this issue without patching the whole library? Any thoughts?