Skip to content

Commit cfe5d47

Browse files
committed
Fix resource_path for builds
1 parent 6af498b commit cfe5d47

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

utils/files.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import os
22
import sys
33

4-
from . import config
5-
64
def resource_path(relative_path):
7-
if config.PRODUCTION:
8-
try:
9-
base_path = sys._MEIPASS
10-
except Exception:
11-
base_path = os.path.abspath(".")
12-
13-
return os.path.join(base_path, relative_path)
5+
""" Get the absolute path to a resource, handling PyInstaller builds. """
6+
if getattr(sys, 'frozen', False): # Detect if running as a PyInstaller bundle
7+
base_path = sys._MEIPASS # Extracted temp folder
148
else:
15-
return relative_path
9+
base_path = os.path.abspath(".") # Normal script execution
10+
11+
return os.path.join(base_path, relative_path)

0 commit comments

Comments
 (0)