diff options
-rw-r--r-- | numpy/core/include/numpy/npy_math.h | 13 | ||||
-rw-r--r-- | numpy/core/setup.py | 6 | ||||
-rw-r--r-- | numpy/core/src/npymath/arm64_exports.c | 23 |
3 files changed, 38 insertions, 4 deletions
diff --git a/numpy/core/include/numpy/npy_math.h b/numpy/core/include/numpy/npy_math.h index 945bbb15b..d7c9fbb4f 100644 --- a/numpy/core/include/numpy/npy_math.h +++ b/numpy/core/include/numpy/npy_math.h @@ -184,21 +184,28 @@ NPY_INPLACE double npy_atan2(double x, double y); #define npy_fmod fmod #define npy_floor floor #define npy_expm1 expm1 -#define npy_log1p log1p #define npy_acosh acosh -#define npy_asinh asinh #define npy_atanh atanh #define npy_rint rint #define npy_trunc trunc #define npy_exp2 exp2 #define npy_frexp frexp #define npy_ldexp ldexp -#define npy_copysign copysign #define npy_exp exp #define npy_sqrt sqrt #define npy_pow pow #define npy_modf modf +#if defined(__arm64__) && defined(__APPLE__) +/* due to a build problem with scipy, export these as functions */ +NPY_INPLACE double npy_asinh(double x); +NPY_INPLACE double npy_copysign(double y, double x); +NPY_INPLACE double npy_log1p(double x); +#else +#define npy_asinh asinh +#define npy_copysign copysign +#define npy_log1p log1p +#endif double npy_nextafter(double x, double y); double npy_spacing(double x); diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 6f0a4417a..9a3b41637 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -776,7 +776,11 @@ def configuration(parent_package='',top_path=None): # join('src', 'npymath', 'ieee754.cpp'), join('src', 'npymath', 'ieee754.c.src'), join('src', 'npymath', 'npy_math_complex.c.src'), - join('src', 'npymath', 'halffloat.c') + join('src', 'npymath', 'halffloat.c'), + # Remove this once scipy macos arm64 build correctly + # links to the arm64 npymath library, + # see gh-22673 + join('src', 'npymath', 'arm64_exports.c'), ] config.add_installed_library('npymath', diff --git a/numpy/core/src/npymath/arm64_exports.c b/numpy/core/src/npymath/arm64_exports.c new file mode 100644 index 000000000..d65bb4f6d --- /dev/null +++ b/numpy/core/src/npymath/arm64_exports.c @@ -0,0 +1,23 @@ +#if defined(__arm64__) && defined(__APPLE__) + +#include <math.h> +/* + * Export these for scipy, since the SciPy build for macos arm64 + * downloads the macos x86_64 NumPy, and does not error when the + * linker fails to use npymathlib.a. Importing numpy will expose + * these external functions + * See https://github.com/numpy/numpy/issues/22673#issuecomment-1327520055 + */ + +double npy_asinh(double x) { + return asinh(x); +} + +double npy_copysign(double y, double x) { + return copysign(y, x); +} + +double npy_log1p(double x) { + return log1p(x); +} +#endif |