forked from radis/radis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
205 lines (171 loc) · 6.09 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
""" Install file for RADIS
Typical install procedure, plus:
- auto-convert README.rst to long_description, removing some sphinx-only syntax
so it can be rendered by PyPi
- read version number from __version__.txt
- some dependencies should be installed manually (typically: all packages with
compiled components such as numpy, pandas, etc.)
Examples
--------
Install (normal, use-only)::
python setup.py install
Or (create an alias, so you can still edit)::
python setup.py develop
Notes
-----
For developers:
when creating a new version, just update the __version__.txt file
to register it on Pypi see register.py::
python register.py
"""
from __future__ import print_function
from __future__ import absolute_import
from setuptools import setup, find_packages
import codecs
import io
import re
import os
import io
from os.path import abspath, dirname, join, exists
import re
import sys
# Build description from README (PyPi compatible)
# -----------------------------------------------
# Utils to format RST
def yield_sphinx_only_markup(lines):
"""
Cleans-up Sphinx-only constructs (ie from README.rst),
so that *PyPi* can format it properly.
To check for remaining errors, install ``sphinx`` and run::
python setup.py --long-description | sed -file 'this_file.sed' | rst2html.py --halt=warning
:param file_inp: a `filename` or ``sys.stdin``?
:param file_out: a `filename` or ``sys.stdout`?`
References
----------
https://stackoverflow.com/questions/16367770/my-rst-readme-is-not-formatted-on-pypi-python-org
Notes
-----
Check output with::
python setup.py --long-description | rst2html.py > output.html
"""
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".. "),
## Other
#
(r"\|version\|", r"x.x.x"),
## added to make RADIS docs Pypi compatible
# (r'\.\. image::', r'.. '),
# (r'\.\. |CO2| replace:: CO\ :sub:`2`', r'.. '),
]
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)
# (note: README.rst has been converted to README.md by register.py, and cleaned afterwards )
description = "A fast line-by-line code for high-resolution infrared molecular spectra"
readme_path = join(abspath(dirname(__file__)), "README.md")
if not exists(readme_path):
long_description = description
else:
with io.open(readme_path, encoding="utf-8") as f:
long_description = f.read()
# Read version number from file
with open(join(dirname(__file__), "radis", "__version__.txt")) as version_file:
__version__ = version_file.read().strip()
# Main install routine
setup(
name="radis",
version=__version__,
description=description,
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/radis/radis",
author="Erwan Pannier",
author_email="[email protected]",
license="GNU Lesser General Public License v3 (LGPLv3)",
keywords=[
"spectrum",
"infrared",
"spectra",
"radiation",
"nonequilibrium",
"spectroscopy",
"molecules",
"HITRAN",
],
packages=find_packages(),
install_requires=[
"numpy",
"scipy",
"matplotlib",
"pandas",
"plotly",
"h5py",
"numba",
"mpldatacursor",
"astropy", # Unit aware calculations
"pint>=0.7.2", # Unit aware calculations
"publib>=0.3.2", # Plotting styles for Matplotlib
"plotly>=2.5.1", # for line survey HTML output
"termcolor", # terminal colors
"six", # python 2-3 compatibility
"configparser",
"astroquery>=0.3.9", # to fetch HITRAN databases
"json-tricks>=3.13.6", # to deal with non jsonable formats
"tables", # for pandas to HDF5 export
"pytest", # to run test suite
"h5py", # to write HDF5 files
"joblib", # for parallel loading of SpecDatabase
"numba", # just-in-time compiler
],
extras_require={
"dev": [
"numpydoc", # for Jedi (autocompletion) to recognize
"black", # for code-linting in accordance to PEP8
"isort", # for sorting imports
"pre-commit", # to enforce Black before each commit
]
},
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Topic :: Scientific/Engineering",
"Programming Language :: Python",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Operating System :: OS Independent",
],
include_package_data=True, # add non .py data files in MANIFEST.in
# package_data={'radis': ['radis/phys/units.txt']},
zip_safe=False, # impossible as long as we have external files read with __file__ syntax
platforms="any",
)