stgit.el: Do not recurse into unknown directories after "t u"
[stgit] / setup.py
CommitLineData
41a6d859
CM
1#!/usr/bin/env python
2
62d51320 3import sys, glob, os
41a6d859
CM
4from distutils.core import setup
5
a2ba4d54 6from stgit import version
0eff9b85 7from stgit import commands, completion
453d47ae
CM
8
9def __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
21def __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
28def __check_python_version():
29 """Check the minimum Python version
30 """
5717401c 31 pyver = '.'.join(map(lambda x: str(x), 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
37def __check_git_version():
38 """Check the minimum GIT version
39 """
003dccff 40 from stgit.run import Run
453d47ae 41 gitver = Run('git', '--version').output_one_line().split()[2]
a2ba4d54 42 if not __check_min_version(version.git_min_ver, gitver):
453d47ae 43 print >> sys.stderr, 'GIT version %s or newer required. Found %s' \
a2ba4d54 44 % (version.git_min_ver, gitver)
453d47ae
CM
45 sys.exit(1)
46
5c5234db
KH
47def __run_setup():
48 setup(name = 'stgit',
49 version = version.version,
50 license = 'GPLv2',
51 author = 'Catalin Marinas',
52 author_email = 'catalin.marinas@gmail.com',
53 url = 'http://www.procode.org/stgit/',
54 description = 'Stacked GIT',
55 long_description = 'Push/pop utility on top of GIT',
56 scripts = ['stg'],
57 packages = ['stgit', 'stgit.commands', 'stgit.lib'],
58 data_files = [
59 ('share/stgit/templates', glob.glob('templates/*.tmpl')),
60 ('share/stgit/examples', glob.glob('examples/*.tmpl')),
61 ('share/stgit/examples', ['examples/gitconfig']),
afddd62b 62 ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),
6c8a90e1 63 ('share/stgit/completion', ['stgit-completion.bash'])
706c6fac 64 ])
5c5234db 65
453d47ae 66# Check the minimum versions required
0eff9b85
CM
67__check_python_version()
68__check_git_version()
41a6d859 69
62d51320
CM
70# ensure readable template files
71old_mask = os.umask(0022)
72
a3d0baef 73version.write_builtin_version()
0eff9b85
CM
74
75# generate the python command list
76f = file('stgit/commands/cmdlist.py', 'w')
77commands.py_commands(commands.get_commands(allow_cached = False), f)
78f.close()
79
80# generate the bash completion script
81f = file('stgit-completion.bash', 'w')
82completion.write_completion(f)
83f.close()
84
a3d0baef 85__run_setup()
62d51320
CM
86
87# restore the old mask
88os.umask(old_mask)