[PATCH] setup: get version number using pure Python modules

Martin Geisler mg at daimi.au.dk
Tue Jan 27 18:01:41 CST 2009


# HG changeset patch
# User Martin Geisler <mg at daimi.au.dk>
# Date 1233100890 -3600
# Node ID e7588c67df41df7a15fe42c24284ccd9addf963a
# Parent  5d25b2f59adeca72930be5a8f30f785e1edabb3d
setup: get version number using pure Python modules

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -96,7 +96,14 @@
     pass
 
 try:
-    l = os.popen('hg id -it').read().split()
+    # execute hg out of this directory with a custom environment which
+    # includes the pure Python modules in mercurial/pure
+    pypath = os.environ.get('PYTHONPATH', '')
+    purepath = os.path.join('mercurial', 'pure')
+    os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
+    cmd = '%s id -it' % os.path.join('.', 'hg')
+    l = os.popen(cmd).read().split()
+    os.environ['PYTHONPATH'] = pypath
     while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
         l.pop()
     version = l and l[-1] or 'unknown' # latest tag or revision number


More information about the Mercurial-devel mailing list