forked from JRCSTU/CO2MPAS-TA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·218 lines (195 loc) · 6.23 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#! python
##
## Installs co2mpas:
## python setup.py install
## or
## pip install -r requirements.txt
## and then just code from inside this folder.
#
import os
import io
import re
import sys
from setuptools import setup, find_packages
if sys.version_info < (3, 4):
msg = "Sorry, Python >= 3.4 is required, but found: {}"
sys.exit(msg.format(sys.version_info))
proj_name = 'co2mpas'
mydir = os.path.dirname(__file__)
# Version-trick to have version-info in a single place,
# taken from: http://stackoverflow.com/questions/2058802/how-can-i-get-the-version-defined-in-setup-py-setuptools-in-my-package
##
def read_project_version():
fglobals = {}
with io.open(os.path.join(
mydir, 'co2mpas', '_version.py'), encoding='UTF-8') as fd:
exec(fd.read(), fglobals) # To read __version__
return fglobals['__version__']
def read_text_lines(fname):
with io.open(os.path.join(mydir, fname)) as fd:
return fd.readlines()
def yield_rst_only_markup(lines):
"""
:param file_inp: a `filename` or ``sys.stdin``?
:param file_out: a `filename` or ``sys.stdout`?`
"""
substs = [
# Selected Sphinx-only Roles.
#
(r':abbr:`([^`]+)`', r'\1'),
(r':ref:`([^`]+)`', r'ref: *\1*'),
(r':term:`([^`]+)`', r'**\1**'),
(r':dfn:`([^`]+)`', r'**\1**'),
(r':(samp|guilabel|menuselection|doc|file):`([^`]+)`',
r'``\2``'),
# Sphinx-only roles:
# :foo:`bar` --> foo(``bar``)
# :a:foo:`bar` XXX afoo(``bar``)
#
#(r'(:(\w+))?:(\w+):`([^`]*)`', r'\2\3(``\4``)'),
#(r':(\w+):`([^`]*)`', r'\1(`\2`)'),
# emphasis
# literal
# code
# math
# pep-reference
# rfc-reference
# strong
# subscript, sub
# superscript, sup
# title-reference
# Sphinx-only Directives.
#
(r'\.\. doctest', r'code-block'),
(r'\.\. plot::', r'.. '),
(r'\.\. seealso', r'info'),
(r'\.\. glossary', r'rubric'),
(r'\.\. figure::', r'.. '),
(r'\.\. image::', r'.. '),
# Other
#
(r'\|version\|', r'x.x.x'),
(r'\.\. include:: AUTHORS', r'see: AUTHORS'),
]
regex_subs = [(re.compile(regex, re.IGNORECASE), sub)
for (regex, sub) in substs]
def clean_line(line):
try:
for (regex, sub) in regex_subs:
line = regex.sub(sub, line)
except Exception as ex:
print("ERROR: %s, (line(%s)" % (regex, sub))
raise ex
return line
for line in lines:
yield clean_line(line)
proj_ver = read_project_version()
readme_lines = read_text_lines('README.rst')
description = readme_lines[1]
long_desc = ''.join(yield_rst_only_markup(readme_lines))
download_url = 'https://github.com/JRCSTU/%s/tarball/v%s' % (proj_name, proj_ver)
setup(
name=proj_name,
version=proj_ver,
description="A vehicle simulator predicting CO2 emissions for NEDC using WLTP time-series",
long_description=long_desc,
download_url=download_url,
keywords=[
"python", "utility", "library", "data", "processing",
"calculation", "dependencies", "resolution", "scientific",
"engineering", "dispatch", "simulink", "graphviz",
],
url='http://co2mpas.io/',
license='EUPL 1.1+',
author='CO2MPAS-Team',
author_email='[email protected]',
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: Implementation :: CPython",
"Development Status :: 4 - Beta",
'Natural Language :: English',
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Manufacturing",
'Environment :: Console',
'License :: OSI Approved :: European Union Public Licence 1.1 (EUPL 1.1)',
'Natural Language :: English',
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: OS Independent",
'Topic :: Scientific/Engineering',
"Topic :: Scientific/Engineering :: Information Analysis",
],
setup_requires=[
'setuptools',
],
# build_requires=[
# # PEP426-field actually not used by `pip` them, hence
# # included in /requirements/developmnet.pip.
# 'setuptools',
# 'setuptools-git >= 0.3',
# 'wheel',
# ],
# dev_requires=[
# # PEP426-field actually not used by `pip` them, hence
# # included in /requirements/developmnet.pip.
# 'sphinx',
# ],
install_requires=[
'pandas',
'xlsxwriter',
'scikit-learn',
'numpy',
'scipy',
'lmfit>=0.9.2',
'matplotlib',
'networkx',
'dill',
'graphviz',
'sphinx',
'docopt',
'six',
'easygui!=0.98',
'mpld3',
'pandalone>=0.1.11', ## For datasync pascha-fixes.
'regex',
'schema',
'tqdm',
'pyyaml',
'cycler',
'pip',
'boltons',
'pykalman',
'wltp',
'cachetools',
],
packages=find_packages(exclude=['tests', 'doc']),
package_data={'co2mpas': [
'demos/*.xlsx',
'ipynbs/*.ipynb',
'co2mpas_template.xlsx',
'datasync_template.xlsx',
]},
include_package_data=True,
zip_safe=True,
test_suite='nose.collector',
tests_require=['nose>=1.0', 'ddt'],
entry_points={
'console_scripts': [
'%(p)s = %(p)s.__main__:main' % {'p': proj_name},
'datasync = %(p)s.datasync:main' % {'p': proj_name},
'%(p)s-autocompletions = %(p)s.__main__:print_autocompletions' % {'p': proj_name},
],
},
options={
'bdist_wheel': {
'universal': True,
},
},
platforms=['any'],
)