forked from manojgudi/sciscipy-1.0.0
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·123 lines (99 loc) · 4.22 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
#!/usr/bin/env python
from distutils.core import setup, Extension, Command
from unittest import TextTestRunner, TestLoader
from glob import glob
from os.path import splitext, basename, join as pjoin
import os, sys
# This should be customized for specific instals
if os.name == 'nt':
common_include_base = r"C:\Program Files (x86)\scilab-5.2.1\modules"
sci_include = [
os.path.join(common_include_base, "core", "includes"),
os.path.join(common_include_base, "call_scilab", "includes"),
os.path.join(common_include_base, "api_scilab", "includes")
]
sci_lib_dir = [r"C:\Program Files (x86)\scilab-5.2.1\bin"]
sci_librairies = ['LibScilab', 'api_scilab']
elif os.name == 'posix':
common_include_base = os.path.join("/","usr", "include", "scilab")
sci_include = [ common_include_base,
os.path.join(common_include_base, "core"),
os.path.join(common_include_base, "call_scilab")
]
sci_lib_dir = [os.path.join("/","usr", "lib", "scilab")]
sci_librairies = ['scilab']
sci_extra_link_args = ['-Wl,--no-as-needed -lpython2.7 -L/usr/lib/scilab -lsciapi_scilab -lscicall_scilab -lscioutput_stream -lscicore -lscilinear_algebra -lsciconsole -lscilocalization -lscipolynomials -lsciio -lscielementary_functions -lscisparse -lscihistory_manager -lscihistory_browser -lscigraphics -lscicompletion -lscifunctions -lsciboolean -lsciwindows_tools -lscitime -lscifftw -lsciintersci -lscidouble -lscicommons -lsciaction_binding -lscitclsci']
else:
raise NotImplementedError, "Only 'nt' and 'posix' are supported"
sci_sources = ['sciscipy.c', 'sciconv_read.c', 'sciconv_write.c', 'util.c']
if os.environ.get('SCI'):
common_include_base_call=os.path.join("/",os.environ.get('SCI'),"..","..","include","scilab")
sci_include.append(os.path.join("/", common_include_base_call))
sci_include.append(os.path.join("/", common_include_base_call, "core"))
sci_include.append(os.path.join("/",common_include_base_call, "call_scilab"))
sci_lib_dir.append(os.path.join("/",os.environ.get('SCI'),"..","..","lib","scilab"))
sci_install = os.path.join("/", "usr", "local", "share", "scilab")
list_of_macros = [('SCI', '"' + sci_install + '"'), ('SCIDEBUG', 0)]
# Test for python version
if sys.version_info[0] >= 3:
list_of_macros += [('PYTHON3', 1)]
# Test for numpy
try:
import numpy
import numpy.distutils.misc_util as misc
sci_include += os.path.join(misc.get_numpy_include_dirs())
numpy_is_avail = 1
sci_sources += ['deallocator.c']
except ImportError:
numpy_is_avail = 0
list_of_macros += [('NUMPY', numpy_is_avail)]
class TestCommand(Command):
user_options = [ ]
def initialize_options(self):
self._dir = os.getcwd()
def finalize_options(self):
pass
def run(self):
'''
Finds all the tests modules in test/, and runs them.
'''
testfiles = [ ]
for t in glob(pjoin(self._dir, 'tests', '*.py')):
if not t.endswith('__init__.py'):
testfiles.append('.'.join(
['tests', splitext(basename(t))[0]])
)
print(testfiles)
tests = TestLoader().loadTestsFromNames(testfiles)
t = TextTestRunner(verbosity = 2)
t.run(tests)
module1 = Extension('sciscipy',
sources = sci_sources,
include_dirs = sci_include,
libraries = sci_librairies,
library_dirs = sci_lib_dir,
extra_link_args = sci_extra_link_args,
define_macros = list_of_macros
)
long_description = r"""
The goal of sciscipy is to give an access to Scilab features inside python.
from scilab import Scilab
sci = Scilab()
x = sci.rand(20, 20)
y = x*x.transpose()
y_inv = sci.inv(y)
The function func in sci.func(x, y) can be a Scilab built-in or any user
defined function so that Scilab libraries can be reused easily in python.
"""
setup ( name = 'sciscipy',
version = '1.0.0',
author = 'Vincent Guffens <[email protected]>, Sylvestre Ledru <[email protected]>',
url = "http://forge.scilab.org/index.php/p/sciscipy/",
license = "GPL",
description = 'Scilab binding',
long_description = long_description,
ext_modules = [module1],
py_modules = ['scilab'],
data_files = [('share/sciscipy', ['scilab.cfg'])],
cmdclass = { 'test': TestCommand}
)