xnd 0.2.0dev3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +42 -0
- data/Gemfile +3 -0
- data/History.md +0 -0
- data/README.md +7 -0
- data/Rakefile +135 -0
- data/ext/ruby_xnd/extconf.rb +70 -0
- data/ext/ruby_xnd/float_pack_unpack.c +277 -0
- data/ext/ruby_xnd/float_pack_unpack.h +39 -0
- data/ext/ruby_xnd/gc_guard.c +36 -0
- data/ext/ruby_xnd/gc_guard.h +12 -0
- data/ext/ruby_xnd/include/xnd.h +449 -0
- data/ext/ruby_xnd/lib/libxnd.a +0 -0
- data/ext/ruby_xnd/lib/libxnd.so +1 -0
- data/ext/ruby_xnd/lib/libxnd.so.0 +1 -0
- data/ext/ruby_xnd/lib/libxnd.so.0.2.0dev3 +0 -0
- data/ext/ruby_xnd/memory_block_object.c +32 -0
- data/ext/ruby_xnd/memory_block_object.h +33 -0
- data/ext/ruby_xnd/ruby_xnd.c +1953 -0
- data/ext/ruby_xnd/ruby_xnd.h +61 -0
- data/ext/ruby_xnd/ruby_xnd_internal.h +85 -0
- data/ext/ruby_xnd/util.h +170 -0
- data/ext/ruby_xnd/xnd/AUTHORS.txt +5 -0
- data/ext/ruby_xnd/xnd/INSTALL.txt +134 -0
- data/ext/ruby_xnd/xnd/LICENSE.txt +29 -0
- data/ext/ruby_xnd/xnd/MANIFEST.in +3 -0
- data/ext/ruby_xnd/xnd/Makefile.in +80 -0
- data/ext/ruby_xnd/xnd/README.rst +44 -0
- data/ext/ruby_xnd/xnd/config.guess +1530 -0
- data/ext/ruby_xnd/xnd/config.h.in +22 -0
- data/ext/ruby_xnd/xnd/config.sub +1782 -0
- data/ext/ruby_xnd/xnd/configure +4867 -0
- data/ext/ruby_xnd/xnd/configure.ac +164 -0
- data/ext/ruby_xnd/xnd/doc/Makefile +14 -0
- data/ext/ruby_xnd/xnd/doc/_static/copybutton.js +66 -0
- data/ext/ruby_xnd/xnd/doc/conf.py +26 -0
- data/ext/ruby_xnd/xnd/doc/index.rst +44 -0
- data/ext/ruby_xnd/xnd/doc/libxnd/data-structures.rst +186 -0
- data/ext/ruby_xnd/xnd/doc/libxnd/functions.rst +148 -0
- data/ext/ruby_xnd/xnd/doc/libxnd/index.rst +25 -0
- data/ext/ruby_xnd/xnd/doc/releases/index.rst +34 -0
- data/ext/ruby_xnd/xnd/doc/xnd/align-pack.rst +96 -0
- data/ext/ruby_xnd/xnd/doc/xnd/buffer-protocol.rst +42 -0
- data/ext/ruby_xnd/xnd/doc/xnd/index.rst +30 -0
- data/ext/ruby_xnd/xnd/doc/xnd/quickstart.rst +62 -0
- data/ext/ruby_xnd/xnd/doc/xnd/types.rst +674 -0
- data/ext/ruby_xnd/xnd/install-sh +527 -0
- data/ext/ruby_xnd/xnd/libxnd/Makefile.in +102 -0
- data/ext/ruby_xnd/xnd/libxnd/Makefile.vc +112 -0
- data/ext/ruby_xnd/xnd/libxnd/bitmaps.c +345 -0
- data/ext/ruby_xnd/xnd/libxnd/contrib.h +313 -0
- data/ext/ruby_xnd/xnd/libxnd/copy.c +944 -0
- data/ext/ruby_xnd/xnd/libxnd/equal.c +1216 -0
- data/ext/ruby_xnd/xnd/libxnd/inline.h +154 -0
- data/ext/ruby_xnd/xnd/libxnd/overflow.h +147 -0
- data/ext/ruby_xnd/xnd/libxnd/split.c +286 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/Makefile.in +39 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/Makefile.vc +44 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/README.txt +2 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/runtest.c +101 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/test.h +48 -0
- data/ext/ruby_xnd/xnd/libxnd/tests/test_fixed.c +108 -0
- data/ext/ruby_xnd/xnd/libxnd/xnd.c +1304 -0
- data/ext/ruby_xnd/xnd/libxnd/xnd.h +449 -0
- data/ext/ruby_xnd/xnd/python/test_xnd.py +3144 -0
- data/ext/ruby_xnd/xnd/python/xnd/__init__.py +290 -0
- data/ext/ruby_xnd/xnd/python/xnd/_xnd.c +2822 -0
- data/ext/ruby_xnd/xnd/python/xnd/contrib/pretty.py +850 -0
- data/ext/ruby_xnd/xnd/python/xnd/docstrings.h +129 -0
- data/ext/ruby_xnd/xnd/python/xnd/pyxnd.h +200 -0
- data/ext/ruby_xnd/xnd/python/xnd/util.h +182 -0
- data/ext/ruby_xnd/xnd/python/xnd_randvalue.py +1121 -0
- data/ext/ruby_xnd/xnd/python/xnd_support.py +106 -0
- data/ext/ruby_xnd/xnd/setup.py +303 -0
- data/ext/ruby_xnd/xnd/vcbuild/INSTALL.txt +42 -0
- data/ext/ruby_xnd/xnd/vcbuild/runtest32.bat +16 -0
- data/ext/ruby_xnd/xnd/vcbuild/runtest64.bat +14 -0
- data/ext/ruby_xnd/xnd/vcbuild/vcbuild32.bat +29 -0
- data/ext/ruby_xnd/xnd/vcbuild/vcbuild64.bat +29 -0
- data/ext/ruby_xnd/xnd/vcbuild/vcclean.bat +13 -0
- data/ext/ruby_xnd/xnd/vcbuild/vcdistclean.bat +14 -0
- data/lib/ruby_xnd.so +0 -0
- data/lib/xnd.rb +306 -0
- data/lib/xnd/monkeys.rb +29 -0
- data/lib/xnd/version.rb +6 -0
- data/spec/debug_spec.rb +9 -0
- data/spec/gc_guard_spec.rb +10 -0
- data/spec/leakcheck.rb +9 -0
- data/spec/spec_helper.rb +877 -0
- data/spec/type_inference_spec.rb +81 -0
- data/spec/xnd_spec.rb +2921 -0
- data/xnd.gemspec +47 -0
- metadata +215 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#
|
|
2
|
+
# BSD 3-Clause License
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2018, plures
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions are met:
|
|
9
|
+
#
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer.
|
|
12
|
+
#
|
|
13
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
# and/or other materials provided with the distribution.
|
|
16
|
+
#
|
|
17
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
# contributors may be used to endorse or promote products derived from
|
|
19
|
+
# this software without specific prior written permission.
|
|
20
|
+
#
|
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
from collections import OrderedDict
|
|
34
|
+
import unittest
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Support for test_xnd.py.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# OrderedDict literals hack.
|
|
42
|
+
class Record(OrderedDict):
|
|
43
|
+
@staticmethod
|
|
44
|
+
def _kv(s):
|
|
45
|
+
if not isinstance(s, slice):
|
|
46
|
+
raise TypeError("expect key-value pair")
|
|
47
|
+
if s.step is not None:
|
|
48
|
+
raise ValueError("expect key-value pair")
|
|
49
|
+
return s.start, s.stop
|
|
50
|
+
def __getitem__(self, items):
|
|
51
|
+
if not isinstance(items, tuple):
|
|
52
|
+
items = (items,)
|
|
53
|
+
return OrderedDict(list(map(self._kv, items)))
|
|
54
|
+
|
|
55
|
+
R = Record()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# Broken classes.
|
|
59
|
+
class BoolMemoryError(object):
|
|
60
|
+
def __bool__(self):
|
|
61
|
+
raise MemoryError
|
|
62
|
+
|
|
63
|
+
class Index(object):
|
|
64
|
+
def __index__(self):
|
|
65
|
+
return 10
|
|
66
|
+
|
|
67
|
+
class IndexMemoryError(object):
|
|
68
|
+
def __index__(self):
|
|
69
|
+
raise MemoryError
|
|
70
|
+
|
|
71
|
+
class IndexTypeError(object):
|
|
72
|
+
def __index__(self):
|
|
73
|
+
return ""
|
|
74
|
+
|
|
75
|
+
def assertEqualWithEx(self, func, x, y):
|
|
76
|
+
if x.value is y is None:
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
xerr = None
|
|
80
|
+
try:
|
|
81
|
+
xres = func(x)
|
|
82
|
+
except Exception as e:
|
|
83
|
+
xerr = e.__class__
|
|
84
|
+
|
|
85
|
+
yerr = None
|
|
86
|
+
try:
|
|
87
|
+
yres = func(y)
|
|
88
|
+
except Exception as e:
|
|
89
|
+
yerr = e.__class__
|
|
90
|
+
|
|
91
|
+
if xerr is None is yerr:
|
|
92
|
+
self.assertEqual(xres, yres, msg="x: %s y: %s" % (x.type, y))
|
|
93
|
+
else:
|
|
94
|
+
self.assertEqual(xerr, yerr, msg="x: %s y: %s" % (x.type, y))
|
|
95
|
+
|
|
96
|
+
def skip_if(condition, reason):
|
|
97
|
+
if condition:
|
|
98
|
+
raise unittest.SkipTest(reason)
|
|
99
|
+
|
|
100
|
+
HAVE_64_BIT = sys.maxsize == 2**63-1
|
|
101
|
+
|
|
102
|
+
HAVE_PYTHON_36 = sys.version_info >= (3, 6, 0)
|
|
103
|
+
|
|
104
|
+
requires_py36 = unittest.skipUnless(
|
|
105
|
+
sys.version_info > (3, 6),
|
|
106
|
+
"test requires Python 3.6 or greater")
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
#
|
|
2
|
+
# BSD 3-Clause License
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2018, plures
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions are met:
|
|
9
|
+
#
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer.
|
|
12
|
+
#
|
|
13
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
# and/or other materials provided with the distribution.
|
|
16
|
+
#
|
|
17
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
# contributors may be used to endorse or promote products derived from
|
|
19
|
+
# this software without specific prior written permission.
|
|
20
|
+
#
|
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
import sys, os
|
|
34
|
+
|
|
35
|
+
if "bdist_wheel" in sys.argv:
|
|
36
|
+
from setuptools import setup, Extension
|
|
37
|
+
else:
|
|
38
|
+
from distutils.core import setup, Extension
|
|
39
|
+
|
|
40
|
+
from distutils.sysconfig import get_python_lib
|
|
41
|
+
from glob import glob
|
|
42
|
+
import platform
|
|
43
|
+
import subprocess
|
|
44
|
+
import shutil
|
|
45
|
+
import warnings
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
import sphinx.cmd
|
|
49
|
+
SPHINX_BUILD = "sphinx.cmd.build"
|
|
50
|
+
except:
|
|
51
|
+
SPHINX_BUILD = "sphinx"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
DESCRIPTION = """\
|
|
55
|
+
General container that maps a wide range of Python values directly to memory.\
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
LONG_DESCRIPTION = """
|
|
59
|
+
Overview
|
|
60
|
+
--------
|
|
61
|
+
|
|
62
|
+
The ``xnd`` module implements a container type that maps most Python values
|
|
63
|
+
relevant for scientific computing directly to typed memory.
|
|
64
|
+
|
|
65
|
+
Whenever possible, a single, pointer-free memory block is used.
|
|
66
|
+
|
|
67
|
+
``xnd`` supports ragged arrays, categorical types, indexing, slicing, aligned
|
|
68
|
+
memory blocks and type inference.
|
|
69
|
+
|
|
70
|
+
Operations like indexing and slicing return zero-copy typed views on the data.
|
|
71
|
+
|
|
72
|
+
Importing PEP-3118 buffers is supported.
|
|
73
|
+
|
|
74
|
+
Links
|
|
75
|
+
-----
|
|
76
|
+
|
|
77
|
+
* https://github.com/plures/
|
|
78
|
+
* http://ndtypes.readthedocs.io/en/latest/
|
|
79
|
+
* http://xnd.readthedocs.io/en/latest/
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
warnings.simplefilter("ignore", UserWarning)
|
|
84
|
+
|
|
85
|
+
if sys.platform == "darwin":
|
|
86
|
+
LIBNAME = "libxnd.dylib"
|
|
87
|
+
LIBSONAME = "libxnd.0.dylib"
|
|
88
|
+
LIBSHARED = "libxnd.0.2.0dev3.dylib"
|
|
89
|
+
else:
|
|
90
|
+
LIBNAME = "libxnd.so"
|
|
91
|
+
LIBSONAME = "libxnd.so.0"
|
|
92
|
+
LIBSHARED = "libxnd.so.0.2.0dev3"
|
|
93
|
+
LIBNDTYPES = "libndtypes.so.0.2.0dev3"
|
|
94
|
+
|
|
95
|
+
if "install" in sys.argv or "bdist_wheel" in sys.argv:
|
|
96
|
+
CONFIGURE_INCLUDES = "%s/ndtypes" % get_python_lib()
|
|
97
|
+
CONFIGURE_LIBS = CONFIGURE_INCLUDES
|
|
98
|
+
INCLUDES = LIBS = [CONFIGURE_INCLUDES]
|
|
99
|
+
LIBXNDDIR = "%s/xnd" % get_python_lib()
|
|
100
|
+
INSTALL_LIBS = True
|
|
101
|
+
elif "conda_install" in sys.argv:
|
|
102
|
+
site = "%s/ndtypes" % get_python_lib()
|
|
103
|
+
sys_includes = os.path.join(os.environ['PREFIX'], "include")
|
|
104
|
+
libdir = "Library/bin" if sys.platform == "win32" else "lib"
|
|
105
|
+
sys_libs = os.path.join(os.environ['PREFIX'], libdir)
|
|
106
|
+
CONFIGURE_INCLUDES = INCLUDES = [sys_includes, site]
|
|
107
|
+
LIBS = [sys_libs, site]
|
|
108
|
+
LIBXNDDIR = "%s/xnd" % get_python_lib()
|
|
109
|
+
INSTALL_LIBS = False
|
|
110
|
+
else:
|
|
111
|
+
CONFIGURE_INCLUDES = "../python/ndtypes"
|
|
112
|
+
CONFIGURE_LIBS = CONFIGURE_INCLUDES
|
|
113
|
+
INCLUDES = LIBS = [CONFIGURE_INCLUDES]
|
|
114
|
+
LIBXNDDIR = "../python/xnd"
|
|
115
|
+
INSTALL_LIBS = False
|
|
116
|
+
|
|
117
|
+
PY_MAJOR = sys.version_info[0]
|
|
118
|
+
PY_MINOR = sys.version_info[1]
|
|
119
|
+
ARCH = platform.architecture()[0]
|
|
120
|
+
BUILD_ALL = \
|
|
121
|
+
"build" in sys.argv or "install" in sys.argv or "bdist_wheel" in sys.argv
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if PY_MAJOR < 3:
|
|
125
|
+
raise NotImplementedError(
|
|
126
|
+
"python2 support is not implemented")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def get_module_path():
|
|
130
|
+
pathlist = glob("build/lib.*/")
|
|
131
|
+
if pathlist:
|
|
132
|
+
return pathlist[0]
|
|
133
|
+
raise RuntimeError("cannot find xnd module in build directory")
|
|
134
|
+
|
|
135
|
+
def copy_ext():
|
|
136
|
+
if sys.platform == "win32":
|
|
137
|
+
pathlist = glob("build/lib.*/xnd/_xnd.*.pyd")
|
|
138
|
+
else:
|
|
139
|
+
pathlist = glob("build/lib.*/xnd/_xnd.*.so")
|
|
140
|
+
if pathlist:
|
|
141
|
+
shutil.copy2(pathlist[0], "python/xnd")
|
|
142
|
+
|
|
143
|
+
def make_symlinks():
|
|
144
|
+
os.chdir(LIBXNDDIR)
|
|
145
|
+
os.chmod(LIBSHARED, 0o755)
|
|
146
|
+
os.system("ln -sf %s %s" % (LIBSHARED, LIBSONAME))
|
|
147
|
+
os.system("ln -sf %s %s" % (LIBSHARED, LIBNAME))
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
if len(sys.argv) == 3 and sys.argv[1] == "install" and \
|
|
151
|
+
sys.argv[2].startswith("--local"):
|
|
152
|
+
localdir = sys.argv[2].split("=")[1]
|
|
153
|
+
sys.argv = sys.argv[:2] + [
|
|
154
|
+
"--install-base=" + localdir,
|
|
155
|
+
"--install-purelib=" + localdir,
|
|
156
|
+
"--install-platlib=" + localdir,
|
|
157
|
+
"--install-scripts=" + localdir,
|
|
158
|
+
"--install-data=" + localdir,
|
|
159
|
+
"--install-headers=" + localdir]
|
|
160
|
+
|
|
161
|
+
LIBNDTYPESDIR = "%s/ndtypes" % localdir
|
|
162
|
+
CONFIGURE_INCLUDES = "%s/ndtypes" % localdir
|
|
163
|
+
CONFIGURE_LIBS = CONFIGURE_INCLUDES
|
|
164
|
+
INCLUDES = LIBS = [CONFIGURE_INCLUDES]
|
|
165
|
+
LIBXNDDIR = "%s/xnd" % localdir
|
|
166
|
+
INSTALL_LIBS = True
|
|
167
|
+
|
|
168
|
+
if sys.platform == "darwin": # homebrew bug
|
|
169
|
+
sys.argv.append("--prefix=")
|
|
170
|
+
|
|
171
|
+
elif len(sys.argv) == 2:
|
|
172
|
+
if sys.argv[1] == 'module':
|
|
173
|
+
sys.argv[1] = 'build'
|
|
174
|
+
if sys.argv[1] == 'module_install' or sys.argv[1] == 'conda_install':
|
|
175
|
+
sys.argv[1] = 'install'
|
|
176
|
+
if sys.argv[1] == 'test':
|
|
177
|
+
module_path = get_module_path()
|
|
178
|
+
python_path = os.getenv('PYTHONPATH')
|
|
179
|
+
path = module_path + ':' + python_path if python_path else module_path
|
|
180
|
+
env = os.environ.copy()
|
|
181
|
+
env['PYTHONPATH'] = path
|
|
182
|
+
ret = subprocess.call([sys.executable, "python/test_xnd.py", "--long"], env=env)
|
|
183
|
+
sys.exit(ret)
|
|
184
|
+
elif sys.argv[1] == 'doctest':
|
|
185
|
+
os.chdir("doc")
|
|
186
|
+
module_path = '../python'
|
|
187
|
+
python_path = os.getenv('PYTHONPATH')
|
|
188
|
+
path = module_path + ':' + python_path if python_path else module_path
|
|
189
|
+
env = os.environ.copy()
|
|
190
|
+
env['PYTHONPATH'] = path
|
|
191
|
+
cmd = [sys.executable, "-m", SPHINX_BUILD,
|
|
192
|
+
"-b", "doctest", "-d", "build/doctrees", ".", "build/html"]
|
|
193
|
+
ret = subprocess.call(cmd, env=env)
|
|
194
|
+
sys.exit(ret)
|
|
195
|
+
elif sys.argv[1] == 'clean':
|
|
196
|
+
shutil.rmtree("build", ignore_errors=True)
|
|
197
|
+
os.chdir("python/xnd")
|
|
198
|
+
shutil.rmtree("__pycache__", ignore_errors=True)
|
|
199
|
+
for f in glob("_xnd*.so"):
|
|
200
|
+
os.remove(f)
|
|
201
|
+
sys.exit(0)
|
|
202
|
+
elif sys.argv[1] == 'distclean':
|
|
203
|
+
if sys.platform == "win32":
|
|
204
|
+
os.chdir("vcbuild")
|
|
205
|
+
os.system("vcdistclean.bat")
|
|
206
|
+
else:
|
|
207
|
+
os.system("make distclean")
|
|
208
|
+
sys.exit(0)
|
|
209
|
+
else:
|
|
210
|
+
pass
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def xnd_ext():
|
|
214
|
+
include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES
|
|
215
|
+
library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS
|
|
216
|
+
depends = ["libxnd/xnd.h", "python/xnd/util.h", "python/xnd/pyxnd.h"]
|
|
217
|
+
sources = ["python/xnd/_xnd.c"]
|
|
218
|
+
|
|
219
|
+
if sys.platform == "win32":
|
|
220
|
+
libraries = ["libndtypes-0.2.0dev3.dll", "libxnd-0.2.0dev3.dll"]
|
|
221
|
+
extra_compile_args = ["/DXND_IMPORT"]
|
|
222
|
+
extra_link_args = []
|
|
223
|
+
runtime_library_dirs = []
|
|
224
|
+
|
|
225
|
+
if BUILD_ALL:
|
|
226
|
+
from distutils.msvc9compiler import MSVCCompiler
|
|
227
|
+
MSVCCompiler().initialize()
|
|
228
|
+
os.chdir("vcbuild")
|
|
229
|
+
os.environ['LIBNDTYPESINCLUDE'] = os.path.normpath(CONFIGURE_INCLUDES)
|
|
230
|
+
os.environ['LIBNDTYPESDIR'] = os.path.normpath(CONFIGURE_LIBS)
|
|
231
|
+
if ARCH == "64bit":
|
|
232
|
+
os.system("vcbuild64.bat")
|
|
233
|
+
else:
|
|
234
|
+
os.system("vcbuild32.bat")
|
|
235
|
+
os.chdir("..")
|
|
236
|
+
|
|
237
|
+
else:
|
|
238
|
+
extra_compile_args = ["-Wextra", "-Wno-missing-field-initializers", "-std=c11"]
|
|
239
|
+
if sys.platform == "darwin":
|
|
240
|
+
libraries = ["ndtypes", "xnd"]
|
|
241
|
+
extra_link_args = ["-Wl,-rpath,@loader_path"]
|
|
242
|
+
runtime_library_dirs = []
|
|
243
|
+
else:
|
|
244
|
+
libraries = [":%s" % LIBNDTYPES, ":%s" % LIBSHARED]
|
|
245
|
+
extra_link_args = []
|
|
246
|
+
runtime_library_dirs = ["$ORIGIN"]
|
|
247
|
+
|
|
248
|
+
if BUILD_ALL:
|
|
249
|
+
os.system(
|
|
250
|
+
"./configure --with-includes='%s' --with-libs='%s' && make" %
|
|
251
|
+
(CONFIGURE_INCLUDES, CONFIGURE_LIBS))
|
|
252
|
+
|
|
253
|
+
return Extension (
|
|
254
|
+
"xnd._xnd",
|
|
255
|
+
include_dirs = include_dirs,
|
|
256
|
+
library_dirs = library_dirs,
|
|
257
|
+
depends = depends,
|
|
258
|
+
sources = sources,
|
|
259
|
+
libraries = libraries,
|
|
260
|
+
extra_compile_args = extra_compile_args,
|
|
261
|
+
extra_link_args = extra_link_args,
|
|
262
|
+
runtime_library_dirs = runtime_library_dirs
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
setup (
|
|
266
|
+
name = "xnd",
|
|
267
|
+
version = "0.2.0dev3",
|
|
268
|
+
description = DESCRIPTION,
|
|
269
|
+
long_description = LONG_DESCRIPTION,
|
|
270
|
+
url = "https://github.com/plures/xnd",
|
|
271
|
+
author = 'Stefan Krah',
|
|
272
|
+
author_email = 'skrah@bytereef.org',
|
|
273
|
+
license = "BSD License",
|
|
274
|
+
keywords = ["xnd", "array computing", "container", "memory blocks"],
|
|
275
|
+
platforms = ["Many"],
|
|
276
|
+
classifiers = [
|
|
277
|
+
"Development Status :: 4 - Beta",
|
|
278
|
+
"Intended Audience :: Developers",
|
|
279
|
+
"Intended Audience :: Education",
|
|
280
|
+
"Intended Audience :: End Users/Desktop",
|
|
281
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
282
|
+
"Intended Audience :: Science/Research",
|
|
283
|
+
"License :: OSI Approved :: BSD License",
|
|
284
|
+
"Programming Language :: C",
|
|
285
|
+
"Programming Language :: Python :: 3",
|
|
286
|
+
"Programming Language :: Python :: 3.6",
|
|
287
|
+
"Programming Language :: Python :: 3.7",
|
|
288
|
+
"Operating System :: OS Independent",
|
|
289
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
290
|
+
"Topic :: Software Development"
|
|
291
|
+
],
|
|
292
|
+
install_requires = ["ndtypes == v0.2.0dev3"],
|
|
293
|
+
package_dir = {"": "python"},
|
|
294
|
+
packages = ["xnd"],
|
|
295
|
+
package_data = {"xnd": ["libxnd*", "xnd.h", "pyxnd.h", "contrib/*"]
|
|
296
|
+
if INSTALL_LIBS else ["pyxnd.h", "contrib/*"]},
|
|
297
|
+
ext_modules = [xnd_ext()],
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
copy_ext()
|
|
301
|
+
|
|
302
|
+
if INSTALL_LIBS and sys.platform != "win32" and not "bdist_wheel" in sys.argv:
|
|
303
|
+
make_symlinks()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
libxnd build instructions for Visual Studio
|
|
4
|
+
===========================================
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Requirements
|
|
8
|
+
------------
|
|
9
|
+
|
|
10
|
+
- Visual Studio 2015 or later.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
64-bit build
|
|
14
|
+
------------
|
|
15
|
+
|
|
16
|
+
# Set the build environment
|
|
17
|
+
vcvarsall.bat x64
|
|
18
|
+
|
|
19
|
+
# Build: If successful, the static library, the dynamic library, the
|
|
20
|
+
# common header file and two executables for running the unit tests
|
|
21
|
+
# should be in the dist64 directory.
|
|
22
|
+
vcbuild64.bat
|
|
23
|
+
|
|
24
|
+
# Test
|
|
25
|
+
runtest64.bat
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
32-bit build
|
|
29
|
+
------------
|
|
30
|
+
|
|
31
|
+
# Set the build environment
|
|
32
|
+
vcvarsall.bat x86
|
|
33
|
+
|
|
34
|
+
# Build: If successful, the static library, the dynamic library, the
|
|
35
|
+
# common header file and two executables for running the unit tests
|
|
36
|
+
# should be in the dist32 directory.
|
|
37
|
+
vcbuild32.bat
|
|
38
|
+
|
|
39
|
+
# Test
|
|
40
|
+
runtest32.bat
|
|
41
|
+
|
|
42
|
+
|