Fix gitmergeonefile.py to deal with local installation
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 16 Aug 2005 13:47:33 +0000 (14:47 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 16 Aug 2005 13:47:33 +0000 (14:47 +0100)
After a previous change, this file didn't know where to find the stgit
package if it wasn't installed with the default prefix.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
gitmergeonefile.py

index 99a6a7c..fe416bd 100755 (executable)
@@ -20,6 +20,18 @@ 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:
+    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')]
+
 from stgit.config import config
 from stgit.utils import append_string