2 # -*- coding: utf-8 -*-
3 from __future__
import (absolute_import
, division
, print_function
,
5 from distutils
.core
import setup
10 from stgit
import commands
, completion
, version
13 def __version_to_list(version
):
14 """Convert a version string to a list of numbers or strings
17 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
34 def __check_python_version():
35 """Check the minimum Python version
37 pyver
= '.'.join(map(str, sys
.version_info
))
38 if not __check_min_version(version
.python_min_ver
, pyver
):
39 print('Python version %s or newer required. Found %s'
40 % (version
.python_min_ver
, pyver
), file=sys
.stderr
)
44 def __check_git_version():
45 """Check the minimum GIT version
47 from stgit
.run
import Run
48 gitver
= Run('git', '--version').output_one_line().split()[2]
49 if not __check_min_version(version
.git_min_ver
, gitver
):
50 print('GIT version %s or newer required. Found %s'
51 % (version
.git_min_ver
, gitver
), file=sys
.stderr
)
55 # Check the minimum versions required
56 __check_python_version()
59 # ensure readable template files
60 old_mask
= os
.umask(0o022)
63 ver
= version
.git_describe_version()
64 except version
.VersionUnavailable
:
65 ver
= version
.git_archival_version()
66 with
open('stgit/builtin_version.py', 'w') as f
:
68 '# This file is automatically generated. Do not edit.',
69 'version = {ver!r}'.format(ver
=ver
),
74 # generate the python command list
75 with
open('stgit/commands/cmdlist.py', 'w') as f
:
76 commands
.py_commands(commands
.get_commands(allow_cached
=False), f
)
78 # generate the bash completion script
79 with
open('stgit-completion.bash', 'w') as f
:
80 completion
.write_completion(f
)
86 author
='Catalin Marinas',
87 author_email
='catalin.marinas@gmail.com',
88 url
='http://www.procode.org/stgit/',
89 download_url
='https://repo.or.cz/stgit.git',
90 description
='Stacked GIT',
91 long_description
='Push/pop utility on top of GIT',
93 packages
=list(map(str, ['stgit', 'stgit.commands', 'stgit.lib'])),
95 ('share/stgit/templates', glob('templates/*.tmpl')),
96 ('share/stgit/examples', glob('examples/*.tmpl')),
97 ('share/stgit/examples', ['examples/gitconfig']),
98 ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),
99 ('share/stgit/completion', ['stgit-completion.bash']),
102 'Development Status :: 5 - Production/Stable',
103 'Environment :: Console',
104 'Intended Audience :: Developers',
105 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)'
106 'Natural Language :: English',
107 'Operating System :: OS Independent',
108 'Programming Language :: Python',
109 'Programming Language :: Python :: 2',
110 'Programming Language :: Python :: 2.6',
111 'Programming Language :: Python :: 2.7',
112 'Programming Language :: Python :: 3',
113 'Programming Language :: Python :: 3.3',
114 'Programming Language :: Python :: 3.4',
115 'Programming Language :: Python :: 3.5',
116 'Programming Language :: Python :: 3.6',
117 'Programming Language :: Python :: 3.7',
118 'Programming Language :: Python :: Implementation :: CPython',
119 'Programming Language :: Python :: Implementation :: PyPy',
120 'Topic :: Software Development :: Version Control',
124 # restore the old mask