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