-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
executable file
·155 lines (105 loc) · 4.18 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2016 Adrian Bürger
#
# This file is part of casiopeia.
#
# casiopeia is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# casiopeia is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with casiopeia. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup
from codecs import open
from os import path, environ
from subprocess import call
from setuptools.command.install import install
# todo: check dependencies
# Custom install class to be able to check for CasADi installtion as well, see:
# http://stackoverflow.com/questions/21915469/python-setuptools-install-
# requires-is-ignored-when-overriding-cmdclass
class CustomInstall(install):
def run(self):
print("Checking for compatible CasADi installation ...")
try:
import casadi
except ImportError:
errmsg = '''
It seems that you are missing CasADi or it's Python interface, or the interface
cannot be found.
Please visit www.casadi.org for information on how to obtain CasADi and it's
Python interface for your system.
CasADi is distributed under the LGPL license, meaning the code can be used
royalty-free even in commercial applications.
'''
raise RuntimeError(errmsg)
casadi_version = casadi.CasadiMeta.getVersion()
if not float(casadi_version[:3]) == 3.1:
errmsg = '''
The version of CasADi found on your system is {0} != 3.1, and therefor
not suitable for use with casiopeia.
If you think that you have already installed a newer version of CasADi on your
system, it might not be found due to an older version that still remained
on the system.
Please visit www.casadi.org for information on how to update CasADi correctly
and how to handle these problems.
'''.format(casadi_version)
raise RuntimeError(errmsg)
print("--> Compatible CasADi installation found (version {0})."\
.format(casadi_version))
install.run(self)
# Get the long description from the README file, see:
# https://github.com/pypa/sampleproject/blob/master/setup.py
with open(path.join(path.abspath(path.dirname(__file__)), 'README.rst'), \
encoding='utf-8') as f:
long_description = f.read()
on_rtd = environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
setup(
name='casiopeia',
version='0.2.1',
author='Adrian Buerger',
author_email='[email protected]',
packages=['casiopeia', 'casiopeia.interfaces', \
'casiopeia.discretization'],
package_dir={'casiopeia': 'casiopeia'},
url='http://github.com/adbuerger/casiopeia/',
license='LGPL',
zip_safe=False,
description='Casadi Interface for Optimum experimental design and ' + \
'Parameter Estimation and Identification Applications',
long_description = long_description,
platforms = ["Linux"],
use_2to3=False,
)
else:
setup(
name='casiopeia',
version='0.2.1',
author='Adrian Buerger',
author_email='[email protected]',
packages=['casiopeia', 'casiopeia.interfaces', \
'casiopeia.discretization'],
package_dir={'casiopeia': 'casiopeia'},
url='http://github.com/adbuerger/casiopeia/',
license='LGPL',
zip_safe=False,
description='Casadi Interface for Optimum experimental design and ' + \
'Parameter Estimation and Identification Applications',
long_description = long_description,
install_requires=[
"numpy>=1.8.2",
"casadi==3.1.0",
],
platforms = ["Linux"],
use_2to3=False,
cmdclass={"install" : CustomInstall},
)