Commits

Ian Bicking committed 4041a26

Put the version in just one place (virtualenv.py)

Comments (0)

Files changed (3)

 # other places throughout the built documents.
 #
 # The short X.Y version.
-version = '1.4'
-# The full version, including alpha/beta/rc tags.
-release = '1.4.1.post1'
+
+## Figure out the version from virtualenv.py:
+version_re = re.compile(
+    r'virtualenv_version = "(.*?)"')
+fp = open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
+                       'virtualenv.py'))
+version = None
+for line in fp:
+    match = version_re.search(line)
+    if match:
+        release = match.group(1)
+        break
+else:
+    raise Exception("Cannot find version in virtualenv.py")
+fp.close()
+del line, fp, version_re
+version = '.'.join(release.split('.')[:2])
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
     from distutils.core import setup
     print 'Note: without Setuptools installed you will have to use "python -m virtualenv ENV"'
 import sys, os
+import re
+## A warning just for Ian:
+try:
+    import getpass
+except ImportError:
+    is_ianb = False
+else:
+    is_ianb = getpass.getuser() == 'ianb'
 
-version = '1.4.1.post1'
+here = os.path.dirname(os.path.abspath(__file__))
 
-f = open(os.path.join(os.path.dirname(__file__), 'docs', 'index.txt'))
+## Figure out the version from virtualenv.py:
+version_re = re.compile(
+    r'virtualenv_version = "(.*?)"')
+fp = open(os.path.join(here, 'virtualenv.py'))
+version = None
+for line in fp:
+    match = version_re.search(line)
+    if match:
+        version = match.group(1)
+        break
+else:
+    raise Exception("Cannot find version in virtualenv.py")
+fp.close()
+
+## Get long_description from index.txt:
+f = open(os.path.join(here, 'docs', 'index.txt'))
 long_description = f.read().strip()
 f.close()
 
+if is_ianb and 'register' in sys.argv:
+    if 'hg tip\n~~~~~~' in long_description:
+        print >> sys.stderr, (
+            "WARNING: hg tip is in index.txt")
+
 setup(name='virtualenv',
       version=version,
       description="Virtual Python Environment builder",
 """Create a "virtual" Python installation
 """
 
+virtualenv_version = "1.4.1.post1"
+
 import sys
 import os
 import optparse
 
 def main():
     parser = optparse.OptionParser(
-        version="1.4.1.post1",
+        version=virtualenv_version,
         usage="%prog [OPTIONS] DEST_DIR")
 
     parser.add_option(