-
Notifications
You must be signed in to change notification settings - Fork 27
/
setup.py
151 lines (121 loc) · 3.45 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# -*- coding: utf-8 -*-
"""
Environments:
SIMPLE_SEISMOGRAPH - to install library without requirements of extensions
SEISMOGRAPH_EXTENSIONS - names of extensions separated by commas
"""
import os
import re
from setuptools import setup
from setuptools import find_packages
with open('seismograph/__init__.py') as _:
__version__ = re.search(r"__version__\s*=\s*'(.*)'", _.read(), re.M).group(1)
assert __version__
class libs:
flask = 'flask>=0.7'
seisma = 'seisma>=0.0.1'
requests = 'requests>=2.5'
selenium = 'selenium>=2.46'
sqlalchemy = 'sqlalchemy>=0.8'
jsonschema = 'jsonschema>=1.0'
EXTENSIONS = [
'mocker',
'alchemy',
'builder',
'selenium',
'seisma',
]
REQUIREMENTS = [
'six>=1.4',
'python-dateutil',
]
CONSOLE_SCRIPTS = [
'seismograph = seismograph.__main__:main',
]
EX_REQUIREMENTS = {
'mocker': [
libs.flask,
libs.requests,
],
'selenium': [
libs.selenium,
],
'alchemy': [
libs.sqlalchemy,
],
'builder': [
libs.jsonschema,
],
'seisma': [
libs.seisma,
],
}
EX_CONSOLE_SCRIPTS = {
'mocker': [
'seismograph.mocker = seismograph.ext.mocker.__main__:main',
],
}
SIMPLE_INSTALL = os.getenv('SIMPLE_SEISMOGRAPH')
EXTENSIONS_TO_INSTALL = os.getenv('SEISMOGRAPH_EXTENSIONS')
def prepare_extension_data(ex_name):
if ex_name not in EXTENSIONS:
raise RuntimeError(
'Unknown extension name: {}'.format(ex_name),
)
requirements = EX_REQUIREMENTS.get(ex_name)
console_scripts = EX_CONSOLE_SCRIPTS.get(ex_name)
if requirements:
REQUIREMENTS.extend(requirements)
if console_scripts:
CONSOLE_SCRIPTS.extend(console_scripts)
def prepare_data():
global REQUIREMENTS
if SIMPLE_INSTALL:
return
if EXTENSIONS_TO_INSTALL:
extensions_to_install = [
n.strip()
for n in EXTENSIONS_TO_INSTALL.split(',')
if n.strip()
]
for ex_name in extensions_to_install:
prepare_extension_data(ex_name)
else:
for ex_name in EXTENSIONS:
prepare_extension_data(ex_name)
REQUIREMENTS = list(set(REQUIREMENTS))
def install_package():
setup(
name='seismograph',
version=__version__,
url='https://github.com/trifonovmixail/seismograph',
packages=find_packages(exclude=('example*', 'tests*')),
author='Mikhail Trifonov',
author_email='[email protected]',
license='GNU LGPL',
description='Framework for test development',
keywords='test unittest framework',
long_description=open('README.rst').read(),
include_package_data=True,
zip_safe=False,
platforms='any',
install_requires=REQUIREMENTS,
entry_points={
'console_scripts': CONSOLE_SCRIPTS,
},
test_suite='tests',
classifiers=(
'Development Status :: 4 - Beta',
'Natural Language :: Russian',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development :: Testing',
),
)
if __name__ == '__main__':
prepare_data()
install_package()