code: def bundle_dir():
      
      if frozen():
          directory = sys._MEIPASS
      else:
          directory = os.path.dirname(os.path.abspath(stack()[1][1]))
      if os.path.exists(directory):
          return directory
docs: Handle resource management within an executable file.