Skip to content

Commit

Permalink
BLD: Adding spatial to Meson build (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 authored and rgommers committed Jul 3, 2021
1 parent 5a0772f commit 9bd7a92
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ scipy/sparse/sparsetools/csr_impl.h
scipy/sparse/sparsetools/other_impl.h
scipy/sparse/sparsetools/sparsetools_impl.h
scipy/spatial/ckdtree.cxx
scipy/spatial/ckdtree.cpp
scipy/spatial/ckdtree.h
scipy/spatial/_hausdorff.c
scipy/spatial/qhull.c
Expand Down
1 change: 1 addition & 0 deletions mesondev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ python -c "from scipy.sparse import csgraph as s; s.test()"
# python -c "from scipy import optimize as s; s.test()" # relies on sparse.linalg
# python -c "from scipy import stats as s; s.test()" # relies on spatial
# python -c "from scipy import special as s; s.test()" # relies on spatial
# python -c "from scipy import spatial as s; s.test()" # failing due to bug in scipy.linalg._decom_update
popd

# Notes:
Expand Down
1 change: 1 addition & 0 deletions scipy/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ subdir('stats')
subdir('fft')
subdir('_lib')
subdir('special')
subdir('spatial')
subdir('cluster')
subdir('constants')
subdir('fftpack')
Expand Down
120 changes: 120 additions & 0 deletions scipy/spatial/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
_spatial_pxd = custom_target('_spatial_pxd',
output : ['qhull.pxd', 'setlist.pxd'],
input : ['qhull.pxd', 'setlist.pxd'],
command : ['cp', '@INPUT@', '-t', '@OUTDIR@'],
)

qhull_src = ['qhull_src/src/poly_r.c',
'qhull_src/src/stat_r.c',
'qhull_src/src/merge_r.c',
'qhull_src/src/userprintf_r.c',
'qhull_src/src/userprintf_rbox_r.c',
'qhull_src/src/usermem_r.c',
'qhull_src/src/geom_r.c',
'qhull_src/src/libqhull_r.c',
'qhull_src/src/user_r.c',
'qhull_src/src/random_r.c',
'qhull_src/src/geom2_r.c',
'qhull_src/src/mem_r.c',
'qhull_src/src/global_r.c',
'qhull_src/src/poly2_r.c',
'qhull_src/src/io_r.c',
'qhull_src/src/rboxlib_r.c',
'qhull_src/src/qset_r.c']

qhull = py3.extension_module('qhull',
['qhull.pyx', 'qhull_misc.h', 'qhull_misc.c'] + qhull_src,
c_args: '-Wno-cpp',
include_directories: [incdir_numpy, '../_lib', '../_build_utils/src', 'qhull_src/src'],
dependencies: [py3_dep, lapack],
install : true,
subdir : 'scipy/spatial')

ckdtree_src = ['ckdtree/src/query.cxx',
'ckdtree/src/build.cxx',
'ckdtree/src/query_pairs.cxx',
'ckdtree/src/count_neighbors.cxx',
'ckdtree/src/query_ball_point.cxx',
'ckdtree/src/query_ball_tree.cxx',
'ckdtree/src/sparse_distances.cxx']

ckdtree_cpp = custom_target('ckdtree_cpp',
output : 'ckdtree.cpp',
input : 'ckdtree.pyx',
command : [cython, '--cplus', '-3', '--fast-fail', '@INPUT@', '-o', '@OUTPUT@']
)

cpp_args = []
compiler = meson.get_compiler('cpp')
if compiler.get_id() == 'msvc'
cpp_args = cpp_args + ['/EHsc']
elif compiler.has_argument('-fvisibility=hidden')
cpp_args = cpp_args + ['-fvisibility=hidden']
endif

ckdtree = py3.extension_module('ckdtree',
ckdtree_src + [ckdtree_cpp],
cpp_args: cpp_args + ['-Wno-cpp'], # TODO: replace with numpy_nodepr_api
include_directories: [incdir_numpy, '../_lib', '../_build_utils/src', 'ckdtree/src'],
dependencies: [py3_dep],
install : true,
subdir : 'scipy/spatial')

_distance_wrap = py3.extension_module('_distance_wrap',
'src/distance_wrap.c',
c_args: '-Wno-cpp', # TODO: replace with numpy_nodepr_api
include_directories: [incdir_numpy, '../_lib'],
dependencies: [py3_dep, npymath_lib],
install : true,
subdir : 'scipy/spatial')

_distance_pybind = py3.extension_module('_distance_pybind',
['src/distance_pybind.cpp'],
cpp_args: cpp_args + [numpy_nodepr_api],
include_directories: [incdir_pybind11, incdir_numpy, 'src/'],
dependencies: [py3_dep],
install : true,
subdir : 'scipy/spatial')

_voronoi = py3.extension_module('_voronoi',
['_voronoi.pyx'],
c_args: numpy_nodepr_api,
include_directories: [incdir_numpy],
dependencies: [py3_dep],
install : true,
subdir : 'scipy/spatial')

_hausdorff = py3.extension_module('_hausdorff',
['_hausdorff.pyx'],
c_args: numpy_nodepr_api,
include_directories: [incdir_numpy],
dependencies: [py3_dep],
install : true,
subdir : 'scipy/spatial')

py3.install_sources(['qhull_src/COPYING.txt'],
pure: false,
subdir: 'scipy/spatial/qhull_src'
)

py3.install_sources(['qhull.pyi',
'_voronoi.pyi',
'ckdtree.pyi',
'distance.pyi'],
pure: false,
subdir: 'scipy/spatial'
)

py3.install_sources(['__init__.py',
'distance.py',
'_geometric_slerp.py',
'_procrustes.py',
'kdtree.py',
'_spherical_voronoi.py',
'_plotutils.py'],
pure: false,
subdir: 'scipy/spatial'
)

subdir('tests')
subdir('transform')
47 changes: 47 additions & 0 deletions scipy/spatial/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
py3.install_sources(['__init__.py',
'test__plotutils.py',
'test_kdtree.py',
'test_hausdorff.py',
'test__procrustes.py',
'test_spherical_voronoi.py',
'test_slerp.py',
'test_distance.py',
'test_qhull.py'],
pure: false,
subdir: 'scipy/spatial/tests'
)

py3.install_sources(['data/pdist-spearman-ml.txt',
'data/pdist-boolean-inp.txt',
'data/pdist-minkowski-5.8-ml-iris.txt',
'data/selfdual-4d-polytope.txt',
'data/pdist-euclidean-ml-iris.txt',
'data/pdist-correlation-ml.txt',
'data/pdist-double-inp.txt',
'data/random-uint-data.txt',
'data/random-bool-data.txt',
'data/iris.txt',
'data/random-int-data.txt',
'data/pdist-jaccard-ml.txt',
'data/pdist-seuclidean-ml.txt',
'data/pdist-euclidean-ml.txt',
'data/pdist-cosine-ml.txt',
'data/pdist-chebyshev-ml.txt',
'data/pdist-minkowski-3.2-ml.txt',
'data/pdist-cityblock-ml.txt',
'data/pdist-seuclidean-ml-iris.txt',
'data/pdist-jensenshannon-ml.txt',
'data/cdist-X1.txt',
'data/pdist-chebyshev-ml-iris.txt',
'data/degenerate_pointset.npz',
'data/pdist-correlation-ml-iris.txt',
'data/pdist-minkowski-3.2-ml-iris.txt',
'data/pdist-hamming-ml.txt',
'data/random-double-data.txt',
'data/cdist-X2.txt',
'data/pdist-cosine-ml-iris.txt',
'data/pdist-jensenshannon-ml-iris.txt',
'data/pdist-cityblock-ml-iris.txt'],
pure: false,
subdir: 'scipy/spatial/tests/data'
)
24 changes: 24 additions & 0 deletions scipy/spatial/transform/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
rotation = py3.extension_module('rotation',
['rotation.pyx'],
c_args: '-Wno-cpp', # TODO: replace with numpy_nodepr_api
include_directories: [incdir_numpy],
dependencies: [py3_dep],
install: true,
subdir: 'scipy/spatial/transform')

py3.install_sources(
'rotation.pyi',
pure: false,
subdir: 'scipy/spatial/transform'
)

py3.install_sources(
['__init__.py',
'_rotation_groups.py',
'_rotation_spline.py'
],
pure: false,
subdir: 'scipy/spatial/transform'
)

subdir('tests')
7 changes: 7 additions & 0 deletions scipy/spatial/transform/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
py3.install_sources(['__init__.py',
'test_rotation.py',
'test_rotation_groups.py',
'test_rotation_spline.py'],
pure: false,
subdir: 'scipy/spatial/transform/tests'
)

0 comments on commit 9bd7a92

Please sign in to comment.