From d181acfa800c7897dfd994404dda6dfde130bd3f Mon Sep 17 00:00:00 2001 From: DylanHsu Date: Mon, 10 Feb 2025 15:47:14 -0500 Subject: [PATCH 1/2] change type of "shape" variable, in method "interpolate", to explicit dtype np.int_ (was string 'int64') causing buffer dtype mismatch --- surfa/image/interp.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfa/image/interp.pyx b/surfa/image/interp.pyx index 235bb7c..f1980a8 100644 --- a/surfa/image/interp.pyx +++ b/surfa/image/interp.pyx @@ -88,7 +88,7 @@ def interpolate(source, target_shape, method, affine=None, disp=None, fill=0): interp_func = globals().get(f'interp_3d_{order}_{method}') # speeds up if conditionals are computed outside of function (TODO is this even true?) - shape = np.asarray(target_shape).astype('int64') + shape = np.asarray(target_shape).astype(np.int_) # ensure correct byteorder # TODO maybe this should be done at read-time? From 8f716fcbb271d24618870e996ff6b523431e2024 Mon Sep 17 00:00:00 2001 From: DylanHsu Date: Mon, 10 Feb 2025 15:48:18 -0500 Subject: [PATCH 2/2] MSVC specific compiler flags for build on Windows --- setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index db5d771..0127a3e 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ import re import pathlib +import platform from setuptools import setup from setuptools import dist @@ -32,11 +33,15 @@ # we don't want to require cython for package install from # source distributions, like pypi installs, and the best way I # can think of to detect this is by checking if PKG-INFO exists -cython_build = not base_dir.joinpath('PKG-INFO').is_file() +cython_build = not base_dir.joinpath('PKG-INFO').is_file() or (platform.system() == 'Windows') # configure c extensions ext = 'pyx' if cython_build else 'c' -ext_opts = dict(extra_compile_args=['-O3', '-std=c99']) +if platform.system() == 'Windows': + ext_opts = dict(extra_compile_args=['/O2', '/std:c++17']) +else: + ext_opts = dict(extra_compile_args=['-O3', '-std=c99']) + extensions = [ Extension('surfa.image.interp', [f'surfa/image/interp.{ext}'], **ext_opts), Extension('surfa.mesh.intersection', [f'surfa/mesh/intersection.{ext}'], **ext_opts),