Allow StGIT to be installed in a local directory
authorCatalin Marinas <catalin.marinas@gmail.com>
Mon, 15 Aug 2005 16:16:17 +0000 (17:16 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 15 Aug 2005 16:16:17 +0000 (17:16 +0100)
StGIT should no longer rely on being installed under /usr. This has
implications in the default python search path, the /etc/stgitrc file
and the /usr/share/stgit/templates directory.

By default, the 'python setup.py install' command will now install StGIT
in the home directory of the current user.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
MANIFEST.in
examples/stgitrc [moved from stgitrc with 87% similarity]
setup.cfg [new file with mode: 0644]
setup.py
stg
stgit/config.py

index 17d28a7..581d0be 100644 (file)
@@ -1,3 +1,4 @@
-include README MANIFEST.in AUTHORS COPYING INSTALL ChangeLog TODO stgitrc
-include examples/*.tmpl
+include README MANIFEST.in AUTHORS COPYING INSTALL ChangeLog TODO
 include templates/*.tmpl
+include examples/*.tmpl
+include examples/stgitrc
similarity index 87%
rename from stgitrc
rename to examples/stgitrc
index 6c2c9a7..a225090 100644 (file)
--- a/stgitrc
@@ -1,3 +1,7 @@
+# StGIT configuration file. Copy it to any of /etc/stgitrc, ~/.stgitrc
+# or .git/stgitrc and modify as needed. Note that the latter overrides
+# the former.
+
 [stgit]
 # Default author/committer details
 #authname:  Your Name
diff --git a/setup.cfg b/setup.cfg
new file mode 100644 (file)
index 0000000..4359033
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[install]
+prefix: ~
index 2e5dd7c..eaf39c1 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -15,7 +15,7 @@ setup(name = 'stgit',
       long_description = 'Push/pop utility on top of GIT',
       scripts = ['stg', 'gitmergeonefile.py'],
       packages = ['stgit', 'stgit.commands'],
-      data_files = [('/etc', ['stgitrc']),
-                    ('share/stgit/templates', glob.glob('templates/*.tmpl')),
-                    ('share/stgit/examples', glob.glob('examples/*.tmpl'))]
+      data_files = [('share/stgit/templates', glob.glob('templates/*.tmpl')),
+                    ('share/stgit/examples', glob.glob('examples/*.tmpl')),
+                    ('share/stgit/examples', ['examples/stgitrc'])]
       )
diff --git a/stg b/stg
index ca9307e..5ec2c22 100755 (executable)
--- a/stg
+++ b/stg
@@ -20,6 +20,22 @@ 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]
+    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.main import main
 
 main()
index 3bbbd0d..042af63 100644 (file)
@@ -28,6 +28,18 @@ else:
 
 config = ConfigParser.RawConfigParser()
 
-config.readfp(file('/etc/stgitrc'))
+# Set the defaults
+config.add_section('stgit')
+config.set('stgit', 'autoresolved', 'no')
+config.set('stgit', 'smtpserver', 'localhost:25')
+
+config.add_section('gitmergeonefile')
+config.set('gitmergeonefile', 'merger',
+           'diff3 -L local -L older -L remote -m -E ' \
+           '"%(branch1)s" "%(ancestor)s" "%(branch2)s" > "%(output)s"')
+config.set('gitmergeonefile', 'keeporig', 'yes')
+
+# Read the configuration files (if any) and override the default settings
+config.read('/etc/stgitrc')
 config.read(os.path.expanduser('~/.stgitrc'))
 config.read(os.path.join(__git_dir, 'stgitrc'))