From 77b59140791123ab9cdd168117c375ecf8ae4d65 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 1 Apr 2024 09:52:40 -0600 Subject: [PATCH 1/5] MNT: add pythoncapi-compat as a git submodule --- .gitmodules | 3 +++ numpy/_core/src/common/pythoncapi-compat | 1 + 2 files changed, 4 insertions(+) create mode 160000 numpy/_core/src/common/pythoncapi-compat diff --git a/.gitmodules b/.gitmodules index 3934afe4500c..4aa48f5bac5c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "numpy/fft/pocketfft"] path = numpy/fft/pocketfft url = https://github.com/mreineck/pocketfft +[submodule "numpy/_core/src/common/pythoncapi-compat"] + path = numpy/_core/src/common/pythoncapi-compat + url = https://github.com/python/pythoncapi-compat diff --git a/numpy/_core/src/common/pythoncapi-compat b/numpy/_core/src/common/pythoncapi-compat new file mode 160000 index 000000000000..f66799130acd --- /dev/null +++ b/numpy/_core/src/common/pythoncapi-compat @@ -0,0 +1 @@ +Subproject commit f66799130acd8843802185553dadf0e300c5fe05 From 0ab2f25052f5c18106a8bd656b2417e8e7a9a743 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 1 Apr 2024 10:50:16 -0600 Subject: [PATCH 2/5] MNT: include pythoncapi_compat.h in npy_pycompat.h --- numpy/_core/src/common/npy_pycompat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/_core/src/common/npy_pycompat.h b/numpy/_core/src/common/npy_pycompat.h index ce6c34fa1333..67d4f6f625a0 100644 --- a/numpy/_core/src/common/npy_pycompat.h +++ b/numpy/_core/src/common/npy_pycompat.h @@ -2,7 +2,7 @@ #define NUMPY_CORE_SRC_COMMON_NPY_PYCOMPAT_H_ #include "numpy/npy_3kcompat.h" - +#include "pythoncapi-compat/pythoncapi_compat.h" /* * In Python 3.10a7 (or b1), python started using the identity for the hash From 917e4b039c3f44c8e3e09b624e3f447022c41e02 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 1 Apr 2024 10:50:35 -0600 Subject: [PATCH 3/5] MNT: remove unnecessary npy_pycompat.h includes --- numpy/_core/src/common/array_assign.c | 2 +- numpy/_core/src/common/npy_argparse.c | 5 +++-- numpy/_core/src/common/npy_longdouble.c | 2 +- numpy/_core/src/common/numpyos.c | 2 +- numpy/_core/src/common/ucsnarrow.c | 2 +- numpy/_core/src/common/ufunc_override.c | 2 +- numpy/_core/src/dummymodule.c | 2 -- numpy/_core/src/multiarray/_multiarray_tests.c.src | 2 +- numpy/_core/src/multiarray/array_assign_array.c | 2 +- numpy/_core/src/multiarray/array_assign_scalar.c | 2 +- numpy/_core/src/multiarray/array_converter.c | 2 +- numpy/_core/src/multiarray/arrayfunction_override.c | 2 +- numpy/_core/src/multiarray/calculation.c | 2 +- numpy/_core/src/multiarray/common.c | 2 +- numpy/_core/src/multiarray/conversion_utils.c | 2 +- numpy/_core/src/multiarray/convert.c | 2 +- numpy/_core/src/multiarray/ctors.c | 2 +- numpy/_core/src/multiarray/datetime.c | 2 +- numpy/_core/src/multiarray/datetime_busday.c | 2 +- numpy/_core/src/multiarray/datetime_busdaycal.c | 2 +- numpy/_core/src/multiarray/datetime_strings.c | 2 +- numpy/_core/src/multiarray/descriptor.c | 2 +- numpy/_core/src/multiarray/dragon4.h | 2 +- numpy/_core/src/multiarray/dtype_transfer.c | 2 +- numpy/_core/src/multiarray/dtypemeta.c | 2 +- numpy/_core/src/multiarray/einsum.c.src | 2 +- numpy/_core/src/multiarray/flagsobject.c | 2 +- numpy/_core/src/multiarray/getset.c | 2 +- numpy/_core/src/multiarray/hashdescr.c | 2 +- numpy/_core/src/multiarray/item_selection.c | 2 +- numpy/_core/src/multiarray/iterators.c | 2 +- numpy/_core/src/multiarray/nditer_impl.h | 2 +- numpy/_core/src/multiarray/nditer_pywrap.c | 2 +- numpy/_core/src/multiarray/number.c | 2 +- numpy/_core/src/multiarray/refcount.c | 2 +- numpy/_core/src/multiarray/scalarapi.c | 2 +- numpy/_core/src/multiarray/sequence.c | 2 +- numpy/_core/src/multiarray/shape.c | 2 +- numpy/_core/src/multiarray/usertypes.c | 2 +- numpy/_core/src/umath/_umath_tests.c.src | 2 +- numpy/_core/src/umath/extobj.c | 2 +- numpy/_core/src/umath/funcs.inc.src | 2 +- numpy/_core/src/umath/matmul.c.src | 2 +- numpy/_core/src/umath/override.c | 4 ++-- numpy/_core/src/umath/reduction.c | 2 +- numpy/_core/src/umath/scalarmath.c.src | 2 +- numpy/_core/src/umath/ufunc_object.c | 2 +- numpy/_core/src/umath/ufunc_type_resolution.c | 4 +++- numpy/linalg/umath_linalg.cpp | 2 -- 49 files changed, 52 insertions(+), 53 deletions(-) diff --git a/numpy/_core/src/common/array_assign.c b/numpy/_core/src/common/array_assign.c index 4e154b7fc7b0..3c6d2f14cb65 100644 --- a/numpy/_core/src/common/array_assign.c +++ b/numpy/_core/src/common/array_assign.c @@ -15,7 +15,7 @@ #include #include "npy_config.h" -#include "npy_pycompat.h" + #include "shape.h" diff --git a/numpy/_core/src/common/npy_argparse.c b/numpy/_core/src/common/npy_argparse.c index 59858f6207bb..2be17483ec28 100644 --- a/numpy/_core/src/common/npy_argparse.c +++ b/numpy/_core/src/common/npy_argparse.c @@ -5,8 +5,9 @@ #include #include "numpy/ndarraytypes.h" +#include "numpy/npy_2_compat.h" #include "npy_argparse.h" -#include "npy_pycompat.h" + #include "npy_import.h" #include "arrayfunction_override.h" @@ -195,7 +196,7 @@ initialize_keywords(const char *funcname, } if (i >= npositional_only) { int i_kwarg = i - npositional_only; - cache->kw_strings[i_kwarg] = PyUString_InternFromString(name); + cache->kw_strings[i_kwarg] = PyUnicode_InternFromString(name); if (cache->kw_strings[i_kwarg] == NULL) { va_end(va); goto error; diff --git a/numpy/_core/src/common/npy_longdouble.c b/numpy/_core/src/common/npy_longdouble.c index 38dfd325c685..ce80a9ae2bc3 100644 --- a/numpy/_core/src/common/npy_longdouble.c +++ b/numpy/_core/src/common/npy_longdouble.c @@ -6,7 +6,7 @@ #include "numpy/ndarraytypes.h" #include "numpy/npy_math.h" -#include "npy_pycompat.h" + #include "numpyos.h" /* diff --git a/numpy/_core/src/common/numpyos.c b/numpy/_core/src/common/numpyos.c index fb69e2587ee9..319f5dcc395f 100644 --- a/numpy/_core/src/common/numpyos.c +++ b/numpy/_core/src/common/numpyos.c @@ -9,7 +9,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #if defined(HAVE_STRTOLD_L) && !defined(_GNU_SOURCE) # define _GNU_SOURCE diff --git a/numpy/_core/src/common/ucsnarrow.c b/numpy/_core/src/common/ucsnarrow.c index 4bea4beee384..203e02fbb3dd 100644 --- a/numpy/_core/src/common/ucsnarrow.c +++ b/numpy/_core/src/common/ucsnarrow.c @@ -9,7 +9,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "ctors.h" /* diff --git a/numpy/_core/src/common/ufunc_override.c b/numpy/_core/src/common/ufunc_override.c index 4fb4d4b3edda..c9b5d0e68f82 100644 --- a/numpy/_core/src/common/ufunc_override.c +++ b/numpy/_core/src/common/ufunc_override.c @@ -1,7 +1,7 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -#include "npy_pycompat.h" +#include "numpy/ndarraytypes.h" #include "get_attr_string.h" #include "npy_import.h" #include "ufunc_override.h" diff --git a/numpy/_core/src/dummymodule.c b/numpy/_core/src/dummymodule.c index 7284ffd68545..2f293d6c4cd6 100644 --- a/numpy/_core/src/dummymodule.c +++ b/numpy/_core/src/dummymodule.c @@ -10,8 +10,6 @@ #define PY_SSIZE_T_CLEAN #include -#include "npy_pycompat.h" - static struct PyMethodDef methods[] = { {NULL, NULL, 0, NULL} }; diff --git a/numpy/_core/src/multiarray/_multiarray_tests.c.src b/numpy/_core/src/multiarray/_multiarray_tests.c.src index 606405dbfdda..7ce182c2343f 100644 --- a/numpy/_core/src/multiarray/_multiarray_tests.c.src +++ b/numpy/_core/src/multiarray/_multiarray_tests.c.src @@ -58,7 +58,7 @@ IsPythonScalar(PyObject * dummy, PyObject *args) } } -#include "npy_pycompat.h" + /** Function to test calling via ctypes */ diff --git a/numpy/_core/src/multiarray/array_assign_array.c b/numpy/_core/src/multiarray/array_assign_array.c index 687757190d00..8886d1cacb40 100644 --- a/numpy/_core/src/multiarray/array_assign_array.c +++ b/numpy/_core/src/multiarray/array_assign_array.c @@ -17,7 +17,7 @@ #include "numpy/npy_math.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "convert_datatype.h" #include "methods.h" diff --git a/numpy/_core/src/multiarray/array_assign_scalar.c b/numpy/_core/src/multiarray/array_assign_scalar.c index d1919fafb4bd..6818c1aa2a1b 100644 --- a/numpy/_core/src/multiarray/array_assign_scalar.c +++ b/numpy/_core/src/multiarray/array_assign_scalar.c @@ -17,7 +17,7 @@ #include "numpy/npy_math.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "convert_datatype.h" #include "methods.h" diff --git a/numpy/_core/src/multiarray/array_converter.c b/numpy/_core/src/multiarray/array_converter.c index fd7ccd767056..22e4e8bb3cb9 100644 --- a/numpy/_core/src/multiarray/array_converter.c +++ b/numpy/_core/src/multiarray/array_converter.c @@ -26,7 +26,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "array_assign.h" #include "common.h" diff --git a/numpy/_core/src/multiarray/arrayfunction_override.c b/numpy/_core/src/multiarray/arrayfunction_override.c index 707024f94c04..20223e1449fb 100644 --- a/numpy/_core/src/multiarray/arrayfunction_override.c +++ b/numpy/_core/src/multiarray/arrayfunction_override.c @@ -4,7 +4,7 @@ #include #include "structmember.h" -#include "npy_pycompat.h" +#include "numpy/ndarraytypes.h" #include "get_attr_string.h" #include "npy_import.h" #include "multiarraymodule.h" diff --git a/numpy/_core/src/multiarray/calculation.c b/numpy/_core/src/multiarray/calculation.c index 73d8ba58bd05..cf77ce90902d 100644 --- a/numpy/_core/src/multiarray/calculation.c +++ b/numpy/_core/src/multiarray/calculation.c @@ -11,7 +11,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "common.h" #include "number.h" diff --git a/numpy/_core/src/multiarray/common.c b/numpy/_core/src/multiarray/common.c index 5804c9cc9148..20495a0585be 100644 --- a/numpy/_core/src/multiarray/common.c +++ b/numpy/_core/src/multiarray/common.c @@ -7,7 +7,7 @@ #include "numpy/arrayobject.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "common.h" #include "abstractdtypes.h" diff --git a/numpy/_core/src/multiarray/conversion_utils.c b/numpy/_core/src/multiarray/conversion_utils.c index d58fee3823ee..ac1fb3ae38dc 100644 --- a/numpy/_core/src/multiarray/conversion_utils.c +++ b/numpy/_core/src/multiarray/conversion_utils.c @@ -10,7 +10,7 @@ #include "numpy/npy_math.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "common.h" #include "arraytypes.h" diff --git a/numpy/_core/src/multiarray/convert.c b/numpy/_core/src/multiarray/convert.c index c6b164d7f4e9..aad40cab9593 100644 --- a/numpy/_core/src/multiarray/convert.c +++ b/numpy/_core/src/multiarray/convert.c @@ -9,7 +9,7 @@ #include "numpy/arrayobject.h" #include "numpy/arrayscalars.h" -#include "npy_pycompat.h" + #include "common.h" #include "arrayobject.h" diff --git a/numpy/_core/src/multiarray/ctors.c b/numpy/_core/src/multiarray/ctors.c index 4c9d76991296..324027659f52 100644 --- a/numpy/_core/src/multiarray/ctors.c +++ b/numpy/_core/src/multiarray/ctors.c @@ -14,7 +14,7 @@ #include "npy_config.h" #include "npy_ctypes.h" -#include "npy_pycompat.h" + #include "multiarraymodule.h" #include "common.h" diff --git a/numpy/_core/src/multiarray/datetime.c b/numpy/_core/src/multiarray/datetime.c index b340cf6cf496..474c048db6cf 100644 --- a/numpy/_core/src/multiarray/datetime.c +++ b/numpy/_core/src/multiarray/datetime.c @@ -16,7 +16,7 @@ #include "numpyos.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "common.h" #include "numpy/arrayscalars.h" diff --git a/numpy/_core/src/multiarray/datetime_busday.c b/numpy/_core/src/multiarray/datetime_busday.c index 93ed0972ec98..73c88811a0a9 100644 --- a/numpy/_core/src/multiarray/datetime_busday.c +++ b/numpy/_core/src/multiarray/datetime_busday.c @@ -15,7 +15,7 @@ #include #include "npy_config.h" -#include "npy_pycompat.h" + #include "numpy/arrayscalars.h" #include "lowlevel_strided_loops.h" diff --git a/numpy/_core/src/multiarray/datetime_busdaycal.c b/numpy/_core/src/multiarray/datetime_busdaycal.c index 880efe934c09..3a7e3a383dca 100644 --- a/numpy/_core/src/multiarray/datetime_busdaycal.c +++ b/numpy/_core/src/multiarray/datetime_busdaycal.c @@ -17,7 +17,7 @@ #include "numpy/arrayscalars.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "common.h" #include "lowlevel_strided_loops.h" diff --git a/numpy/_core/src/multiarray/datetime_strings.c b/numpy/_core/src/multiarray/datetime_strings.c index 090277e16939..f92eec3f5a59 100644 --- a/numpy/_core/src/multiarray/datetime_strings.c +++ b/numpy/_core/src/multiarray/datetime_strings.c @@ -16,7 +16,7 @@ #include "numpy/arrayobject.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "numpy/arrayscalars.h" #include "convert_datatype.h" diff --git a/numpy/_core/src/multiarray/descriptor.c b/numpy/_core/src/multiarray/descriptor.c index 8a8e432d82ee..94f40fb42ca0 100644 --- a/numpy/_core/src/multiarray/descriptor.c +++ b/numpy/_core/src/multiarray/descriptor.c @@ -13,7 +13,7 @@ #include "npy_config.h" #include "npy_ctypes.h" #include "npy_import.h" -#include "npy_pycompat.h" + #include "_datetime.h" #include "common.h" diff --git a/numpy/_core/src/multiarray/dragon4.h b/numpy/_core/src/multiarray/dragon4.h index 0e29c42e3c09..8986c1672e71 100644 --- a/numpy/_core/src/multiarray/dragon4.h +++ b/numpy/_core/src/multiarray/dragon4.h @@ -38,7 +38,7 @@ #define _MULTIARRAYMODULE #include "numpy/arrayobject.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "numpy/arrayscalars.h" /* Half binary format */ diff --git a/numpy/_core/src/multiarray/dtype_transfer.c b/numpy/_core/src/multiarray/dtype_transfer.c index 513b2e6be478..d7a5e80800b6 100644 --- a/numpy/_core/src/multiarray/dtype_transfer.c +++ b/numpy/_core/src/multiarray/dtype_transfer.c @@ -21,7 +21,7 @@ #include "numpy/npy_math.h" #include "lowlevel_strided_loops.h" -#include "npy_pycompat.h" + #include "convert_datatype.h" #include "ctors.h" diff --git a/numpy/_core/src/multiarray/dtypemeta.c b/numpy/_core/src/multiarray/dtypemeta.c index dd8ba326b98f..4aadfd902545 100644 --- a/numpy/_core/src/multiarray/dtypemeta.c +++ b/numpy/_core/src/multiarray/dtypemeta.c @@ -9,7 +9,7 @@ #include #include #include -#include "npy_pycompat.h" + #include "npy_import.h" #include "abstractdtypes.h" diff --git a/numpy/_core/src/multiarray/einsum.c.src b/numpy/_core/src/multiarray/einsum.c.src index cf84c5a7629c..81d3f3e1d79b 100644 --- a/numpy/_core/src/multiarray/einsum.c.src +++ b/numpy/_core/src/multiarray/einsum.c.src @@ -16,7 +16,7 @@ #define _MULTIARRAYMODULE #include #include -#include + #include //PyArray_AssignRawScalar #include diff --git a/numpy/_core/src/multiarray/flagsobject.c b/numpy/_core/src/multiarray/flagsobject.c index 4751b2a8bfed..8257727030c0 100644 --- a/numpy/_core/src/multiarray/flagsobject.c +++ b/numpy/_core/src/multiarray/flagsobject.c @@ -12,7 +12,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "array_assign.h" #include "common.h" diff --git a/numpy/_core/src/multiarray/getset.c b/numpy/_core/src/multiarray/getset.c index d53fc53601d6..d18463f27bb5 100644 --- a/numpy/_core/src/multiarray/getset.c +++ b/numpy/_core/src/multiarray/getset.c @@ -9,7 +9,7 @@ #include "numpy/arrayobject.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "npy_import.h" #include "common.h" diff --git a/numpy/_core/src/multiarray/hashdescr.c b/numpy/_core/src/multiarray/hashdescr.c index 925179e30a53..f570caf1588f 100644 --- a/numpy/_core/src/multiarray/hashdescr.c +++ b/numpy/_core/src/multiarray/hashdescr.c @@ -8,7 +8,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "hashdescr.h" diff --git a/numpy/_core/src/multiarray/item_selection.c b/numpy/_core/src/multiarray/item_selection.c index 37e33c28a944..df05e4aa8aa5 100644 --- a/numpy/_core/src/multiarray/item_selection.c +++ b/numpy/_core/src/multiarray/item_selection.c @@ -13,7 +13,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "multiarraymodule.h" #include "common.h" diff --git a/numpy/_core/src/multiarray/iterators.c b/numpy/_core/src/multiarray/iterators.c index 68881a1f004f..2806670d3e07 100644 --- a/numpy/_core/src/multiarray/iterators.c +++ b/numpy/_core/src/multiarray/iterators.c @@ -11,7 +11,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "arrayobject.h" #include "iterators.h" diff --git a/numpy/_core/src/multiarray/nditer_impl.h b/numpy/_core/src/multiarray/nditer_impl.h index 0332d78ec913..790ddcb11f83 100644 --- a/numpy/_core/src/multiarray/nditer_impl.h +++ b/numpy/_core/src/multiarray/nditer_impl.h @@ -18,7 +18,7 @@ #include #include "numpy/arrayobject.h" -#include "npy_pycompat.h" + #include "convert_datatype.h" #include "lowlevel_strided_loops.h" diff --git a/numpy/_core/src/multiarray/nditer_pywrap.c b/numpy/_core/src/multiarray/nditer_pywrap.c index 94dd526ceb6c..ad20194f308f 100644 --- a/numpy/_core/src/multiarray/nditer_pywrap.c +++ b/numpy/_core/src/multiarray/nditer_pywrap.c @@ -15,7 +15,7 @@ #include "numpy/arrayobject.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "alloc.h" #include "common.h" #include "conversion_utils.h" diff --git a/numpy/_core/src/multiarray/number.c b/numpy/_core/src/multiarray/number.c index d42d23a281ea..7b4d6f21f45c 100644 --- a/numpy/_core/src/multiarray/number.c +++ b/numpy/_core/src/multiarray/number.c @@ -8,7 +8,7 @@ #include "numpy/arrayobject.h" #include "npy_config.h" -#include "npy_pycompat.h" + #include "npy_import.h" #include "common.h" #include "number.h" diff --git a/numpy/_core/src/multiarray/refcount.c b/numpy/_core/src/multiarray/refcount.c index df16452ab283..1bc693532646 100644 --- a/numpy/_core/src/multiarray/refcount.c +++ b/numpy/_core/src/multiarray/refcount.c @@ -21,7 +21,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + /* * Helper function to clear a strided memory (normally or always contiguous) diff --git a/numpy/_core/src/multiarray/scalarapi.c b/numpy/_core/src/multiarray/scalarapi.c index a4ed781142ad..9ca83d8a57f5 100644 --- a/numpy/_core/src/multiarray/scalarapi.c +++ b/numpy/_core/src/multiarray/scalarapi.c @@ -12,7 +12,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "array_coercion.h" #include "ctors.h" diff --git a/numpy/_core/src/multiarray/sequence.c b/numpy/_core/src/multiarray/sequence.c index 7bdd64d27e5f..4c94bb798072 100644 --- a/numpy/_core/src/multiarray/sequence.c +++ b/numpy/_core/src/multiarray/sequence.c @@ -10,7 +10,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "common.h" #include "mapping.h" diff --git a/numpy/_core/src/multiarray/shape.c b/numpy/_core/src/multiarray/shape.c index ede7a617e00b..6ca8ff85e218 100644 --- a/numpy/_core/src/multiarray/shape.c +++ b/numpy/_core/src/multiarray/shape.c @@ -12,7 +12,7 @@ #include "npy_config.h" -#include "npy_pycompat.h" + #include "arraywrap.h" #include "ctors.h" diff --git a/numpy/_core/src/multiarray/usertypes.c b/numpy/_core/src/multiarray/usertypes.c index 92325247a60c..5e794a8490ca 100644 --- a/numpy/_core/src/multiarray/usertypes.c +++ b/numpy/_core/src/multiarray/usertypes.c @@ -34,7 +34,7 @@ maintainer email: oliphant.travis@ieee.org #include "common.h" -#include "npy_pycompat.h" + #include "usertypes.h" #include "dtypemeta.h" diff --git a/numpy/_core/src/umath/_umath_tests.c.src b/numpy/_core/src/umath/_umath_tests.c.src index 2479c9c9279c..ac45ae92afbc 100644 --- a/numpy/_core/src/umath/_umath_tests.c.src +++ b/numpy/_core/src/umath/_umath_tests.c.src @@ -19,7 +19,7 @@ #include "numpy/ndarrayobject.h" #include "numpy/npy_math.h" -#include "npy_pycompat.h" + #include "npy_config.h" #include "npy_cpu_features.h" diff --git a/numpy/_core/src/umath/extobj.c b/numpy/_core/src/umath/extobj.c index aea145de81f9..d32feaaa31da 100644 --- a/numpy/_core/src/umath/extobj.c +++ b/numpy/_core/src/umath/extobj.c @@ -6,7 +6,7 @@ #include #include "npy_config.h" -#include "npy_pycompat.h" + #include "npy_argparse.h" #include "conversion_utils.h" diff --git a/numpy/_core/src/umath/funcs.inc.src b/numpy/_core/src/umath/funcs.inc.src index 6cd9448d025b..df81c835034a 100644 --- a/numpy/_core/src/umath/funcs.inc.src +++ b/numpy/_core/src/umath/funcs.inc.src @@ -7,7 +7,7 @@ */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION -#include "npy_pycompat.h" + #include "npy_import.h" diff --git a/numpy/_core/src/umath/matmul.c.src b/numpy/_core/src/umath/matmul.c.src index cdae9d1d22a5..37f990f970ed 100644 --- a/numpy/_core/src/umath/matmul.c.src +++ b/numpy/_core/src/umath/matmul.c.src @@ -14,7 +14,7 @@ #include "numpy/halffloat.h" #include "lowlevel_strided_loops.h" -#include "npy_pycompat.h" + #include "npy_cblas.h" #include "arraytypes.h" /* For TYPE_dot functions */ diff --git a/numpy/_core/src/umath/override.c b/numpy/_core/src/umath/override.c index bb29fcdf7c52..f03a253fe7c2 100644 --- a/numpy/_core/src/umath/override.c +++ b/numpy/_core/src/umath/override.c @@ -1,7 +1,7 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION -#define NO_IMPORT_ARRAY +#define NO_IMPORT_ -#include "npy_pycompat.h" +#include "numpy/ndarraytypes.h" #include "numpy/ufuncobject.h" #include "npy_import.h" diff --git a/numpy/_core/src/umath/reduction.c b/numpy/_core/src/umath/reduction.c index 46466418e417..548530e1ca3b 100644 --- a/numpy/_core/src/umath/reduction.c +++ b/numpy/_core/src/umath/reduction.c @@ -16,7 +16,7 @@ #include "npy_config.h" #include "numpy/arrayobject.h" -#include "npy_pycompat.h" + #include "array_assign.h" #include "array_coercion.h" #include "array_method.h" diff --git a/numpy/_core/src/umath/scalarmath.c.src b/numpy/_core/src/umath/scalarmath.c.src index 40ba7d65f05c..c04a8f248cd3 100644 --- a/numpy/_core/src/umath/scalarmath.c.src +++ b/numpy/_core/src/umath/scalarmath.c.src @@ -19,7 +19,7 @@ #include "numpy/npy_math.h" #include "npy_import.h" -#include "npy_pycompat.h" + #include "numpy/halffloat.h" #include "templ_common.h" diff --git a/numpy/_core/src/umath/ufunc_object.c b/numpy/_core/src/umath/ufunc_object.c index 63ef0d9080ca..3585dd8ace21 100644 --- a/numpy/_core/src/umath/ufunc_object.c +++ b/numpy/_core/src/umath/ufunc_object.c @@ -33,7 +33,7 @@ #include #include "npy_config.h" -#include "npy_pycompat.h" + #include "npy_argparse.h" #include "numpy/arrayobject.h" diff --git a/numpy/_core/src/umath/ufunc_type_resolution.c b/numpy/_core/src/umath/ufunc_type_resolution.c index f9962a9b4e32..abb8c5ac7e07 100644 --- a/numpy/_core/src/umath/ufunc_type_resolution.c +++ b/numpy/_core/src/umath/ufunc_type_resolution.c @@ -33,9 +33,11 @@ #endif #include "npy_config.h" -#include "npy_pycompat.h" + +#include "numpy/npy_common.h" #include "npy_import.h" +#include "numpy/ndarraytypes.h" #include "numpy/ufuncobject.h" #include "ufunc_type_resolution.h" #include "ufunc_object.h" diff --git a/numpy/linalg/umath_linalg.cpp b/numpy/linalg/umath_linalg.cpp index cd5ddddaa8d7..ecbca7f4d3ea 100644 --- a/numpy/linalg/umath_linalg.cpp +++ b/numpy/linalg/umath_linalg.cpp @@ -13,8 +13,6 @@ #include "numpy/ufuncobject.h" #include "numpy/npy_math.h" -#include "npy_pycompat.h" - #include "npy_config.h" #include "npy_cblas.h" From c74a960af165b55c6dd7986e45435bc2cd296ded Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 1 Apr 2024 11:26:21 -0600 Subject: [PATCH 4/5] MNT: skip pythoncapi-comat in check_installed_files --- tools/check_installed_files.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/check_installed_files.py b/tools/check_installed_files.py index 9e97f903d65a..7f78d5b1c7d6 100644 --- a/tools/check_installed_files.py +++ b/tools/check_installed_files.py @@ -79,6 +79,11 @@ def get_files(dir_to_check, kind='test'): k: v for k, v in files.items() if not k.startswith('distutils') } + # ignore python files in vendored pythoncapi-compat submodule + files = { + k: v for k, v in files.items() if 'pythoncapi-compat' not in k + } + return files From 1bceaf893336e50e936d80db996c860d3a35ea64 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Wed, 3 Apr 2024 08:07:17 -0600 Subject: [PATCH 5/5] MNT: respond to review comments --- numpy/_core/meson.build | 5 +++++ numpy/_core/src/umath/override.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/numpy/_core/meson.build b/numpy/_core/meson.build index 8fc377aeedde..658725af9216 100644 --- a/numpy/_core/meson.build +++ b/numpy/_core/meson.build @@ -123,6 +123,11 @@ if use_intel_sort and not fs.exists('src/npysort/x86-simd-sort/README.md') error('Missing the `x86-simd-sort` git submodule! Run `git submodule update --init` to fix this.') endif +if not fs.exists('src/common/pythoncapi-compat') + error('Missing the `pythoncapi-compat` git submodule! ' + + 'Run `git submodule update --init` to fix this.') +endif + # Check sizes of types. Note, some of these landed in config.h before, but were # unused. So clean that up and only define the NPY_SIZEOF flavors rather than # the SIZEOF ones diff --git a/numpy/_core/src/umath/override.c b/numpy/_core/src/umath/override.c index f03a253fe7c2..88d05abddc50 100644 --- a/numpy/_core/src/umath/override.c +++ b/numpy/_core/src/umath/override.c @@ -1,5 +1,5 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION -#define NO_IMPORT_ +#define NO_IMPORT_ARRAY #include "numpy/ndarraytypes.h" #include "numpy/ufuncobject.h"