4 from distutils
.core
import setup
6 from stgit
import version
7 from stgit
import commands
, completion
9 def __version_to_list(version
):
10 """Convert a version string to a list of numbers or strings
13 for p
in version
.split('.'):
21 def __check_min_version(min_ver
, ver
):
22 """Check whether ver is greater or equal to min_ver
24 min_ver_list
= __version_to_list(min_ver
)
25 ver_list
= __version_to_list(ver
)
26 return min_ver_list
<= ver_list
28 def __check_python_version():
29 """Check the minimum Python version
31 pyver
= '.'.join(map(lambda x
: str(x
), sys
.version_info
))
32 if not __check_min_version(version
.python_min_ver
, pyver
):
33 print >> sys
.stderr
, 'Python version %s or newer required. Found %s' \
34 % (version
.python_min_ver
, pyver
)
37 def __check_git_version():
38 """Check the minimum GIT version
40 from stgit
.run
import Run
41 gitver
= Run('git', '--version').output_one_line().split()[2]
42 if not __check_min_version(version
.git_min_ver
, gitver
):
43 print >> sys
.stderr
, 'GIT version %s or newer required. Found %s' \
44 % (version
.git_min_ver
, gitver
)
49 version
= version
.version
,
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',
57 packages
= ['stgit', 'stgit.commands', 'stgit.lib'],
59 ('share/stgit/templates', glob
.glob('templates/*.tmpl')),
60 ('share/stgit/examples', glob
.glob('examples/*.tmpl')),
61 ('share/stgit/examples', ['examples/gitconfig']),
62 ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),
63 ('share/stgit/completion', ['stgit-completion.bash'])
66 # Check the minimum versions required
67 __check_python_version()
70 # ensure readable template files
71 old_mask
= os
.umask(0022)
73 version
.write_builtin_version()
75 # generate the python command list
76 f
= file('stgit/commands/cmdlist.py', 'w')
77 commands
.py_commands(commands
.get_commands(allow_cached
= False), f
)
80 # generate the bash completion script
81 f
= file('stgit-completion.bash', 'w')
82 completion
.write_completion(f
)
87 # restore the old mask