chiark / gitweb /
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 17d28a7a77428f02d7ea36ea50790106427bc8ef..581d0be2a5fb3569b06681b7d559f1279aa4104b 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 6c2c9a75a0672124ae00c69ffa65c2bb6d325f74..a2250904972ca7bf647b29df84db9b96a01044f0 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 2e5dd7c4087890dfcbee47f90bf05e3cddf2bb90..eaf39c17ba9220b325a89e5292a19077072b87ea 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 ca9307e1d1e4bf3e83eafaa87ace266a09db30d1..5ec2c22b0579d1bc939fe9c6739c2682f836606c 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 3bbbd0d3e4e53049cb1aead21af908bc3536674a..042af631eb1b09bfea5d5b267c19d91c5fb21180 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'))