Handle utf-8 email bodies with latin-1 characters
[stgit.git] / setup.py
blob284a64814a0cfc6a27e1e1497eff74fc4c689da3
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 from __future__ import (absolute_import, division, print_function,
4 unicode_literals)
5 from distutils.core import setup
6 import glob
7 import os
8 import sys
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
16 """
17 ver_list = []
18 for p in version.split('.'):
19 try:
20 n = int(p)
21 except ValueError:
22 n = p
23 ver_list.append(n)
24 return ver_list
26 def __check_min_version(min_ver, ver):
27 """Check whether ver is greater or equal to min_ver
28 """
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
35 """
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)
40 sys.exit(1)
42 def __check_git_version():
43 """Check the minimum GIT version
44 """
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)
50 sys.exit(1)
52 def __run_setup():
53 setup(name = 'stgit',
54 version = version.version,
55 license = 'GPLv2',
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',
62 scripts = ['stg'],
63 packages = list(map(str, ['stgit', 'stgit.commands', 'stgit.lib'])),
64 data_files = [
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'])
71 classifiers = [
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()
94 __check_git_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)
109 __run_setup()
111 # restore the old mask
112 os.umask(old_mask)