-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
setup.py
executable file
·106 lines (92 loc) · 2.8 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
from setuptools import setup, find_packages
# To prevent importing about and thereby breaking the coverage info we use this
# exec hack
about = {}
with open('mt940/__about__.py') as fp:
exec(fp.read(), about)
tests_require = [
'pyyaml',
'pytest',
'pytest-cache',
'pytest-cover',
'pytest-flake8',
'flake8',
]
if sys.argv[-1] == 'info':
for k, v in about.items():
print('%s: %s' % (k, v))
sys.exit()
if __name__ == '__main__':
with open('README.rst') as fh:
try:
import sphinx2rst
readme = sphinx2rst.sphinx_to_rst(fh)
except ImportError:
readme = fh.read()
try:
import git
try:
repo = git.Repo('.')
except git.exc.InvalidGitRepositoryError:
raise ImportError()
if repo.bare:
raise ImportError()
tags = [tag.tag for tag in repo.tags if tag.tag]
tags = sorted(tags, key=lambda tag: tag.tagged_date, reverse=True)
changes = [
'',
'',
'Changelog',
'---------',
]
for tag in tags:
version = tag.tag
if version[0] != 'v':
version = 'v' + version
message = tag.message.split('\n')[0]
changes.append(' * **%s** %s' % (version, message))
changes = '\n'.join(changes)
except ImportError:
changes = ''
setup(
name=about['__package_name__'],
version=about['__version__'],
author=about['__author__'],
author_email=about['__email__'],
description=about['__description__'],
url=about['__url__'],
license=about['__license__'],
keywords=about['__title__'],
packages=find_packages(exclude=['docs']),
long_description=readme + changes,
include_package_data=True,
tests_require=tests_require,
setup_requires=[
'setuptools>=39.1.0',
],
zip_safe=False,
extras_require={
'docs': [
'sphinx>=1.7.2',
'GitPython>=2.1.9',
'sphinx2rst',
],
'tests': tests_require,
},
classifiers=[
'Development Status :: 6 - Mature',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: PyPy',
],
)