This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
206 lines (172 loc) · 5.92 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
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright 2014 European Commission (JRC);
# Licensed under the EUPL (the 'Licence');
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
''''
Setuptools script for *fuefit* that calculates fitted fuel-maps from measured engine data-points based on coefficients with physical meaning.
Install:
========
Runs on Python-3, tested on: see :file:`.travis.yaml`
To install it, assuming you have download the sources,
do the usual::
python setup.py install
Or get it directly from the PIP repository::
pip install fuefit
'''
from distutils.version import StrictVersion
import os, sys, io
import re
from setuptools import setup
## Fail early in ancient python-versions
#
py_verinfo = sys.version_info
py_sver = StrictVersion("%s.%s.%s" % py_verinfo[:3])
if py_verinfo[0] != 3 or py_sver < StrictVersion("3.3"):
exit("Sorry, only Python 3.3+ is supported!")
if sys.argv[-1] == 'setup.py':
exit("To install, run `python setup.py install`")
proj_name = 'fuefit'
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, proj_name, '_version.py')) 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_sphinx_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'`\1`_'),
(r':term:`([^`]+)`', r'**\1**'),
(r':dfn:`([^`]+)`', r'**\1**'),
(r':(samp|guilabel|menuselection):`([^`]+)`', 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``)'),
## 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'),
]
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_sphinx_only_markup(readme_lines))
## Trick from: http://peterdowns.com/posts/first-time-with-pypi.html
download_url = 'https://github.com/ankostis/%s/tarball/v%s' %(proj_name, proj_ver)
setup(
name=proj_name,
version=proj_ver,
description=description,
long_description=long_desc,
author="Kostis Anagnostopoulos @ European Commission (JRC)",
author_email="[email protected]",
url="https://github.com/ankostis/fuefit",
download_url=download_url,
license = "European Union Public Licence 1.1 or later (EUPL 1.1+)",
keywords = [
"automotive", "vehicle", "vehicles", "car", "cars", "fuel", "consumption",
"engine", "engine-map", "fitting",
],
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",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Manufacturing",
"License :: OSI Approved :: European Union Public Licence 1.1 (EUPL 1.1)",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
],
packages=['fuefit', 'fuefit.test', 'fuefit.excel'],
include_package_data = True,
package_data={
'fuefit.test': ['*.bat', '*.sh'],
'fuefit.excel': ['*.xlsm', '*.ico'],
},
# extras_require = {
# 'docs': ['sphinx >= 1.2'],
# },
install_requires=[
'enum34',
'pandas',
'xlrd',
'scipy',
'lmfit',
'jsonschema',
'matplotlib',
'networkx',
'pint',
'xlwings == 0.2.3',
],
setup_requires = [
'setuptools',# >= 3.4.4',
'setuptools-git >= 0.3', ## Gather package-data from all files in git.
'nose>=1.0',
'sphinx', # >=1.3',
'sphinx_rtd_theme',
'wheel',
],
tests_require = [
'nose',
],
test_suite='nose.collector',
entry_points={
'console_scripts': [
'fuefit = fuefit.__main__:main',
],
},
zip_safe=True,
options={
'build_sphinx' :{
'build_dir': 'docs/_build',
},
'bdist_wheel' :{
'universal': True,
},
},
)