2 # -*- coding: utf-8 -*-
3 from __future__
import (absolute_import
, division
, print_function
,
5 from distutils
.core
import setup
10 from stgit
import version
11 from stgit
import commands
, completion
14 def __version_to_list(version
):
15 """Convert a version string to a list of numbers or strings
18 for p
in version
.split('.'):
27 def __check_min_version(min_ver
, ver
):
28 """Check whether ver is greater or equal to min_ver
30 min_ver_list
= __version_to_list(min_ver
)
31 ver_list
= __version_to_list(ver
)
32 return min_ver_list
<= ver_list
35 def __check_python_version():
36 """Check the minimum Python version
38 pyver
= '.'.join(map(str, sys
.version_info
))
39 if not __check_min_version(version
.python_min_ver
, pyver
):
40 print('Python version %s or newer required. Found %s'
41 % (version
.python_min_ver
, pyver
), file=sys
.stderr
)
45 def __check_git_version():
46 """Check the minimum GIT version
48 from stgit
.run
import Run
49 gitver
= Run('git', '--version').output_one_line().split()[2]
50 if not __check_min_version(version
.git_min_ver
, gitver
):
51 print('GIT version %s or newer required. Found %s'
52 % (version
.git_min_ver
, gitver
), file=sys
.stderr
)
56 # Check the minimum versions required
57 __check_python_version()
60 # ensure readable template files
61 old_mask
= os
.umask(0o022)
63 version
.write_builtin_version()
65 # generate the python command list
66 with
open('stgit/commands/cmdlist.py', 'w') as f
:
67 commands
.py_commands(commands
.get_commands(allow_cached
=False), f
)
69 # generate the bash completion script
70 with
open('stgit-completion.bash', 'w') as f
:
71 completion
.write_completion(f
)
75 version
=version
.version
,
77 author
='Catalin Marinas',
78 author_email
='catalin.marinas@gmail.com',
79 url
='http://www.procode.org/stgit/',
80 download_url
='http://repo.or.cz/stgit.git',
81 description
='Stacked GIT',
82 long_description
='Push/pop utility on top of GIT',
84 packages
=list(map(str, ['stgit', 'stgit.commands', 'stgit.lib'])),
86 ('share/stgit/templates', glob('templates/*.tmpl')),
87 ('share/stgit/examples', glob('examples/*.tmpl')),
88 ('share/stgit/examples', ['examples/gitconfig']),
89 ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),
90 ('share/stgit/completion', ['stgit-completion.bash']),
93 'Development Status :: 5 - Production/Stable',
94 'Environment :: Console',
95 'Intended Audience :: Developers',
96 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)'
97 'Natural Language :: English',
98 'Operating System :: OS Independent',
99 'Programming Language :: Python',
100 'Programming Language :: Python :: 2',
101 'Programming Language :: Python :: 2.6',
102 'Programming Language :: Python :: 2.7',
103 'Programming Language :: Python :: 3',
104 'Programming Language :: Python :: 3.3',
105 'Programming Language :: Python :: 3.4',
106 'Programming Language :: Python :: 3.5',
107 'Programming Language :: Python :: 3.6',
108 'Programming Language :: Python :: Implementation :: CPython',
109 'Programming Language :: Python :: Implementation :: PyPy',
110 'Topic :: Software Development :: Version Control',
114 # restore the old mask