chiark / gitweb /
Only print the progress message if on a TTY
[stgit] / stg
diff --git a/stg b/stg
index ca9307e1d1e4bf3e83eafaa87ace266a09db30d1..def843c5d5fd4dee9a54504512b4308cb3a84018 100755 (executable)
--- a/stg
+++ b/stg
@@ -20,6 +20,24 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
+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]
+    local_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')]
+    sys.path = local_path + sys.path
+
 from stgit.main import main
 
-main()
+if __name__ == '__main__':
+    main()