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('.'):
26 def __check_min_version(min_ver
, ver
):
27 """Check whether ver is greater or equal to min_ver
29 min_ver_list
= __version_to_list(min_ver
)
30 ver_list
= __version_to_list(ver
)
31 return min_ver_list
<= ver_list
33 def __check_python_version():
34 """Check the minimum Python version
36 pyver
= '.'.join(map(str, sys
.version_info
))
37 if not __check_min_version(version
.python_min_ver
, pyver
):
38 print('Python version %s or newer required. Found %s'
39 % (version
.python_min_ver
, pyver
), file=sys
.stderr
)
42 def __check_git_version():
43 """Check the minimum GIT version
45 from stgit
.run
import Run
46 gitver
= Run('git', '--version').output_one_line().split()[2]
47 if not __check_min_version(version
.git_min_ver
, gitver
):
48 print('GIT version %s or newer required. Found %s'
49 % (version
.git_min_ver
, gitver
), file=sys
.stderr
)
54 version
= version
.version
,
56 author
= 'Catalin Marinas',
57 author_email
= 'catalin.marinas@gmail.com',
58 url
= 'http://www.procode.org/stgit/',
59 download_url
= 'http://repo.or.cz/stgit.git',
60 description
= 'Stacked GIT',
61 long_description
= 'Push/pop utility on top of GIT',
63 packages
= list(map(str, ['stgit', 'stgit.commands', 'stgit.lib'])),
65 ('share/stgit/templates', glob
.glob('templates/*.tmpl')),
66 ('share/stgit/examples', glob
.glob('examples/*.tmpl')),
67 ('share/stgit/examples', ['examples/gitconfig']),
68 ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),
69 ('share/stgit/completion', ['stgit-completion.bash'])
72 'Development Status :: 5 - Production/Stable',
73 'Environment :: Console',
74 'Intended Audience :: Developers',
75 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)'
76 'Natural Language :: English',
77 'Operating System :: OS Independent',
78 'Programming Language :: Python',
79 'Programming Language :: Python :: 2',
80 'Programming Language :: Python :: 2.7',
81 'Programming Language :: Python :: 3',
82 'Programming Language :: Python :: 3.3',
83 'Programming Language :: Python :: 3.4',
84 'Programming Language :: Python :: 3.5',
85 'Programming Language :: Python :: 3.6',
86 'Programming Language :: Python :: Implementation :: CPython',
87 'Programming Language :: Python :: Implementation :: PyPy',
88 'Topic :: Software Development :: Version Control',
92 # Check the minimum versions required
93 __check_python_version()
96 # ensure readable template files
97 old_mask
= os
.umask(0o022)
99 version
.write_builtin_version()
101 # generate the python command list
102 with
open('stgit/commands/cmdlist.py', 'w') as f
:
103 commands
.py_commands(commands
.get_commands(allow_cached
= False), f
)
105 # generate the bash completion script
106 with
open('stgit-completion.bash', 'w') as f
:
107 completion
.write_completion(f
)
111 # restore the old mask