code: def find_top_pyfile():
      
      import os
      frame = currentframe()
      while True:
          if frame.f_back is None:
              finfo = getframeinfo(frame)
              #print(getframeinfo(frame))
              return os.path.abspath(finfo.filename)
  
          frame = frame.f_back
docs: This function inspects the Cpython frame to find the path of the script.