forked from wolph/mt940
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·137 lines (116 loc) · 3.66 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import sys
from setuptools.command.test import test as TestCommand
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core 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)
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', 'Arguments to pass to pytest')]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ''
def run_tests(self):
import shlex
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)
tests_require = [
'pyyaml',
'pytest',
'pytest-cache',
'pytest-cover',
'pytest-flakes',
'pytest-pep8',
'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,
install_requires=[
'enum34>=1.1.6; python_version <= "2.7"',
],
tests_require=tests_require,
setup_requires=[
'setuptools>=39.1.0',
],
zip_safe=False,
cmdclass={'test': PyTest},
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 :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: PyPy',
],
)