<filename>setup.py
import os
import sys
import inspect
import platform
import threading


# ROOT_DIR = None
# def setup():
#     main_id = None
#     for t in threading.enumerate():
#         if t.name == 'MainThread':
#             main_id = t.ident
#             break

#     if not main_id:
#         raise RuntimeError("Main thread exited before execution")

#     current_main_frame = sys._current_frames()[main_id]
#     base_frame = inspect.getouterframes(current_main_frame)[-1]

#     if platform.system() == 'Windows':
#         filename = base_frame.filename
#     else:
#         filename = base_frame[0].f_code.co_filename

#     global ROOT_DIR
#     ROOT_DIR = os.path.dirname(os.path.abspath(filename))

<filename>setup.py
import os
import sys
import inspect
import platform
import threading


# ROOT_DIR = None
# def setup():
#     main_id = None
#     for t in threading.enumerate():
#         if t.name == 'MainThread':
#             main_id = t.ident
#             break

#     if not main_id:
#         raise RuntimeError("Main thread exited before execution")

#     current_main_frame = sys._current_frames()[main_id]
#     base_frame = inspect.getouterframes(current_main_frame)[-1]

#     if platform.system() == 'Windows':
#         filename = base_frame.filename
#     else:
#         filename = base_frame[0].f_code.co_filename

#     global ROOT_DIR
#     ROOT_DIR = os.path.dirname(os.path.abspath(filename))

# ROOT_DIR = None # def setup(): #     main_id = None #     for t in threading.enumerate(): #         if t.name == 'MainThread': #             main_id = t.ident #             break #     if not main_id: #         raise RuntimeError("Main thread exited before execution") #     current_main_frame = sys._current_frames()[main_id] #     base_frame = inspect.getouterframes(current_main_frame)[-1] #     if platform.system() == 'Windows': #         filename = base_frame.filename #     else: #         filename = base_frame[0].f_code.co_filename #     global ROOT_DIR #     ROOT_DIR = os.path.dirname(os.path.abspath(filename))