+import sys, os
+
+# Try to detect where it is run from and set prefix and the search path.
+# It is assumed that the user installed StGIT using the --prefix= option
+prefix, bin = os.path.split(sys.path[0])
+
+if bin == 'bin' and prefix != sys.prefix:
+ sys.prefix = prefix
+ sys.exec_prefix = prefix
+
+ major, minor = sys.version_info[0:2]
+ sys.path += [os.path.join(prefix, 'lib', 'python'),
+ os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor)),
+ os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor),
+ 'site-packages')]
+