refine local path mechanics
This commit is contained in:
parent
963895e7d4
commit
e4fd07185e
15
Utils.py
15
Utils.py
|
@ -49,14 +49,17 @@ def local_path(path):
|
||||||
if local_path.cached_path:
|
if local_path.cached_path:
|
||||||
return os.path.join(local_path.cached_path, path)
|
return os.path.join(local_path.cached_path, path)
|
||||||
|
|
||||||
elif is_bundled() and hasattr(sys, "_MEIPASS"):
|
elif is_bundled():
|
||||||
# we are running in a PyInstaller bundle
|
if hasattr(sys, "_MEIPASS"):
|
||||||
local_path.cached_path = sys._MEIPASS # pylint: disable=protected-access,no-member
|
# we are running in a PyInstaller bundle
|
||||||
|
local_path.cached_path = sys._MEIPASS # pylint: disable=protected-access,no-member
|
||||||
|
else:
|
||||||
|
# cx_Freeze
|
||||||
|
local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||||
else:
|
else:
|
||||||
# we are running in a normal Python environment
|
# we are running in a normal Python environment
|
||||||
# or cx_Freeze
|
import __main__
|
||||||
local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0]))
|
local_path.cached_path = os.path.dirname(os.path.abspath(__main__.__file__))
|
||||||
|
|
||||||
return os.path.join(local_path.cached_path, path)
|
return os.path.join(local_path.cached_path, path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue