chiark / gitweb /
Check the minimum required versions of GIT and Python (bug #10218)
authorCatalin Marinas <catalin.marinas@gmail.com>
Fri, 7 Dec 2007 21:16:36 +0000 (21:16 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Fri, 7 Dec 2007 21:16:36 +0000 (21:16 +0000)
The patch modifies the setup.py script to check the minimum versions
of GIT and Python required for building and installing StGIT. They are
currently set to git-1.5.2 and Python-2.4.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
setup.py
stgit/version.py

index cf5b1da37d2813ce2f0756e45a1522e8e10e9f23..7b0ded5c72f666d7e51b3b30c6e991bc08b3a725 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,52 @@
 #!/usr/bin/env python
 
-import glob
+import sys, glob
 from distutils.core import setup
 
-from stgit.version import version
+from stgit.version import version, git_min_ver, python_min_ver
+from stgit.run import Run
+
+def __version_to_list(version):
+    """Convert a version string to a list of numbers or strings
+    """
+    ver_list = []
+    for p in version.split('.'):
+        try:
+            n = int(p)
+        except ValueError:
+            n = p
+        ver_list.append(n)
+    return ver_list
+
+def __check_min_version(min_ver, ver):
+    """Check whether ver is greater or equal to min_ver
+    """
+    min_ver_list = __version_to_list(min_ver)
+    ver_list = __version_to_list(ver)
+    return min_ver_list <= ver_list
+
+def __check_python_version():
+    """Check the minimum Python version
+    """
+    pyver = '.'.join(str(n) for n in sys.version_info)
+    if not __check_min_version(python_min_ver, pyver):
+        print >> sys.stderr, 'Python version %s or newer required. Found %s' \
+              % (python_min_ver, pyver)
+        sys.exit(1)
+
+def __check_git_version():
+    """Check the minimum GIT version
+    """
+    gitver = Run('git', '--version').output_one_line().split()[2]
+    if not __check_min_version(git_min_ver, gitver):
+        print >> sys.stderr, 'GIT version %s or newer required. Found %s' \
+              % (git_min_ver, gitver)
+        sys.exit(1)
+
+# Check the minimum versions required
+if sys.argv[1] in ['install', 'build']:
+    __check_python_version()
+    __check_git_version()
 
 setup(name = 'stgit',
       version = version,
index e8dfdaf0a9ce2c2796fd2e697a1d5497b6d0fd39..edd79e0539446d9eccfb23a37015ad6675ac67cd 100644 (file)
@@ -1 +1,5 @@
 version = '0.13'
+
+# minimum version requirements
+git_min_ver = '1.5.2'
+python_min_ver = '2.5'