4 from distutils
.core
import setup
7 from stgit
import commands
, version
8 from stgit
.completion
.bash
import write_bash_completion
9 from stgit
.completion
.fish
import write_fish_completion
12 def __version_to_list(version
):
13 """Convert a version string to a list of numbers or strings"""
15 for p
in version
.split('.'):
24 def __check_min_version(min_ver
, ver
):
25 """Check whether ver is greater or equal to min_ver"""
26 min_ver_list
= __version_to_list(min_ver
)
27 ver_list
= __version_to_list(ver
)
28 return min_ver_list
<= ver_list
31 def __check_python_version():
32 """Check the minimum Python version"""
33 pyver
= '.'.join(map(str, sys
.version_info
))
34 if not __check_min_version(version
.python_min_ver
, pyver
):
36 'Python version %s or newer required. Found %s'
37 % (version
.python_min_ver
, pyver
),
43 def __check_git_version():
44 """Check the minimum Git version"""
45 from stgit
.run
import Run
47 gitver
= Run('git', '--version').output_one_line().split()[2]
48 if not __check_min_version(version
.git_min_ver
, gitver
):
50 'Git version %s or newer required. Found %s'
51 % (version
.git_min_ver
, gitver
),
57 # Check the minimum versions required
58 __check_python_version()
61 # ensure readable template files
62 old_mask
= os
.umask(0o022)
65 version
.git_describe_version
,
66 version
.git_archival_version
,
67 version
.get_builtin_version
,
71 except version
.VersionUnavailable
:
76 print('StGit version unavailable', file=sys
.stderr
)
79 with
open('stgit/builtin_version.py', 'w') as f
:
81 '# This file is automatically generated. Do not edit.',
82 'version = {ver!r}'.format(ver
=ver
),
87 # generate the python command list
88 with
open('stgit/commands/cmdlist.py', 'w') as f
:
89 commands
.py_commands(commands
.get_commands(allow_cached
=False), f
)
91 if not os
.path
.exists('completion'):
92 os
.mkdir('completion')
94 # generate the bash completion script
95 with
open(os
.path
.join('completion', 'stgit.bash'), 'w') as f
:
96 write_bash_completion(f
)
98 # generate the fish completion script
99 with
open(os
.path
.join('completion', 'stg.fish'), 'w') as f
:
100 write_fish_completion(f
)
106 author
='Catalin Marinas',
107 author_email
='catalin.marinas@gmail.com',
108 url
='http://stacked-git.github.io',
109 download_url
='https://github.com/stacked-git/stgit.git',
110 description
='Stacked Git',
111 long_description
='Application for managing Git commits as a stack of patches.',
126 ('share/stgit/templates', glob('stgit/templates/*.tmpl')),
127 ('share/stgit/examples', glob('examples/*.tmpl')),
128 ('share/stgit/examples', ['examples/gitconfig']),
129 ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),
130 ('share/stgit/completion', ['completion/stg.fish']),
131 ('share/stgit/completion', ['completion/stgit.bash']),
132 ('share/stgit/completion', ['completion/stgit.zsh']),
136 'templates/covermail.tmpl',
137 'templates/mailattch.tmpl',
138 'templates/patchandattch.tmpl',
139 'templates/patchexport.tmpl',
140 'templates/patchmail.tmpl',
144 'Development Status :: 5 - Production/Stable',
145 'Environment :: Console',
146 'Intended Audience :: Developers',
147 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)'
148 'Natural Language :: English',
149 'Operating System :: OS Independent',
150 'Programming Language :: Python',
151 'Programming Language :: Python :: 3',
152 'Programming Language :: Python :: 3.5',
153 'Programming Language :: Python :: 3.6',
154 'Programming Language :: Python :: 3.7',
155 'Programming Language :: Python :: 3.8',
156 'Programming Language :: Python :: 3.9',
157 'Programming Language :: Python :: Implementation :: CPython',
158 'Programming Language :: Python :: Implementation :: PyPy',
159 'Topic :: Software Development :: Version Control',
163 # restore the old mask