Commit | Line | Data |
---|---|---|
41a6d859 CM |
1 | #!/usr/bin/env python |
2 | ||
4e72d22a | 3 | import sys, glob, os |
41a6d859 CM |
4 | from distutils.core import setup |
5 | ||
453d47ae | 6 | from stgit.version import version, git_min_ver, python_min_ver |
453d47ae CM |
7 | |
8 | def __version_to_list(version): | |
9 | """Convert a version string to a list of numbers or strings | |
10 | """ | |
11 | ver_list = [] | |
12 | for p in version.split('.'): | |
13 | try: | |
14 | n = int(p) | |
15 | except ValueError: | |
16 | n = p | |
17 | ver_list.append(n) | |
18 | return ver_list | |
19 | ||
20 | def __check_min_version(min_ver, ver): | |
21 | """Check whether ver is greater or equal to min_ver | |
22 | """ | |
23 | min_ver_list = __version_to_list(min_ver) | |
24 | ver_list = __version_to_list(ver) | |
25 | return min_ver_list <= ver_list | |
26 | ||
27 | def __check_python_version(): | |
28 | """Check the minimum Python version | |
29 | """ | |
5717401c | 30 | pyver = '.'.join(map(lambda x: str(x), sys.version_info)) |
453d47ae CM |
31 | if not __check_min_version(python_min_ver, pyver): |
32 | print >> sys.stderr, 'Python version %s or newer required. Found %s' \ | |
33 | % (python_min_ver, pyver) | |
34 | sys.exit(1) | |
35 | ||
36 | def __check_git_version(): | |
37 | """Check the minimum GIT version | |
38 | """ | |
003dccff | 39 | from stgit.run import Run |
453d47ae CM |
40 | gitver = Run('git', '--version').output_one_line().split()[2] |
41 | if not __check_min_version(git_min_ver, gitver): | |
42 | print >> sys.stderr, 'GIT version %s or newer required. Found %s' \ | |
43 | % (git_min_ver, gitver) | |
44 | sys.exit(1) | |
45 | ||
46 | # Check the minimum versions required | |
47 | if sys.argv[1] in ['install', 'build']: | |
48 | __check_python_version() | |
49 | __check_git_version() | |
41a6d859 | 50 | |
4e72d22a CM |
51 | # ensure readable template files |
52 | old_mask = os.umask(0022) | |
53 | ||
41a6d859 CM |
54 | setup(name = 'stgit', |
55 | version = version, | |
56 | license = 'GPLv2', | |
57 | author = 'Catalin Marinas', | |
a2275a12 | 58 | author_email = 'catalin.marinas@gmail.com', |
41a6d859 CM |
59 | url = 'http://www.procode.org/stgit/', |
60 | description = 'Stacked GIT', | |
61 | long_description = 'Push/pop utility on top of GIT', | |
3659ef88 | 62 | scripts = ['stg'], |
957526bf | 63 | packages = ['stgit', 'stgit.commands'], |
47e93ba9 CM |
64 | data_files = [('share/stgit/templates', glob.glob('templates/*.tmpl')), |
65 | ('share/stgit/examples', glob.glob('examples/*.tmpl')), | |
abcc2620 | 66 | ('share/stgit/examples', ['examples/gitconfig']), |
1aaf55c9 CM |
67 | ('share/stgit/contrib', ['contrib/diffcol.sh', |
68 | 'contrib/stgbashprompt.sh', | |
69 | 'contrib/stgit-completion.bash']), | |
d1c8fcd7 | 70 | ('share/doc/stgit', glob.glob('doc/*.txt'))] |
41a6d859 | 71 | ) |
4e72d22a CM |
72 | |
73 | # restore the old mask | |
74 | os.umask(old_mask) |