def install_as_gi():
 import sys
 if ('gi.repository' in const.PREFIX):
  return
 for mod in iterkeys(sys.modules):
  if ((mod == 'gi') or mod.startswith('gi.')):
   raise AssertionError('pgi has to be imported before gi')
 import pgi
 import pgi.repository
 sys.modules['gi'] = pgi
 sys.modules['gi.repository'] = pgi.repository
 const.PREFIX.append('gi.repository')

def install_as_gi ( ) : import sys if ( 'gi.repository' in const . PREFIX ) : return for mod in iterkeys ( sys . modules ) : if ( ( mod == 'gi' ) or mod . startswith ( 'gi.' ) ) : raise AssertionError ( 'pgi has to be imported before gi' ) import pgi import pgi . repository sys . modules [ 'gi' ] = pgi sys . modules [ 'gi.repository' ] = pgi . repository const . PREFIX . append ( 'gi.repository' )
call before the first gi import to redirect gi imports to pgi .