-
Notifications
You must be signed in to change notification settings - Fork 228
/
setup.py
255 lines (237 loc) · 12.3 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/usr/bin/env python3
###############################################################################
# #
# RMG - Reaction Mechanism Generator #
# #
# Copyright (c) 2002-2023 Prof. William H. Green ([email protected]), #
# Prof. Richard H. West ([email protected]) and the RMG Team ([email protected]) #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the 'Software'), #
# to deal in the Software without restriction, including without limitation #
# the rights to use, copy, modify, merge, publish, distribute, sublicense, #
# and/or sell copies of the Software, and to permit persons to whom the #
# Software is furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
# DEALINGS IN THE SOFTWARE. #
# #
###############################################################################
import sys
import os
from collections import OrderedDict
try:
from distutils.core import setup
from distutils.extension import Extension
except ImportError:
print('The distutils package is required to build or install RMG Py.')
raise
try:
from Cython.Build import cythonize
from Cython.Compiler import Options
except ImportError:
print('Cython (http://www.cython.org/) is required to build or install RMG Py.')
raise
try:
import numpy
except ImportError:
print('NumPy (http://numpy.scipy.org/) is required to build or install RMG Py.')
raise
# Create annotated HTML files for each of the Cython modules
Options.annotate = True
directives = {
# Set input language version to python 3
'language_level': 3,
# Turn on profiling capacity for all Cython modules
# 'profile': True,
# Embed call signatures in cythonized files - enable when building documentation
# 'embedsignature': True,
}
################################################################################
main_ext_modules = [
# RMG
Extension('rmgpy.rmgobject', ['rmgpy/rmgobject.pyx']),
# Kinetics
Extension('rmgpy.kinetics.arrhenius', ['rmgpy/kinetics/arrhenius.pyx']),
Extension('rmgpy.kinetics.chebyshev', ['rmgpy/kinetics/chebyshev.pyx']),
Extension('rmgpy.kinetics.kineticsdata', ['rmgpy/kinetics/kineticsdata.pyx']),
Extension('rmgpy.kinetics.falloff', ['rmgpy/kinetics/falloff.pyx']),
Extension('rmgpy.kinetics.model', ['rmgpy/kinetics/model.pyx']),
Extension('rmgpy.kinetics.tunneling', ['rmgpy/kinetics/tunneling.pyx']),
Extension('rmgpy.kinetics.surface', ['rmgpy/kinetics/surface.pyx']),
Extension('rmgpy.kinetics.uncertainties', ['rmgpy/kinetics/uncertainties.pyx']),
# Molecules and molecular representations
Extension('rmgpy.molecule.atomtype', ['rmgpy/molecule/atomtype.py'], include_dirs=['.']),
Extension('rmgpy.molecule.element', ['rmgpy/molecule/element.py'], include_dirs=['.']),
Extension('rmgpy.molecule.graph', ['rmgpy/molecule/graph.pyx'], include_dirs=['.']),
Extension('rmgpy.molecule.group', ['rmgpy/molecule/group.py'], include_dirs=['.']),
Extension('rmgpy.molecule.molecule', ['rmgpy/molecule/molecule.py'], include_dirs=['.']),
Extension('rmgpy.molecule.symmetry', ['rmgpy/molecule/symmetry.py'], include_dirs=['.']),
Extension('rmgpy.molecule.vf2', ['rmgpy/molecule/vf2.pyx'], include_dirs=['.']),
Extension('rmgpy.molecule.converter', ['rmgpy/molecule/converter.py'], include_dirs=['.']),
Extension('rmgpy.molecule.translator', ['rmgpy/molecule/translator.py'], include_dirs=['.']),
Extension('rmgpy.molecule.util', ['rmgpy/molecule/util.py'], include_dirs=['.']),
Extension('rmgpy.molecule.inchi', ['rmgpy/molecule/inchi.py'], include_dirs=['.']),
Extension('rmgpy.molecule.resonance', ['rmgpy/molecule/resonance.py'], include_dirs=['.']),
Extension('rmgpy.molecule.pathfinder', ['rmgpy/molecule/pathfinder.py'], include_dirs=['.']),
Extension('rmgpy.molecule.kekulize', ['rmgpy/molecule/kekulize.pyx'], include_dirs=['.']),
# Pressure dependence
Extension('rmgpy.pdep.collision', ['rmgpy/pdep/collision.pyx']),
Extension('rmgpy.pdep.configuration', ['rmgpy/pdep/configuration.pyx']),
Extension('rmgpy.pdep.me', ['rmgpy/pdep/me.pyx']),
Extension('rmgpy.pdep.msc', ['rmgpy/pdep/msc.pyx']),
Extension('rmgpy.pdep.reaction', ['rmgpy/pdep/reaction.pyx']),
Extension('rmgpy.pdep.rs', ['rmgpy/pdep/rs.pyx']),
Extension('rmgpy.pdep.cse', ['rmgpy/pdep/cse.pyx']),
# Statistical mechanics
Extension('rmgpy.statmech.conformer', ['rmgpy/statmech/conformer.pyx']),
Extension('rmgpy.statmech.mode', ['rmgpy/statmech/mode.pyx']),
Extension('rmgpy.statmech.rotation', ['rmgpy/statmech/rotation.pyx']),
Extension('rmgpy.statmech.schrodinger', ['rmgpy/statmech/schrodinger.pyx']),
Extension('rmgpy.statmech.torsion', ['rmgpy/statmech/torsion.pyx']),
Extension('rmgpy.statmech.translation', ['rmgpy/statmech/translation.pyx']),
Extension('rmgpy.statmech.vibration', ['rmgpy/statmech/vibration.pyx']),
# Thermodynamics
Extension('rmgpy.thermo.thermodata', ['rmgpy/thermo/thermodata.pyx']),
Extension('rmgpy.thermo.model', ['rmgpy/thermo/model.pyx']),
Extension('rmgpy.thermo.nasa', ['rmgpy/thermo/nasa.pyx']),
Extension('rmgpy.thermo.wilhoit', ['rmgpy/thermo/wilhoit.pyx']),
# Miscellaneous
Extension('rmgpy.constants', ['rmgpy/constants.py'], include_dirs=['.']),
Extension('rmgpy.quantity', ['rmgpy/quantity.py'], include_dirs=['.']),
Extension('rmgpy.reaction', ['rmgpy/reaction.py'], include_dirs=['.']),
Extension('rmgpy.species', ['rmgpy/species.py'], include_dirs=['.']),
Extension('rmgpy.chemkin', ['rmgpy/chemkin.pyx'], include_dirs=['.']),
]
solver_ext_modules = [
Extension('rmgpy.solver.base', ['rmgpy/solver/base.pyx'], include_dirs=['.']),
Extension('rmgpy.solver.simple', ['rmgpy/solver/simple.pyx'], include_dirs=['.']),
Extension('rmgpy.solver.liquid', ['rmgpy/solver/liquid.pyx'], include_dirs=['.']),
Extension('rmgpy.solver.mbSampled', ['rmgpy/solver/mbSampled.pyx'], include_dirs=['.']),
Extension('rmgpy.solver.surface', ['rmgpy/solver/surface.pyx'], include_dirs=['.']),
]
arkane_ext_modules = [
# RMG
Extension('rmgpy.rmgobject', ['rmgpy/rmgobject.pyx']),
# Kinetics
Extension('rmgpy.kinetics.arrhenius', ['rmgpy/kinetics/arrhenius.pyx']),
Extension('rmgpy.kinetics.chebyshev', ['rmgpy/kinetics/chebyshev.pyx']),
Extension('rmgpy.kinetics.kineticsdata', ['rmgpy/kinetics/kineticsdata.pyx']),
Extension('rmgpy.kinetics.falloff', ['rmgpy/kinetics/falloff.pyx']),
Extension('rmgpy.kinetics.model', ['rmgpy/kinetics/model.pyx']),
Extension('rmgpy.kinetics.tunneling', ['rmgpy/kinetics/tunneling.pyx']),
# Pressure dependence
Extension('rmgpy.pdep.collision', ['rmgpy/pdep/collision.pyx']),
Extension('rmgpy.pdep.configuration', ['rmgpy/pdep/configuration.pyx']),
Extension('rmgpy.pdep.me', ['rmgpy/pdep/me.pyx']),
Extension('rmgpy.pdep.msc', ['rmgpy/pdep/msc.pyx']),
Extension('rmgpy.pdep.reaction', ['rmgpy/pdep/reaction.pyx']),
Extension('rmgpy.pdep.rs', ['rmgpy/pdep/rs.pyx']),
Extension('rmgpy.pdep.cse', ['rmgpy/pdep/cse.pyx']),
# Statistical mechanics
Extension('rmgpy.statmech.conformer', ['rmgpy/statmech/conformer.pyx']),
Extension('rmgpy.statmech.mode', ['rmgpy/statmech/mode.pyx']),
Extension('rmgpy.statmech.rotation', ['rmgpy/statmech/rotation.pyx']),
Extension('rmgpy.statmech.schrodinger', ['rmgpy/statmech/schrodinger.pyx']),
Extension('rmgpy.statmech.torsion', ['rmgpy/statmech/torsion.pyx']),
Extension('rmgpy.statmech.translation', ['rmgpy/statmech/translation.pyx']),
Extension('rmgpy.statmech.vibration', ['rmgpy/statmech/vibration.pyx']),
# Thermodynamics
Extension('rmgpy.thermo.thermodata', ['rmgpy/thermo/thermodata.pyx']),
Extension('rmgpy.thermo.model', ['rmgpy/thermo/model.pyx']),
Extension('rmgpy.thermo.nasa', ['rmgpy/thermo/nasa.pyx']),
Extension('rmgpy.thermo.wilhoit', ['rmgpy/thermo/wilhoit.pyx']),
# Miscellaneous
Extension('rmgpy.constants', ['rmgpy/constants.py'], include_dirs=['.']),
Extension('rmgpy.quantity', ['rmgpy/quantity.py'], include_dirs=['.']),
]
################################################################################
ext_modules = []
if 'install' in sys.argv:
# This is so users can still do simply `python setup.py install`
ext_modules.extend(main_ext_modules)
ext_modules.extend(solver_ext_modules)
if 'main' in sys.argv:
# This is for `python setup.py build_ext main`
sys.argv.remove('main')
ext_modules.extend(main_ext_modules)
if 'solver' in sys.argv:
# This is for `python setup.py build_ext solver`
sys.argv.remove('solver')
ext_modules.extend(solver_ext_modules)
if 'arkane' in sys.argv:
# This is for `python setup.py build_ext arkane`
sys.argv.remove('arkane')
ext_modules.extend(main_ext_modules)
ext_modules.extend(arkane_ext_modules)
if 'minimal' in sys.argv:
# This starts with the full install list, but removes anything that has a pure python mode
# i.e. in only includes things whose source is .pyx
sys.argv.remove('minimal')
temporary_list = []
temporary_list.extend(main_ext_modules)
temporary_list.extend(solver_ext_modules)
for module in temporary_list:
for source in module.sources:
if os.path.splitext(source)[1] == '.pyx':
ext_modules.append(module)
# Remove duplicates while preserving order:
ext_modules = list(OrderedDict.fromkeys(ext_modules))
scripts = [
'Arkane.py',
'rmg.py',
'scripts/checkModels.py',
'scripts/diffModels.py',
'scripts/generateChemkinHTML.py',
'scripts/generateFluxDiagram.py',
'scripts/generateReactions.py',
'scripts/machineWriteDatabase.py',
'scripts/mergeModels.py',
'scripts/rmg2to3.py',
'scripts/simulate.py',
'scripts/standardizeModelSpeciesNames.py',
'scripts/thermoEstimator.py',
'scripts/isotopes.py',
'testing/databaseTest.py',
]
modules = []
for root, dirs, files in os.walk('rmgpy'):
if 'test_data' in root:
continue
for f in files:
if f.endswith('.py') or f.endswith('.pyx'):
if 'Test' not in f and '__init__' not in f:
module = 'rmgpy' + root.partition('rmgpy')[-1].replace('/', '.') + '.' + f.partition('.py')[0]
modules.append(module)
for root, dirs, files in os.walk('arkane'):
if 'data' in root:
continue
for f in files:
if f.endswith('.py') or f.endswith('.pyx'):
if 'Test' not in f and '__init__' not in f:
module = 'arkane' + root.partition('arkane')[-1].replace('/', '.') + '.' + f.partition('.py')[0]
modules.append(module)
# Read the version number
exec(open('rmgpy/version.py').read())
# Initiate the build and/or installation
setup(
name='RMG-Py',
version=__version__,
description='Reaction Mechanism Generator',
author='William H. Green and the RMG Team',
author_email='[email protected]',
url='http://reactionmechanismgenerator.github.io',
packages=['rmgpy', 'arkane'],
py_modules=modules,
scripts=scripts,
ext_modules=cythonize(ext_modules, build_dir='build', compiler_directives=directives),
include_dirs=['.', numpy.get_include()],
)