code: def install_as_gi():
      
  
      import sys
  
      # check if gi has already been replaces
      if "gi.repository" in const.PREFIX:
          return
  
      # make sure gi isn't loaded first
      for mod in iterkeys(sys.modules):
          if mod == "gi" or mod.startswith("gi."):
              raise AssertionError("pgi has to be imported before gi")
  
      # replace and tell the import hook
      import pgi
      import pgi.repository
      sys.modules["gi"] = pgi
      sys.modules["gi.repository"] = pgi.repository
      const.PREFIX.append("gi.repository")
docs: Call before the first gi import to redirect gi imports to pgi