From baf09d8ea2d1a03e9e5d11ddba2b56e892a6e0bf Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:33:41 -0400 Subject: [PATCH 01/14] BUG: Include python-including headers first --- numpy/_core/src/common/blas_utils.c | 8 ++++---- numpy/_core/src/common/blas_utils.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/numpy/_core/src/common/blas_utils.c b/numpy/_core/src/common/blas_utils.c index aaf976ed70e4..25824ead00b6 100644 --- a/numpy/_core/src/common/blas_utils.c +++ b/numpy/_core/src/common/blas_utils.c @@ -1,3 +1,7 @@ +#include "numpy/numpyconfig.h" // NPY_VISIBILITY_HIDDEN +#include "numpy/npy_math.h" // npy_get_floatstatus_barrier +#include "blas_utils.h" + #include #include #include @@ -6,10 +10,6 @@ #include #endif -#include "numpy/numpyconfig.h" // NPY_VISIBILITY_HIDDEN -#include "numpy/npy_math.h" // npy_get_floatstatus_barrier -#include "blas_utils.h" - #if NPY_BLAS_CHECK_FPE_SUPPORT /* Return whether we're running on macOS 15.4 or later diff --git a/numpy/_core/src/common/blas_utils.h b/numpy/_core/src/common/blas_utils.h index 8c1437f88899..34d6321c2920 100644 --- a/numpy/_core/src/common/blas_utils.h +++ b/numpy/_core/src/common/blas_utils.h @@ -1,7 +1,7 @@ -#include - #include "numpy/numpyconfig.h" // for NPY_VISIBILITY_HIDDEN +#include + /* NPY_BLAS_CHECK_FPE_SUPPORT controls whether we need a runtime check * for floating-point error (FPE) support in BLAS. */ From e7b47cf9762ca4b39d3179e2e900271c36cfa763 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 27 Jun 2025 19:18:55 -0400 Subject: [PATCH 02/14] STY: Add comments noting that Python.h should be included first. --- numpy/_core/include/numpy/halffloat.h | 3 +++ numpy/_core/include/numpy/ndarrayobject.h | 3 +++ numpy/_core/include/numpy/npy_3kcompat.h | 3 +++ numpy/_core/include/numpy/npy_common.h | 3 +++ numpy/_core/include/numpy/random/distributions.h | 3 +++ numpy/_core/src/_simd/_simd.h | 3 +++ numpy/_core/src/_simd/_simd_inc.h.src | 3 +++ numpy/_core/src/common/array_assign.c | 3 +++ numpy/_core/src/common/cblasfuncs.c | 3 +++ numpy/_core/src/common/get_attr_string.h | 3 +++ numpy/_core/src/common/gil_utils.c | 3 +++ numpy/_core/src/common/mem_overlap.c | 3 +++ numpy/_core/src/common/npy_argparse.c | 3 +++ numpy/_core/src/common/npy_argparse.h | 3 +++ numpy/_core/src/common/npy_cpu_features.h | 3 +++ numpy/_core/src/common/npy_ctypes.h | 3 +++ numpy/_core/src/common/npy_dlpack.h | 3 +++ numpy/_core/src/common/npy_hashtable.h | 3 +++ numpy/_core/src/common/npy_import.h | 3 +++ numpy/_core/src/common/npy_longdouble.c | 3 +++ numpy/_core/src/common/npy_sort.h.src | 3 +++ numpy/_core/src/common/numpyos.c | 3 +++ numpy/_core/src/common/python_xerbla.c | 3 +++ numpy/_core/src/dummymodule.c | 3 +++ numpy/_core/src/multiarray/_multiarray_tests.c.src | 3 +++ numpy/_core/src/multiarray/abstractdtypes.c | 3 +++ numpy/_core/src/multiarray/alloc.c | 3 +++ numpy/_core/src/multiarray/array_assign_array.c | 3 +++ numpy/_core/src/multiarray/array_assign_scalar.c | 3 +++ numpy/_core/src/multiarray/array_coercion.c | 3 +++ numpy/_core/src/multiarray/array_converter.c | 3 +++ numpy/_core/src/multiarray/array_method.h | 3 +++ numpy/_core/src/multiarray/arrayfunction_override.c | 3 +++ numpy/_core/src/multiarray/arrayobject.c | 3 +++ numpy/_core/src/multiarray/arraytypes.c.src | 3 +++ numpy/_core/src/multiarray/arraywrap.c | 3 +++ numpy/_core/src/multiarray/buffer.c | 3 +++ numpy/_core/src/multiarray/calculation.c | 3 +++ numpy/_core/src/multiarray/common.c | 3 +++ numpy/_core/src/multiarray/common_dtype.c | 3 +++ numpy/_core/src/multiarray/compiled_base.c | 3 +++ numpy/_core/src/multiarray/conversion_utils.c | 3 +++ numpy/_core/src/multiarray/convert.c | 3 +++ numpy/_core/src/multiarray/convert_datatype.c | 3 +++ numpy/_core/src/multiarray/ctors.c | 3 +++ numpy/_core/src/multiarray/datetime.c | 3 +++ numpy/_core/src/multiarray/datetime_busday.c | 3 +++ numpy/_core/src/multiarray/datetime_busdaycal.c | 3 +++ numpy/_core/src/multiarray/datetime_strings.c | 3 +++ numpy/_core/src/multiarray/descriptor.c | 3 +++ numpy/_core/src/multiarray/dlpack.c | 3 +++ numpy/_core/src/multiarray/dragon4.h | 3 +++ numpy/_core/src/multiarray/dtype_transfer.c | 3 +++ numpy/_core/src/multiarray/dtype_traversal.c | 3 +++ numpy/_core/src/multiarray/dtypemeta.c | 3 +++ numpy/_core/src/multiarray/einsum.c.src | 3 +++ numpy/_core/src/multiarray/flagsobject.c | 3 +++ numpy/_core/src/multiarray/fnv.c | 3 +++ numpy/_core/src/multiarray/getset.c | 3 +++ numpy/_core/src/multiarray/hashdescr.c | 3 +++ numpy/_core/src/multiarray/item_selection.c | 3 +++ numpy/_core/src/multiarray/iterators.c | 3 +++ numpy/_core/src/multiarray/lowlevel_strided_loops.c.src | 3 +++ numpy/_core/src/multiarray/mapping.c | 3 +++ numpy/_core/src/multiarray/methods.c | 3 +++ numpy/_core/src/multiarray/multiarraymodule.c | 3 +++ numpy/_core/src/multiarray/nditer_impl.h | 3 +++ numpy/_core/src/multiarray/nditer_pywrap.c | 3 +++ numpy/_core/src/multiarray/npy_static_data.c | 3 +++ numpy/_core/src/multiarray/number.c | 3 +++ numpy/_core/src/multiarray/public_dtype_api.c | 3 +++ numpy/_core/src/multiarray/scalarapi.c | 3 +++ numpy/_core/src/multiarray/scalartypes.c.src | 3 +++ numpy/_core/src/multiarray/sequence.c | 3 +++ numpy/_core/src/multiarray/shape.c | 3 +++ numpy/_core/src/multiarray/strfuncs.c | 3 +++ numpy/_core/src/multiarray/stringdtype/casts.cpp | 3 +++ numpy/_core/src/multiarray/stringdtype/dtype.c | 4 ++++ numpy/_core/src/multiarray/stringdtype/static_string.c | 3 +++ numpy/_core/src/multiarray/stringdtype/utf8_utils.c | 3 +++ numpy/_core/src/multiarray/temp_elide.c | 3 +++ numpy/_core/src/multiarray/textreading/conversions.c | 4 +++- numpy/_core/src/multiarray/textreading/field_types.h | 3 +++ numpy/_core/src/multiarray/textreading/readtext.c | 3 +++ numpy/_core/src/multiarray/textreading/rows.c | 4 +++- numpy/_core/src/multiarray/textreading/rows.h | 3 +++ numpy/_core/src/multiarray/textreading/str_to_int.c | 4 +++- numpy/_core/src/multiarray/textreading/stream_pyobject.c | 3 +++ numpy/_core/src/multiarray/textreading/stream_pyobject.h | 3 +++ numpy/_core/src/multiarray/textreading/tokenize.cpp | 4 +++- numpy/_core/src/multiarray/textreading/tokenize.h | 3 +++ numpy/_core/src/multiarray/unique.cpp | 4 ++++ numpy/_core/src/multiarray/usertypes.c | 3 +++ numpy/_core/src/multiarray/vdot.c | 3 +++ numpy/_core/src/npymath/npy_math_common.h | 4 ++++ numpy/_core/src/npymath/npy_math_private.h | 3 +++ numpy/_core/src/umath/_operand_flag_tests.c | 3 +++ numpy/_core/src/umath/_rational_tests.c | 4 ++++ numpy/_core/src/umath/_struct_ufunc_tests.c | 3 +++ numpy/_core/src/umath/_umath_tests.c.src | 3 +++ numpy/_core/src/umath/_umath_tests.dispatch.c | 3 +++ numpy/_core/src/umath/dispatching.cpp | 3 +++ numpy/_core/src/umath/extobj.c | 3 +++ numpy/_core/src/umath/legacy_array_method.c | 3 +++ numpy/_core/src/umath/loops.c.src | 3 +++ numpy/_core/src/umath/matmul.c.src | 3 +++ numpy/_core/src/umath/reduction.c | 3 +++ numpy/_core/src/umath/scalarmath.c.src | 3 +++ numpy/_core/src/umath/special_integer_comparisons.cpp | 3 +++ numpy/_core/src/umath/string_buffer.h | 3 +++ numpy/_core/src/umath/string_fastsearch.h | 3 +++ numpy/_core/src/umath/string_ufuncs.cpp | 4 ++++ numpy/_core/src/umath/stringdtype_ufuncs.cpp | 4 ++++ numpy/_core/src/umath/ufunc_object.c | 3 +++ numpy/_core/src/umath/ufunc_type_resolution.c | 3 +++ numpy/_core/src/umath/umathmodule.c | 3 +++ numpy/_core/src/umath/wrapping_array_method.c | 3 +++ numpy/_core/tests/examples/limited_api/limited_api1.c | 3 +++ numpy/_core/tests/examples/limited_api/limited_api_latest.c | 3 +++ numpy/f2py/src/fortranobject.h | 3 +++ numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c | 3 +++ numpy/fft/_pocketfft_umath.cpp | 3 +++ numpy/linalg/lapack_lite/f2c.c | 3 +++ numpy/linalg/lapack_lite/f2c.h | 3 +++ numpy/linalg/lapack_lite/python_xerbla.c | 3 +++ numpy/linalg/lapack_litemodule.c | 3 +++ numpy/linalg/umath_linalg.cpp | 3 +++ numpy/random/include/aligned_malloc.h | 3 +++ 128 files changed, 390 insertions(+), 4 deletions(-) diff --git a/numpy/_core/include/numpy/halffloat.h b/numpy/_core/include/numpy/halffloat.h index 950401664e10..4468128d133f 100644 --- a/numpy/_core/include/numpy/halffloat.h +++ b/numpy/_core/include/numpy/halffloat.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_ #define NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/include/numpy/ndarrayobject.h b/numpy/_core/include/numpy/ndarrayobject.h index f06bafe5b52a..c1bb38365084 100644 --- a/numpy/_core/include/numpy/ndarrayobject.h +++ b/numpy/_core/include/numpy/ndarrayobject.h @@ -8,6 +8,9 @@ extern "C" { #endif +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "ndarraytypes.h" #include "dtype_api.h" diff --git a/numpy/_core/include/numpy/npy_3kcompat.h b/numpy/_core/include/numpy/npy_3kcompat.h index c2bf74faf09d..b3c0c37b6e6b 100644 --- a/numpy/_core/include/numpy/npy_3kcompat.h +++ b/numpy/_core/include/numpy/npy_3kcompat.h @@ -11,6 +11,9 @@ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/include/numpy/npy_common.h b/numpy/_core/include/numpy/npy_common.h index 5eaa29035428..ff74981db36b 100644 --- a/numpy/_core/include/numpy/npy_common.h +++ b/numpy/_core/include/numpy/npy_common.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ /* need Python.h for npy_intp, npy_uintp */ #include diff --git a/numpy/_core/include/numpy/random/distributions.h b/numpy/_core/include/numpy/random/distributions.h index e7fa4bd00d43..ea81207cb9e6 100644 --- a/numpy/_core/include/numpy/random/distributions.h +++ b/numpy/_core/include/numpy/random/distributions.h @@ -5,6 +5,9 @@ extern "C" { #endif +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" #include diff --git a/numpy/_core/src/_simd/_simd.h b/numpy/_core/src/_simd/_simd.h index 82a4451cc3a2..2c454e4dff70 100644 --- a/numpy/_core/src/_simd/_simd.h +++ b/numpy/_core/src/_simd/_simd.h @@ -12,6 +12,9 @@ #ifndef _SIMD_SIMD_H_ #define _SIMD_SIMD_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" #include "npy_cpu_features.h" diff --git a/numpy/_core/src/_simd/_simd_inc.h.src b/numpy/_core/src/_simd/_simd_inc.h.src index a023848831ed..d7c43bdf68a4 100644 --- a/numpy/_core/src/_simd/_simd_inc.h.src +++ b/numpy/_core/src/_simd/_simd_inc.h.src @@ -1,6 +1,9 @@ #ifndef _SIMD_SIMD_INC_H_ #define _SIMD_SIMD_INC_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "simd/simd.h" diff --git a/numpy/_core/src/common/array_assign.c b/numpy/_core/src/common/array_assign.c index 3c6d2f14cb65..64cf91037bdd 100644 --- a/numpy/_core/src/common/array_assign.c +++ b/numpy/_core/src/common/array_assign.c @@ -10,6 +10,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/cblasfuncs.c b/numpy/_core/src/common/cblasfuncs.c index 66a215dfeb64..8522b214a4c3 100644 --- a/numpy/_core/src/common/cblasfuncs.c +++ b/numpy/_core/src/common/cblasfuncs.c @@ -6,6 +6,9 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/get_attr_string.h b/numpy/_core/src/common/get_attr_string.h index 324a92c5ef0c..e7889df27a3f 100644 --- a/numpy/_core/src/common/get_attr_string.h +++ b/numpy/_core/src/common/get_attr_string.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_SRC_COMMON_GET_ATTR_STRING_H_ #define NUMPY_CORE_SRC_COMMON_GET_ATTR_STRING_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "npy_pycompat.h" diff --git a/numpy/_core/src/common/gil_utils.c b/numpy/_core/src/common/gil_utils.c index 95af26a2bf8e..15f3ce67ec51 100644 --- a/numpy/_core/src/common/gil_utils.c +++ b/numpy/_core/src/common/gil_utils.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/mem_overlap.c b/numpy/_core/src/common/mem_overlap.c index d5b734cad120..1654ada5470f 100644 --- a/numpy/_core/src/common/mem_overlap.c +++ b/numpy/_core/src/common/mem_overlap.c @@ -183,6 +183,9 @@ */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/npy_argparse.c b/numpy/_core/src/common/npy_argparse.c index 6766b17043ac..8f42e87a0a28 100644 --- a/numpy/_core/src/common/npy_argparse.c +++ b/numpy/_core/src/common/npy_argparse.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/npy_argparse.h b/numpy/_core/src/common/npy_argparse.h index e1eef918cb33..eaa5afae014e 100644 --- a/numpy/_core/src/common/npy_argparse.h +++ b/numpy/_core/src/common/npy_argparse.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_ARGPARSE_H #define NUMPY_CORE_SRC_COMMON_NPY_ARGPARSE_H +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/ndarraytypes.h" diff --git a/numpy/_core/src/common/npy_cpu_features.h b/numpy/_core/src/common/npy_cpu_features.h index 7d6a406f8789..173b906060c5 100644 --- a/numpy/_core/src/common/npy_cpu_features.h +++ b/numpy/_core/src/common/npy_cpu_features.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_CPU_FEATURES_H_ #define NUMPY_CORE_SRC_COMMON_NPY_CPU_FEATURES_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include // for PyObject #include "numpy/numpyconfig.h" // for NPY_VISIBILITY_HIDDEN diff --git a/numpy/_core/src/common/npy_ctypes.h b/numpy/_core/src/common/npy_ctypes.h index 78809732416c..ee1bf4409e02 100644 --- a/numpy/_core/src/common/npy_ctypes.h +++ b/numpy/_core/src/common/npy_ctypes.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_CTYPES_H_ #define NUMPY_CORE_SRC_COMMON_NPY_CTYPES_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "npy_import.h" diff --git a/numpy/_core/src/common/npy_dlpack.h b/numpy/_core/src/common/npy_dlpack.h index 1dd3ae7f88e5..7e026f9e0a78 100644 --- a/numpy/_core/src/common/npy_dlpack.h +++ b/numpy/_core/src/common/npy_dlpack.h @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include "Python.h" #include "dlpack/dlpack.h" diff --git a/numpy/_core/src/common/npy_hashtable.h b/numpy/_core/src/common/npy_hashtable.h index cd061ba6fa11..c729bc27e7c6 100644 --- a/numpy/_core/src/common/npy_hashtable.h +++ b/numpy/_core/src/common/npy_hashtable.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_NPY_HASHTABLE_H_ #define NUMPY_CORE_SRC_COMMON_NPY_NPY_HASHTABLE_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/common/npy_import.h b/numpy/_core/src/common/npy_import.h index 970efa8f549e..f657a4b7b4a2 100644 --- a/numpy/_core/src/common/npy_import.h +++ b/numpy/_core/src/common/npy_import.h @@ -1,6 +1,9 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ #define NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" diff --git a/numpy/_core/src/common/npy_longdouble.c b/numpy/_core/src/common/npy_longdouble.c index ce80a9ae2bc3..0fe7d16e0565 100644 --- a/numpy/_core/src/common/npy_longdouble.c +++ b/numpy/_core/src/common/npy_longdouble.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/npy_sort.h.src b/numpy/_core/src/common/npy_sort.h.src index d6e4357225a8..cef966c99237 100644 --- a/numpy/_core/src/common/npy_sort.h.src +++ b/numpy/_core/src/common/npy_sort.h.src @@ -2,6 +2,9 @@ #define __NPY_SORT_H__ /* Python include is for future object sorts */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/common/numpyos.c b/numpy/_core/src/common/numpyos.c index a5ca28081d52..5bd3de4d1178 100644 --- a/numpy/_core/src/common/numpyos.c +++ b/numpy/_core/src/common/numpyos.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/python_xerbla.c b/numpy/_core/src/common/python_xerbla.c index 71a4c81edbf1..49a5e90b2616 100644 --- a/numpy/_core/src/common/python_xerbla.c +++ b/numpy/_core/src/common/python_xerbla.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/dummymodule.c b/numpy/_core/src/dummymodule.c index e1ef80ab3af3..0fdff1427991 100644 --- a/numpy/_core/src/dummymodule.c +++ b/numpy/_core/src/dummymodule.c @@ -7,6 +7,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define NO_IMPORT_ARRAY +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/_multiarray_tests.c.src b/numpy/_core/src/multiarray/_multiarray_tests.c.src index 8012a32b070e..52829adf407e 100644 --- a/numpy/_core/src/multiarray/_multiarray_tests.c.src +++ b/numpy/_core/src/multiarray/_multiarray_tests.c.src @@ -1,4 +1,7 @@ /* -*-c-*- */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/abstractdtypes.c b/numpy/_core/src/multiarray/abstractdtypes.c index 120ada551e7f..bd024ad1eaab 100644 --- a/numpy/_core/src/multiarray/abstractdtypes.c +++ b/numpy/_core/src/multiarray/abstractdtypes.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/alloc.c b/numpy/_core/src/multiarray/alloc.c index cc9c5762a196..c4a5de2d751b 100644 --- a/numpy/_core/src/multiarray/alloc.c +++ b/numpy/_core/src/multiarray/alloc.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/array_assign_array.c b/numpy/_core/src/multiarray/array_assign_array.c index 8886d1cacb40..b5b5ec61532e 100644 --- a/numpy/_core/src/multiarray/array_assign_array.c +++ b/numpy/_core/src/multiarray/array_assign_array.c @@ -10,6 +10,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/array_assign_scalar.c b/numpy/_core/src/multiarray/array_assign_scalar.c index 0199ba969eb9..4652ff076d64 100644 --- a/numpy/_core/src/multiarray/array_assign_scalar.c +++ b/numpy/_core/src/multiarray/array_assign_scalar.c @@ -10,6 +10,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/array_coercion.c b/numpy/_core/src/multiarray/array_coercion.c index ff7d98bd9c64..286a69ab72cf 100644 --- a/numpy/_core/src/multiarray/array_coercion.c +++ b/numpy/_core/src/multiarray/array_coercion.c @@ -2,6 +2,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/array_converter.c b/numpy/_core/src/multiarray/array_converter.c index 496173038954..5523c456b11c 100644 --- a/numpy/_core/src/multiarray/array_converter.c +++ b/numpy/_core/src/multiarray/array_converter.c @@ -8,6 +8,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/array_method.h b/numpy/_core/src/multiarray/array_method.h index bcf270899f13..f3e983e204a0 100644 --- a/numpy/_core/src/multiarray/array_method.h +++ b/numpy/_core/src/multiarray/array_method.h @@ -4,6 +4,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/src/multiarray/arrayfunction_override.c b/numpy/_core/src/multiarray/arrayfunction_override.c index 9834ab138cf6..0f298f331456 100644 --- a/numpy/_core/src/multiarray/arrayfunction_override.c +++ b/numpy/_core/src/multiarray/arrayfunction_override.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "structmember.h" diff --git a/numpy/_core/src/multiarray/arrayobject.c b/numpy/_core/src/multiarray/arrayobject.c index 6f520fd6abbb..43c58b5808f9 100644 --- a/numpy/_core/src/multiarray/arrayobject.c +++ b/numpy/_core/src/multiarray/arrayobject.c @@ -23,6 +23,9 @@ maintainer email: oliphant.travis@ieee.org #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/arraytypes.c.src b/numpy/_core/src/multiarray/arraytypes.c.src index 9e5588f98a83..aee1ce0f1125 100644 --- a/numpy/_core/src/multiarray/arraytypes.c.src +++ b/numpy/_core/src/multiarray/arraytypes.c.src @@ -1,4 +1,7 @@ /* -*- c -*- */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/arraywrap.c b/numpy/_core/src/multiarray/arraywrap.c index 09e46bd4d3e7..f54c22da102d 100644 --- a/numpy/_core/src/multiarray/arraywrap.c +++ b/numpy/_core/src/multiarray/arraywrap.c @@ -5,6 +5,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/arrayobject.h" diff --git a/numpy/_core/src/multiarray/buffer.c b/numpy/_core/src/multiarray/buffer.c index fcff3ad6ca74..b68a6b2f6c3f 100644 --- a/numpy/_core/src/multiarray/buffer.c +++ b/numpy/_core/src/multiarray/buffer.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/calculation.c b/numpy/_core/src/multiarray/calculation.c index 87f03a94fa5f..b8dff3ca03ac 100644 --- a/numpy/_core/src/multiarray/calculation.c +++ b/numpy/_core/src/multiarray/calculation.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/common.c b/numpy/_core/src/multiarray/common.c index 8236ec5c65ae..fac8ad8d4fd1 100644 --- a/numpy/_core/src/multiarray/common.c +++ b/numpy/_core/src/multiarray/common.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/common_dtype.c b/numpy/_core/src/multiarray/common_dtype.c index fa3328e8f276..b663fa617a44 100644 --- a/numpy/_core/src/multiarray/common_dtype.c +++ b/numpy/_core/src/multiarray/common_dtype.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/compiled_base.c b/numpy/_core/src/multiarray/compiled_base.c index fee0d4a61a78..d8992e89fa0d 100644 --- a/numpy/_core/src/multiarray/compiled_base.c +++ b/numpy/_core/src/multiarray/compiled_base.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/conversion_utils.c b/numpy/_core/src/multiarray/conversion_utils.c index 5ada3e6e4faf..883a964a5b97 100644 --- a/numpy/_core/src/multiarray/conversion_utils.c +++ b/numpy/_core/src/multiarray/conversion_utils.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/convert.c b/numpy/_core/src/multiarray/convert.c index 8e0177616955..235c95da5dba 100644 --- a/numpy/_core/src/multiarray/convert.c +++ b/numpy/_core/src/multiarray/convert.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/convert_datatype.c b/numpy/_core/src/multiarray/convert_datatype.c index 59b6298b5815..5893c1147e4f 100644 --- a/numpy/_core/src/multiarray/convert_datatype.c +++ b/numpy/_core/src/multiarray/convert_datatype.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/ctors.c b/numpy/_core/src/multiarray/ctors.c index f7efe5041ab3..cd3b36159abb 100644 --- a/numpy/_core/src/multiarray/ctors.c +++ b/numpy/_core/src/multiarray/ctors.c @@ -2,6 +2,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/datetime.c b/numpy/_core/src/multiarray/datetime.c index d820474532ca..1588ccbff653 100644 --- a/numpy/_core/src/multiarray/datetime.c +++ b/numpy/_core/src/multiarray/datetime.c @@ -9,6 +9,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/datetime_busday.c b/numpy/_core/src/multiarray/datetime_busday.c index 73c88811a0a9..b4e60b9fb7ae 100644 --- a/numpy/_core/src/multiarray/datetime_busday.c +++ b/numpy/_core/src/multiarray/datetime_busday.c @@ -9,6 +9,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/datetime_busdaycal.c b/numpy/_core/src/multiarray/datetime_busdaycal.c index 3a7e3a383dca..1f1a37d9e7c9 100644 --- a/numpy/_core/src/multiarray/datetime_busdaycal.c +++ b/numpy/_core/src/multiarray/datetime_busdaycal.c @@ -10,6 +10,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/datetime_strings.c b/numpy/_core/src/multiarray/datetime_strings.c index f92eec3f5a59..8ed09b8c3716 100644 --- a/numpy/_core/src/multiarray/datetime_strings.c +++ b/numpy/_core/src/multiarray/datetime_strings.c @@ -9,6 +9,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/descriptor.c b/numpy/_core/src/multiarray/descriptor.c index f520e3c4bceb..e472c0d75be6 100644 --- a/numpy/_core/src/multiarray/descriptor.c +++ b/numpy/_core/src/multiarray/descriptor.c @@ -2,6 +2,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/dlpack.c b/numpy/_core/src/multiarray/dlpack.c index ac37a04c30c6..a79b79bf8205 100644 --- a/numpy/_core/src/multiarray/dlpack.c +++ b/numpy/_core/src/multiarray/dlpack.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/dragon4.h b/numpy/_core/src/multiarray/dragon4.h index 8986c1672e71..d0d605d679bb 100644 --- a/numpy/_core/src/multiarray/dragon4.h +++ b/numpy/_core/src/multiarray/dragon4.h @@ -32,6 +32,9 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_DRAGON4_H_ #define NUMPY_CORE_SRC_MULTIARRAY_DRAGON4_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/dtype_transfer.c b/numpy/_core/src/multiarray/dtype_transfer.c index 188a55a4b5f5..003284d9cc37 100644 --- a/numpy/_core/src/multiarray/dtype_transfer.c +++ b/numpy/_core/src/multiarray/dtype_transfer.c @@ -13,6 +13,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/dtype_traversal.c b/numpy/_core/src/multiarray/dtype_traversal.c index 91b1889b7d1f..2ef6fccd4fdb 100644 --- a/numpy/_core/src/multiarray/dtype_traversal.c +++ b/numpy/_core/src/multiarray/dtype_traversal.c @@ -14,6 +14,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/dtypemeta.c b/numpy/_core/src/multiarray/dtypemeta.c index 0b1b0fb39192..1653c9d36465 100644 --- a/numpy/_core/src/multiarray/dtypemeta.c +++ b/numpy/_core/src/multiarray/dtypemeta.c @@ -2,6 +2,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/einsum.c.src b/numpy/_core/src/multiarray/einsum.c.src index 3733c436cb1b..63950845d091 100644 --- a/numpy/_core/src/multiarray/einsum.c.src +++ b/numpy/_core/src/multiarray/einsum.c.src @@ -8,6 +8,9 @@ * See LICENSE.txt for the license. */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/flagsobject.c b/numpy/_core/src/multiarray/flagsobject.c index 8257727030c0..6f9871cda667 100644 --- a/numpy/_core/src/multiarray/flagsobject.c +++ b/numpy/_core/src/multiarray/flagsobject.c @@ -2,6 +2,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/fnv.c b/numpy/_core/src/multiarray/fnv.c index 2b7848519e61..33af34f225ed 100644 --- a/numpy/_core/src/multiarray/fnv.c +++ b/numpy/_core/src/multiarray/fnv.c @@ -7,6 +7,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" #include "fnv.h" diff --git a/numpy/_core/src/multiarray/getset.c b/numpy/_core/src/multiarray/getset.c index 48da52dd3178..060a072e8ce7 100644 --- a/numpy/_core/src/multiarray/getset.c +++ b/numpy/_core/src/multiarray/getset.c @@ -2,6 +2,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/hashdescr.c b/numpy/_core/src/multiarray/hashdescr.c index f570caf1588f..b9e4bb95fd33 100644 --- a/numpy/_core/src/multiarray/hashdescr.c +++ b/numpy/_core/src/multiarray/hashdescr.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/item_selection.c b/numpy/_core/src/multiarray/item_selection.c index 5c036b704774..8f96a8faa861 100644 --- a/numpy/_core/src/multiarray/item_selection.c +++ b/numpy/_core/src/multiarray/item_selection.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/iterators.c b/numpy/_core/src/multiarray/iterators.c index 422c690882ab..114cb4249103 100644 --- a/numpy/_core/src/multiarray/iterators.c +++ b/numpy/_core/src/multiarray/iterators.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src b/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src index 0c4eb3dd9a8d..80a660496d09 100644 --- a/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src +++ b/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src @@ -8,6 +8,9 @@ * See LICENSE.txt for the license. */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/mapping.c b/numpy/_core/src/multiarray/mapping.c index 7953e32fcbf0..7910b452f1ce 100644 --- a/numpy/_core/src/multiarray/mapping.c +++ b/numpy/_core/src/multiarray/mapping.c @@ -2,6 +2,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/methods.c b/numpy/_core/src/multiarray/methods.c index 58a554dc40be..1ddefcf61c6f 100644 --- a/numpy/_core/src/multiarray/methods.c +++ b/numpy/_core/src/multiarray/methods.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/multiarraymodule.c b/numpy/_core/src/multiarray/multiarraymodule.c index e80c6c0cd45c..ef585c9ef38e 100644 --- a/numpy/_core/src/multiarray/multiarraymodule.c +++ b/numpy/_core/src/multiarray/multiarraymodule.c @@ -15,6 +15,9 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/nditer_impl.h b/numpy/_core/src/multiarray/nditer_impl.h index ab3724d67d11..d78e179d0758 100644 --- a/numpy/_core/src/multiarray/nditer_impl.h +++ b/numpy/_core/src/multiarray/nditer_impl.h @@ -13,6 +13,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/nditer_pywrap.c b/numpy/_core/src/multiarray/nditer_pywrap.c index 27c392db8720..8eabc5f41305 100644 --- a/numpy/_core/src/multiarray/nditer_pywrap.c +++ b/numpy/_core/src/multiarray/nditer_pywrap.c @@ -9,6 +9,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/npy_static_data.c b/numpy/_core/src/multiarray/npy_static_data.c index 62e1fd3c1b15..88d3c439bfc4 100644 --- a/numpy/_core/src/multiarray/npy_static_data.c +++ b/numpy/_core/src/multiarray/npy_static_data.c @@ -3,6 +3,9 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/number.c b/numpy/_core/src/multiarray/number.c index b801d7e041e2..d0371d68de43 100644 --- a/numpy/_core/src/multiarray/number.c +++ b/numpy/_core/src/multiarray/number.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/public_dtype_api.c b/numpy/_core/src/multiarray/public_dtype_api.c index 9b2d7a393842..e43dd93d1f79 100644 --- a/numpy/_core/src/multiarray/public_dtype_api.c +++ b/numpy/_core/src/multiarray/public_dtype_api.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/scalarapi.c b/numpy/_core/src/multiarray/scalarapi.c index e133b46d008a..4e1a266f2b86 100644 --- a/numpy/_core/src/multiarray/scalarapi.c +++ b/numpy/_core/src/multiarray/scalarapi.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/scalartypes.c.src b/numpy/_core/src/multiarray/scalartypes.c.src index 03165b10337e..aa266befa3fa 100644 --- a/numpy/_core/src/multiarray/scalartypes.c.src +++ b/numpy/_core/src/multiarray/scalartypes.c.src @@ -1,4 +1,7 @@ /* -*- c -*- */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/sequence.c b/numpy/_core/src/multiarray/sequence.c index 4c94bb798072..f8a5ebf37af1 100644 --- a/numpy/_core/src/multiarray/sequence.c +++ b/numpy/_core/src/multiarray/sequence.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/shape.c b/numpy/_core/src/multiarray/shape.c index 340fe7289ac8..382b3acdc0a1 100644 --- a/numpy/_core/src/multiarray/shape.c +++ b/numpy/_core/src/multiarray/shape.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/strfuncs.c b/numpy/_core/src/multiarray/strfuncs.c index efe5c8a4fdd8..cef5e3cf9792 100644 --- a/numpy/_core/src/multiarray/strfuncs.c +++ b/numpy/_core/src/multiarray/strfuncs.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/stringdtype/casts.cpp b/numpy/_core/src/multiarray/stringdtype/casts.cpp index 3632e359c9a9..77dd9f0013ab 100644 --- a/numpy/_core/src/multiarray/stringdtype/casts.cpp +++ b/numpy/_core/src/multiarray/stringdtype/casts.cpp @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include "numpy/npy_common.h" diff --git a/numpy/_core/src/multiarray/stringdtype/dtype.c b/numpy/_core/src/multiarray/stringdtype/dtype.c index a06e7a1ed1b6..79a15b1167b7 100644 --- a/numpy/_core/src/multiarray/stringdtype/dtype.c +++ b/numpy/_core/src/multiarray/stringdtype/dtype.c @@ -1,4 +1,8 @@ /* The implementation of the StringDType class */ + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include "structmember.h" diff --git a/numpy/_core/src/multiarray/stringdtype/static_string.c b/numpy/_core/src/multiarray/stringdtype/static_string.c index 89b53bcb8538..ed7ab4ba2d47 100644 --- a/numpy/_core/src/multiarray/stringdtype/static_string.c +++ b/numpy/_core/src/multiarray/stringdtype/static_string.c @@ -17,6 +17,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/stringdtype/utf8_utils.c b/numpy/_core/src/multiarray/stringdtype/utf8_utils.c index b40d23841471..17b86e3c998a 100644 --- a/numpy/_core/src/multiarray/stringdtype/utf8_utils.c +++ b/numpy/_core/src/multiarray/stringdtype/utf8_utils.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/temp_elide.c b/numpy/_core/src/multiarray/temp_elide.c index 9236476c4213..e6d205537643 100644 --- a/numpy/_core/src/multiarray/temp_elide.c +++ b/numpy/_core/src/multiarray/temp_elide.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/conversions.c b/numpy/_core/src/multiarray/textreading/conversions.c index 692b67a95264..c7d1062e0b26 100644 --- a/numpy/_core/src/multiarray/textreading/conversions.c +++ b/numpy/_core/src/multiarray/textreading/conversions.c @@ -1,4 +1,6 @@ - +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/src/multiarray/textreading/field_types.h b/numpy/_core/src/multiarray/textreading/field_types.h index 078b740cfe0c..a4c4ef2a42f6 100644 --- a/numpy/_core/src/multiarray/textreading/field_types.h +++ b/numpy/_core/src/multiarray/textreading/field_types.h @@ -2,6 +2,9 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_FIELD_TYPES_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_FIELD_TYPES_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/readtext.c b/numpy/_core/src/multiarray/textreading/readtext.c index 4df2446302d6..65e5e6807fce 100644 --- a/numpy/_core/src/multiarray/textreading/readtext.c +++ b/numpy/_core/src/multiarray/textreading/readtext.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/rows.c b/numpy/_core/src/multiarray/textreading/rows.c index c459fa826e53..545bdff42d42 100644 --- a/numpy/_core/src/multiarray/textreading/rows.c +++ b/numpy/_core/src/multiarray/textreading/rows.c @@ -1,4 +1,6 @@ - +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/rows.h b/numpy/_core/src/multiarray/textreading/rows.h index 20eb9e186a19..45358b4621ed 100644 --- a/numpy/_core/src/multiarray/textreading/rows.h +++ b/numpy/_core/src/multiarray/textreading/rows.h @@ -2,6 +2,9 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_ROWS_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_ROWS_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/textreading/str_to_int.c b/numpy/_core/src/multiarray/textreading/str_to_int.c index 5f58067228d1..c61558014958 100644 --- a/numpy/_core/src/multiarray/textreading/str_to_int.c +++ b/numpy/_core/src/multiarray/textreading/str_to_int.c @@ -1,4 +1,6 @@ - +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/textreading/stream_pyobject.c b/numpy/_core/src/multiarray/textreading/stream_pyobject.c index 3832ee84a4f3..213a5519beec 100644 --- a/numpy/_core/src/multiarray/textreading/stream_pyobject.c +++ b/numpy/_core/src/multiarray/textreading/stream_pyobject.c @@ -4,6 +4,9 @@ * single line of a file. */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/stream_pyobject.h b/numpy/_core/src/multiarray/textreading/stream_pyobject.h index 45c11dd951a7..49830e12d22b 100644 --- a/numpy/_core/src/multiarray/textreading/stream_pyobject.h +++ b/numpy/_core/src/multiarray/textreading/stream_pyobject.h @@ -2,6 +2,9 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_STREAM_PYOBJECT_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_STREAM_PYOBJECT_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/tokenize.cpp b/numpy/_core/src/multiarray/textreading/tokenize.cpp index e0ddc393d889..952ca8e279b8 100644 --- a/numpy/_core/src/multiarray/textreading/tokenize.cpp +++ b/numpy/_core/src/multiarray/textreading/tokenize.cpp @@ -1,4 +1,6 @@ - +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/textreading/tokenize.h b/numpy/_core/src/multiarray/textreading/tokenize.h index 53e97760ff9e..8580817f48b2 100644 --- a/numpy/_core/src/multiarray/textreading/tokenize.h +++ b/numpy/_core/src/multiarray/textreading/tokenize.h @@ -2,6 +2,9 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_TOKENIZE_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_TOKENIZE_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/ndarraytypes.h" diff --git a/numpy/_core/src/multiarray/unique.cpp b/numpy/_core/src/multiarray/unique.cpp index 636f1ef0137c..9029531fa53b 100644 --- a/numpy/_core/src/multiarray/unique.cpp +++ b/numpy/_core/src/multiarray/unique.cpp @@ -2,6 +2,10 @@ #define _MULTIARRAYMODULE #define HASH_TABLE_INITIAL_BUCKETS 1024 + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/src/multiarray/usertypes.c b/numpy/_core/src/multiarray/usertypes.c index 445f7ad7fe67..d24913a0a7f1 100644 --- a/numpy/_core/src/multiarray/usertypes.c +++ b/numpy/_core/src/multiarray/usertypes.c @@ -23,6 +23,9 @@ maintainer email: oliphant.travis@ieee.org #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/vdot.c b/numpy/_core/src/multiarray/vdot.c index ff08ed2d4b07..cfc97fc5aa66 100644 --- a/numpy/_core/src/multiarray/vdot.c +++ b/numpy/_core/src/multiarray/vdot.c @@ -1,6 +1,9 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/npymath/npy_math_common.h b/numpy/_core/src/npymath/npy_math_common.h index 1f555a90a665..aaacb368e2cd 100644 --- a/numpy/_core/src/npymath/npy_math_common.h +++ b/numpy/_core/src/npymath/npy_math_common.h @@ -1,6 +1,10 @@ /* * Common headers needed by every npy math compilation unit */ + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/npymath/npy_math_private.h b/numpy/_core/src/npymath/npy_math_private.h index e55af987f3f3..79667ae2527f 100644 --- a/numpy/_core/src/npymath/npy_math_private.h +++ b/numpy/_core/src/npymath/npy_math_private.h @@ -18,6 +18,9 @@ #ifndef _NPY_MATH_PRIVATE_H_ #define _NPY_MATH_PRIVATE_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #ifdef __cplusplus #include diff --git a/numpy/_core/src/umath/_operand_flag_tests.c b/numpy/_core/src/umath/_operand_flag_tests.c index 5cdff6220280..c56ae22f8cba 100644 --- a/numpy/_core/src/umath/_operand_flag_tests.c +++ b/numpy/_core/src/umath/_operand_flag_tests.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/_rational_tests.c b/numpy/_core/src/umath/_rational_tests.c index d257bc22d051..ee52af7c0301 100644 --- a/numpy/_core/src/umath/_rational_tests.c +++ b/numpy/_core/src/umath/_rational_tests.c @@ -1,4 +1,8 @@ /* Fixed size rational numbers exposed to Python */ + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/umath/_struct_ufunc_tests.c b/numpy/_core/src/umath/_struct_ufunc_tests.c index 56c4be117e44..ec36b543ed28 100644 --- a/numpy/_core/src/umath/_struct_ufunc_tests.c +++ b/numpy/_core/src/umath/_struct_ufunc_tests.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/_umath_tests.c.src b/numpy/_core/src/umath/_umath_tests.c.src index 845f51ebc94f..4b61658c2d80 100644 --- a/numpy/_core/src/umath/_umath_tests.c.src +++ b/numpy/_core/src/umath/_umath_tests.c.src @@ -5,6 +5,9 @@ ** INCLUDES ** ***************************************************************************** */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/_umath_tests.dispatch.c b/numpy/_core/src/umath/_umath_tests.dispatch.c index e92356ac09f2..723e42949c3a 100644 --- a/numpy/_core/src/umath/_umath_tests.dispatch.c +++ b/numpy/_core/src/umath/_umath_tests.dispatch.c @@ -1,6 +1,9 @@ /** * Testing the utilities of the CPU dispatcher */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/dispatching.cpp b/numpy/_core/src/umath/dispatching.cpp index ba98a9b5c5d1..887db86fc96b 100644 --- a/numpy/_core/src/umath/dispatching.cpp +++ b/numpy/_core/src/umath/dispatching.cpp @@ -38,6 +38,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/umath/extobj.c b/numpy/_core/src/umath/extobj.c index 755d8665b11d..0e14b564e8f1 100644 --- a/numpy/_core/src/umath/extobj.c +++ b/numpy/_core/src/umath/extobj.c @@ -2,6 +2,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/legacy_array_method.c b/numpy/_core/src/umath/legacy_array_method.c index 705262fedd38..297b4ba52d0f 100644 --- a/numpy/_core/src/umath/legacy_array_method.c +++ b/numpy/_core/src/umath/legacy_array_method.c @@ -6,6 +6,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/loops.c.src b/numpy/_core/src/umath/loops.c.src index 3928d2a0d0c4..a4e580ce2efb 100644 --- a/numpy/_core/src/umath/loops.c.src +++ b/numpy/_core/src/umath/loops.c.src @@ -1,4 +1,7 @@ /* -*- c -*- */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/matmul.c.src b/numpy/_core/src/umath/matmul.c.src index 11e014acec7f..5ed0c2b22fb7 100644 --- a/numpy/_core/src/umath/matmul.c.src +++ b/numpy/_core/src/umath/matmul.c.src @@ -1,4 +1,7 @@ /* -*- c -*- */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/reduction.c b/numpy/_core/src/umath/reduction.c index b376b94936bc..fee7e9abd78a 100644 --- a/numpy/_core/src/umath/reduction.c +++ b/numpy/_core/src/umath/reduction.c @@ -10,6 +10,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/scalarmath.c.src b/numpy/_core/src/umath/scalarmath.c.src index a565eee8f939..2e93f658ab65 100644 --- a/numpy/_core/src/umath/scalarmath.c.src +++ b/numpy/_core/src/umath/scalarmath.c.src @@ -5,6 +5,9 @@ but still supports error-modes. */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/special_integer_comparisons.cpp b/numpy/_core/src/umath/special_integer_comparisons.cpp index 06babeeda0a8..14e5aa18018e 100644 --- a/numpy/_core/src/umath/special_integer_comparisons.cpp +++ b/numpy/_core/src/umath/special_integer_comparisons.cpp @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/umath/string_buffer.h b/numpy/_core/src/umath/string_buffer.h index dafedcbc03ff..75e03f15a2db 100644 --- a/numpy/_core/src/umath/string_buffer.h +++ b/numpy/_core/src/umath/string_buffer.h @@ -1,6 +1,9 @@ #ifndef _NPY_CORE_SRC_UMATH_STRING_BUFFER_H_ #define _NPY_CORE_SRC_UMATH_STRING_BUFFER_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/umath/string_fastsearch.h b/numpy/_core/src/umath/string_fastsearch.h index 95d0ee4fb214..634835244e5b 100644 --- a/numpy/_core/src/umath/string_fastsearch.h +++ b/numpy/_core/src/umath/string_fastsearch.h @@ -3,6 +3,9 @@ /* stringlib: fastsearch implementation taken from CPython */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/umath/string_ufuncs.cpp b/numpy/_core/src/umath/string_ufuncs.cpp index 95f30ccb109e..7813fcd21e67 100644 --- a/numpy/_core/src/umath/string_ufuncs.cpp +++ b/numpy/_core/src/umath/string_ufuncs.cpp @@ -1,4 +1,8 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include + #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/umath/stringdtype_ufuncs.cpp b/numpy/_core/src/umath/stringdtype_ufuncs.cpp index b0181d4186c9..1181a043897c 100644 --- a/numpy/_core/src/umath/stringdtype_ufuncs.cpp +++ b/numpy/_core/src/umath/stringdtype_ufuncs.cpp @@ -1,4 +1,8 @@ /* Ufunc implementations for the StringDType class */ + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/ufunc_object.c b/numpy/_core/src/umath/ufunc_object.c index 4cdde8d3d77d..c2f8e4a6af1c 100644 --- a/numpy/_core/src/umath/ufunc_object.c +++ b/numpy/_core/src/umath/ufunc_object.c @@ -27,6 +27,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/ufunc_type_resolution.c b/numpy/_core/src/umath/ufunc_type_resolution.c index 95670efb936f..80d500e24a3c 100644 --- a/numpy/_core/src/umath/ufunc_type_resolution.c +++ b/numpy/_core/src/umath/ufunc_type_resolution.c @@ -24,6 +24,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/umathmodule.c b/numpy/_core/src/umath/umathmodule.c index e5cf2cf8acb3..194b2771da68 100644 --- a/numpy/_core/src/umath/umathmodule.c +++ b/numpy/_core/src/umath/umathmodule.c @@ -10,6 +10,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/wrapping_array_method.c b/numpy/_core/src/umath/wrapping_array_method.c index 9b3970561f3f..ac92cb27a3bb 100644 --- a/numpy/_core/src/umath/wrapping_array_method.c +++ b/numpy/_core/src/umath/wrapping_array_method.c @@ -21,6 +21,9 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/tests/examples/limited_api/limited_api1.c b/numpy/_core/tests/examples/limited_api/limited_api1.c index 3dbf5698f1d4..e72ee28efa7a 100644 --- a/numpy/_core/tests/examples/limited_api/limited_api1.c +++ b/numpy/_core/tests/examples/limited_api/limited_api1.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define Py_LIMITED_API 0x03060000 #include diff --git a/numpy/_core/tests/examples/limited_api/limited_api_latest.c b/numpy/_core/tests/examples/limited_api/limited_api_latest.c index 92d83ea977a1..d9b5a8ad6e67 100644 --- a/numpy/_core/tests/examples/limited_api/limited_api_latest.c +++ b/numpy/_core/tests/examples/limited_api/limited_api_latest.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/f2py/src/fortranobject.h b/numpy/f2py/src/fortranobject.h index 4aed2f60891b..eb88c8e26a67 100644 --- a/numpy/f2py/src/fortranobject.h +++ b/numpy/f2py/src/fortranobject.h @@ -4,6 +4,9 @@ extern "C" { #endif +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #ifndef NPY_NO_DEPRECATED_API diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index 25866f1a40ec..7c5005a97e92 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -10,6 +10,9 @@ extern "C" { /*********************** See f2py2e/cfuncs.py: includes ***********************/ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include "fortranobject.h" diff --git a/numpy/fft/_pocketfft_umath.cpp b/numpy/fft/_pocketfft_umath.cpp index ab8af5aa522e..8147ef52e5ca 100644 --- a/numpy/fft/_pocketfft_umath.cpp +++ b/numpy/fft/_pocketfft_umath.cpp @@ -11,6 +11,9 @@ */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/linalg/lapack_lite/f2c.c b/numpy/linalg/lapack_lite/f2c.c index 47e4d5729b83..c6c9c3b8bbba 100644 --- a/numpy/linalg/lapack_lite/f2c.c +++ b/numpy/linalg/lapack_lite/f2c.c @@ -7,6 +7,9 @@ it is available, and shipping a static library isn't portable. */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/lapack_lite/f2c.h b/numpy/linalg/lapack_lite/f2c.h index 60bce4a9f575..09482f6fe5e9 100644 --- a/numpy/linalg/lapack_lite/f2c.h +++ b/numpy/linalg/lapack_lite/f2c.h @@ -7,6 +7,9 @@ #ifndef F2C_INCLUDE #define F2C_INCLUDE +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/lapack_lite/python_xerbla.c b/numpy/linalg/lapack_lite/python_xerbla.c index 71a4c81edbf1..49a5e90b2616 100644 --- a/numpy/linalg/lapack_lite/python_xerbla.c +++ b/numpy/linalg/lapack_lite/python_xerbla.c @@ -1,3 +1,6 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c index cad5f3f92f09..cd39dddc62b8 100644 --- a/numpy/linalg/lapack_litemodule.c +++ b/numpy/linalg/lapack_litemodule.c @@ -4,6 +4,9 @@ More modifications by Jeff Whitaker */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/umath_linalg.cpp b/numpy/linalg/umath_linalg.cpp index 1b6850145bc8..2077bf653d6d 100644 --- a/numpy/linalg/umath_linalg.cpp +++ b/numpy/linalg/umath_linalg.cpp @@ -5,6 +5,9 @@ ** INCLUDES ** ***************************************************************************** */ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/random/include/aligned_malloc.h b/numpy/random/include/aligned_malloc.h index 0fff57b6c44d..02f206ef41af 100644 --- a/numpy/random/include/aligned_malloc.h +++ b/numpy/random/include/aligned_malloc.h @@ -1,6 +1,9 @@ #ifndef _RANDOMDGEN__ALIGNED_MALLOC_H_ #define _RANDOMDGEN__ALIGNED_MALLOC_H_ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" From 83c46c9c187fc98c4bd057936390b97d6f7a77b2 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 27 Jun 2025 19:25:20 -0400 Subject: [PATCH 03/14] BUG: Move Python.h include first and add comments explaining why it should be there. --- numpy/_core/src/common/binop_override.h | 6 +++++- numpy/_core/src/common/npy_partition.h | 7 ++++++- numpy/_core/src/multiarray/refcount.c | 9 +++++++-- numpy/_core/src/umath/clip.cpp | 10 +++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/numpy/_core/src/common/binop_override.h b/numpy/_core/src/common/binop_override.h index a6b4747ca560..8060dcad88b2 100644 --- a/numpy/_core/src/common/binop_override.h +++ b/numpy/_core/src/common/binop_override.h @@ -1,8 +1,12 @@ #ifndef NUMPY_CORE_SRC_COMMON_BINOP_OVERRIDE_H_ #define NUMPY_CORE_SRC_COMMON_BINOP_OVERRIDE_H_ -#include +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ #include + +#include #include "numpy/arrayobject.h" #include "get_attr_string.h" diff --git a/numpy/_core/src/common/npy_partition.h b/numpy/_core/src/common/npy_partition.h index 57f834d9f0e1..8f769d50e5e2 100644 --- a/numpy/_core/src/common/npy_partition.h +++ b/numpy/_core/src/common/npy_partition.h @@ -1,11 +1,16 @@ #ifndef NUMPY_CORE_SRC_COMMON_PARTITION_H_ #define NUMPY_CORE_SRC_COMMON_PARTITION_H_ -#include "npy_sort.h" +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ /* Python include is for future object sorts */ #include +#include "npy_sort.h" + + #include #include diff --git a/numpy/_core/src/multiarray/refcount.c b/numpy/_core/src/multiarray/refcount.c index 571b50372684..8e7fce748516 100644 --- a/numpy/_core/src/multiarray/refcount.c +++ b/numpy/_core/src/multiarray/refcount.c @@ -2,6 +2,13 @@ * This module corresponds to the `Special functions for NPY_OBJECT` * section in the numpy reference for C-API. */ + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ +#define PY_SSIZE_T_CLEAN +#include + #include "array_method.h" #include "dtype_traversal.h" #include "lowlevel_strided_loops.h" @@ -9,8 +16,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -#define PY_SSIZE_T_CLEAN -#include #include #include "numpy/arrayobject.h" diff --git a/numpy/_core/src/umath/clip.cpp b/numpy/_core/src/umath/clip.cpp index e051692c6d48..be373f67b3ff 100644 --- a/numpy/_core/src/umath/clip.cpp +++ b/numpy/_core/src/umath/clip.cpp @@ -1,15 +1,19 @@ /** * This module provides the inner loops for the clip ufunc */ + +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ +#define PY_SSIZE_T_CLEAN +#include + #include #define _UMATHMODULE #define _MULTIARRAYMODULE #define NPY_NO_DEPRECATED_API NPY_API_VERSION -#define PY_SSIZE_T_CLEAN -#include - #include "numpy/halffloat.h" #include "numpy/ndarraytypes.h" #include "numpy/npy_common.h" From 79ab7673af83fc04cc9dfed74a10184661c159e1 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 27 Jun 2025 19:29:33 -0400 Subject: [PATCH 04/14] STY: Include Python.h explicitly and add comments explaining why it's there. --- numpy/_core/src/common/blas_utils.c | 5 +++++ numpy/_core/src/common/blas_utils.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/numpy/_core/src/common/blas_utils.c b/numpy/_core/src/common/blas_utils.c index 25824ead00b6..7605bfe55ec5 100644 --- a/numpy/_core/src/common/blas_utils.c +++ b/numpy/_core/src/common/blas_utils.c @@ -1,3 +1,8 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ +#include + #include "numpy/numpyconfig.h" // NPY_VISIBILITY_HIDDEN #include "numpy/npy_math.h" // npy_get_floatstatus_barrier #include "blas_utils.h" diff --git a/numpy/_core/src/common/blas_utils.h b/numpy/_core/src/common/blas_utils.h index 34d6321c2920..a0154cf207b7 100644 --- a/numpy/_core/src/common/blas_utils.h +++ b/numpy/_core/src/common/blas_utils.h @@ -1,3 +1,8 @@ +/* Any file that includes Python.h must include it before any other files */ +/* https://docs.python.org/3/extending/extending.html#a-simple-example */ +/* npy_common.h includes Python.h so it also counts in this list */ +#include + #include "numpy/numpyconfig.h" // for NPY_VISIBILITY_HIDDEN #include From efbe8ee5300cb8785f677472ff694f5ca6b445aa Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 1 Jul 2025 07:14:10 -0400 Subject: [PATCH 05/14] DEV: Add Python.h linter check to azure lint job --- azure-pipelines.yml | 3 + tools/check_python_h_first.py | 201 ++++++++++++++++++++++++++++++++++ tools/get_submodule_paths.py | 23 ++++ 3 files changed, 227 insertions(+) create mode 100755 tools/check_python_h_first.py create mode 100644 tools/get_submodule_paths.py diff --git a/azure-pipelines.yml b/azure-pipelines.yml index af6e5cf52ac4..89dee2267352 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -56,6 +56,9 @@ stages: python tools/linter.py displayName: 'Run Lint Checks' failOnStderr: true + - script: | + python tools/check_python_h_first.py + displayName: 'Check Python.h is first file included' - job: Linux_Python_311_32bit_full_with_asserts pool: diff --git a/tools/check_python_h_first.py b/tools/check_python_h_first.py new file mode 100755 index 000000000000..007edca33748 --- /dev/null +++ b/tools/check_python_h_first.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python +"""Check that Python.h is included before any stdlib headers. + +May be a bit overzealous, but it should get the job done. +""" +import argparse +import fnmatch +import os.path +import re +import subprocess +import sys +from get_submodule_paths import get_submodule_paths + +HEADER_PATTERN = re.compile( + r'^\s*#\s*include\s*[<"]((?:\w+/)*\w+(?:\.h[hp+]{0,2})?)[>"]\s*$' +) + +PYTHON_INCLUDING_HEADERS = [ + "Python.h", + # This isn't all of Python.h, but it is the visibility macros + "pyconfig.h", + "numpy/arrayobject.h", + "numpy/ndarrayobject.h", + "numpy/npy_common.h", + "numpy/npy_math.h", + "numpy/random/distributions.h", + # Boost::Python + "boost/python.hpp", +] +LEAF_HEADERS = [] + +C_CPP_EXTENSIONS = (".c", ".h", ".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx") +# check against list in diff_files + +PARSER = argparse.ArgumentParser(description=__doc__) +PARSER.add_argument( + "files", + nargs="*", + help="Lint these files or directories; " "use **/*.py to lint all files", +) + + +def check_python_h_included_first(name_to_check: str) -> int: + """Check that the passed file includes Python.h first if it does at all. + + Perhaps overzealous, but that should work around concerns with + recursion. + + Parameters + ---------- + name_to_check : str + The name of the file to check. + + Returns + ------- + int + The number of headers before Python.h + """ + included_python = False + included_non_python_header = [] + warned_python_construct = False + basename_to_check = os.path.basename(name_to_check) + in_comment = False + includes_headers = False + with open(name_to_check) as in_file: + for i, line in enumerate(in_file, 1): + # Very basic comment parsing + # Assumes /*...*/ comments are on their own lines + if "/*" in line: + if "*/" not in line: + in_comment = True + # else-branch could use regex to remove comment and continue + continue + if in_comment: + if "*/" in line: + in_comment = False + continue + match = HEADER_PATTERN.match(line) + if match: + includes_headers = True + this_header = match.group(1) + if this_header in PYTHON_INCLUDING_HEADERS: + if included_non_python_header and not included_python: + print( + f"Header before Python.h in file {name_to_check:s}\n" + f"Python.h on line {i:d}, other header(s) on line(s)" + f" {included_non_python_header}", + file=sys.stderr, + ) + included_python = True + PYTHON_INCLUDING_HEADERS.append(basename_to_check) + elif not included_python and ( + "numpy" in this_header + and this_header != "numpy/utils.h" + or "python" in this_header + ): + print( + f"Python.h not included before python-including header " + f"in file {name_to_check:s}\n" + f"{this_header:s} on line {i:d}", + file=sys.stderr, + ) + elif not included_python and this_header not in LEAF_HEADERS: + included_non_python_header.append(i) + elif ( + not included_python + and not warned_python_construct + and ".h" not in basename_to_check + ) and ("py::" in line or "PYBIND11_" in line or "npy_" in line): + print( + "Python-including header not used before python constructs " + f"in file {name_to_check:s}\nConstruct on line {i:d}", + file=sys.stderr, + ) + warned_python_construct = True + if includes_headers: + LEAF_HEADERS.append(this_header) + return included_python and len(included_non_python_header) + + +def process_files(file_list: list[str]) -> int: + n_out_of_order = 0 + submodule_paths = get_submodule_paths() + root_directory = os.path.dirname(os.path.dirname(__file__)) + for name_to_check in sorted( + file_list, key=lambda name: "h" not in os.path.splitext(name)[1].lower() + ): + name_to_check = os.path.join(root_directory, name_to_check) + if any(submodule_path in name_to_check for submodule_path in submodule_paths): + continue + try: + n_out_of_order += check_python_h_included_first(name_to_check) + except UnicodeDecodeError: + print(f"File {name_to_check:s} not utf-8", sys.stdout) + return n_out_of_order + + +def find_c_cpp_files(root: str) -> list[str]: + + result = [] + + for dirpath, dirnames, filenames in os.walk("scipy"): + # I'm assuming other people have checked boost + for name in ("build", ".git", "boost"): + try: + dirnames.remove(name) + except ValueError: + pass + for name in fnmatch.filter(dirnames, "*.p"): + dirnames.remove(name) + result.extend( + [ + os.path.join(dirpath, name) + for name in filenames + if os.path.splitext(name)[1].lower() in C_CPP_EXTENSIONS + ] + ) + # Check the headers before the source files + result.sort(key=lambda path: "h" in os.path.splitext(path)[1], reverse=True) + return result + + +def diff_files(sha: str) -> list[str]: + """Find the diff since the given SHA. + + Adapted from lint.py + """ + res = subprocess.run( + [ + "git", + "diff", + "--name-only", + "--diff-filter=ACMR", + "-z", + sha, + "--", + # Check against C_CPP_EXTENSIONS + "*.[chCH]", + "*.[ch]pp", + "*.[ch]xx", + "*.cc", + "*.hh", + ], + stdout=subprocess.PIPE, + encoding="utf-8", + ) + res.check_returncode() + return [f for f in res.stdout.split("\0") if f] + + +if __name__ == "__main__": + args = PARSER.parse_args() + + if not (len(args.files) == 0): + files = find_c_cpp_files("numpy") + else: + files = args.files + + # See which of the headers include Python.h and add them to the list + n_out_of_order = process_files(files) + sys.exit(n_out_of_order) diff --git a/tools/get_submodule_paths.py b/tools/get_submodule_paths.py new file mode 100644 index 000000000000..9cff4f3cdc58 --- /dev/null +++ b/tools/get_submodule_paths.py @@ -0,0 +1,23 @@ +import os + + +def get_submodule_paths(): + ''' + Get paths to submodules so that we can exclude them from things like + check_test_name.py, check_unicode.py, etc. + ''' + root_directory = os.path.dirname(os.path.dirname(__file__)) + gitmodule_file = os.path.join(root_directory, '.gitmodules') + with open(gitmodule_file) as gitmodules: + data = gitmodules.read().split('\n') + submodule_paths = [datum.split(' = ')[1] for datum in data if + datum.startswith('\tpath = ')] + submodule_paths = [os.path.join(root_directory, path) for path in + submodule_paths] + # vendored with a script rather than via gitmodules + submodule_paths.append(os.path.join(root_directory, 'scipy/_lib/pyprima')) + return submodule_paths + + +if __name__ == "__main__": + print('\n'.join(get_submodule_paths())) From 2b7b322275d8342fb7cc0833d54141a95db5e437 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 1 Jul 2025 07:15:19 -0400 Subject: [PATCH 06/14] Revert "BUG: Move Python.h include first and add comments explaining why it should be there." This reverts commit 83c46c9c187fc98c4bd057936390b97d6f7a77b2. --- numpy/_core/src/common/binop_override.h | 6 +----- numpy/_core/src/common/npy_partition.h | 7 +------ numpy/_core/src/multiarray/refcount.c | 9 ++------- numpy/_core/src/umath/clip.cpp | 10 +++------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/numpy/_core/src/common/binop_override.h b/numpy/_core/src/common/binop_override.h index 8060dcad88b2..a6b4747ca560 100644 --- a/numpy/_core/src/common/binop_override.h +++ b/numpy/_core/src/common/binop_override.h @@ -1,12 +1,8 @@ #ifndef NUMPY_CORE_SRC_COMMON_BINOP_OVERRIDE_H_ #define NUMPY_CORE_SRC_COMMON_BINOP_OVERRIDE_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ -#include - #include +#include #include "numpy/arrayobject.h" #include "get_attr_string.h" diff --git a/numpy/_core/src/common/npy_partition.h b/numpy/_core/src/common/npy_partition.h index 8f769d50e5e2..57f834d9f0e1 100644 --- a/numpy/_core/src/common/npy_partition.h +++ b/numpy/_core/src/common/npy_partition.h @@ -1,16 +1,11 @@ #ifndef NUMPY_CORE_SRC_COMMON_PARTITION_H_ #define NUMPY_CORE_SRC_COMMON_PARTITION_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ +#include "npy_sort.h" /* Python include is for future object sorts */ #include -#include "npy_sort.h" - - #include #include diff --git a/numpy/_core/src/multiarray/refcount.c b/numpy/_core/src/multiarray/refcount.c index 8e7fce748516..571b50372684 100644 --- a/numpy/_core/src/multiarray/refcount.c +++ b/numpy/_core/src/multiarray/refcount.c @@ -2,13 +2,6 @@ * This module corresponds to the `Special functions for NPY_OBJECT` * section in the numpy reference for C-API. */ - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ -#define PY_SSIZE_T_CLEAN -#include - #include "array_method.h" #include "dtype_traversal.h" #include "lowlevel_strided_loops.h" @@ -16,6 +9,8 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE +#define PY_SSIZE_T_CLEAN +#include #include #include "numpy/arrayobject.h" diff --git a/numpy/_core/src/umath/clip.cpp b/numpy/_core/src/umath/clip.cpp index be373f67b3ff..e051692c6d48 100644 --- a/numpy/_core/src/umath/clip.cpp +++ b/numpy/_core/src/umath/clip.cpp @@ -1,19 +1,15 @@ /** * This module provides the inner loops for the clip ufunc */ - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ -#define PY_SSIZE_T_CLEAN -#include - #include #define _UMATHMODULE #define _MULTIARRAYMODULE #define NPY_NO_DEPRECATED_API NPY_API_VERSION +#define PY_SSIZE_T_CLEAN +#include + #include "numpy/halffloat.h" #include "numpy/ndarraytypes.h" #include "numpy/npy_common.h" From b8efa92c89320f3b119fa616f6bc55eb1eec0353 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 1 Jul 2025 07:15:30 -0400 Subject: [PATCH 07/14] Revert "STY: Include Python.h explicitly and add comments explaining why it's there." This reverts commit 79ab7673af83fc04cc9dfed74a10184661c159e1. --- numpy/_core/src/common/blas_utils.c | 5 ----- numpy/_core/src/common/blas_utils.h | 5 ----- 2 files changed, 10 deletions(-) diff --git a/numpy/_core/src/common/blas_utils.c b/numpy/_core/src/common/blas_utils.c index 7605bfe55ec5..25824ead00b6 100644 --- a/numpy/_core/src/common/blas_utils.c +++ b/numpy/_core/src/common/blas_utils.c @@ -1,8 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ -#include - #include "numpy/numpyconfig.h" // NPY_VISIBILITY_HIDDEN #include "numpy/npy_math.h" // npy_get_floatstatus_barrier #include "blas_utils.h" diff --git a/numpy/_core/src/common/blas_utils.h b/numpy/_core/src/common/blas_utils.h index a0154cf207b7..34d6321c2920 100644 --- a/numpy/_core/src/common/blas_utils.h +++ b/numpy/_core/src/common/blas_utils.h @@ -1,8 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ -#include - #include "numpy/numpyconfig.h" // for NPY_VISIBILITY_HIDDEN #include From 208e64f288e1fb5f3aedf18d8a7375842622a7e1 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 1 Jul 2025 07:36:23 -0400 Subject: [PATCH 08/14] STY: Style fixes requested by linter --- tools/check_python_h_first.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/check_python_h_first.py b/tools/check_python_h_first.py index 007edca33748..79b755cb4332 100755 --- a/tools/check_python_h_first.py +++ b/tools/check_python_h_first.py @@ -9,6 +9,7 @@ import re import subprocess import sys + from get_submodule_paths import get_submodule_paths HEADER_PATTERN = re.compile( @@ -36,7 +37,7 @@ PARSER.add_argument( "files", nargs="*", - help="Lint these files or directories; " "use **/*.py to lint all files", + help="Lint these files or directories; use **/*.py to lint all files", ) From d2bc1e5ad6276ab4024cb5dbe4168aae6847617d Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 1 Jul 2025 18:26:40 -0400 Subject: [PATCH 09/14] Revert "STY: Add comments noting that Python.h should be included first." This reverts commit e7b47cf9762ca4b39d3179e2e900271c36cfa763. --- numpy/_core/include/numpy/halffloat.h | 3 --- numpy/_core/include/numpy/ndarrayobject.h | 3 --- numpy/_core/include/numpy/npy_3kcompat.h | 3 --- numpy/_core/include/numpy/npy_common.h | 3 --- numpy/_core/include/numpy/random/distributions.h | 3 --- numpy/_core/src/_simd/_simd.h | 3 --- numpy/_core/src/_simd/_simd_inc.h.src | 3 --- numpy/_core/src/common/array_assign.c | 3 --- numpy/_core/src/common/cblasfuncs.c | 3 --- numpy/_core/src/common/get_attr_string.h | 3 --- numpy/_core/src/common/gil_utils.c | 3 --- numpy/_core/src/common/mem_overlap.c | 3 --- numpy/_core/src/common/npy_argparse.c | 3 --- numpy/_core/src/common/npy_argparse.h | 3 --- numpy/_core/src/common/npy_cpu_features.h | 3 --- numpy/_core/src/common/npy_ctypes.h | 3 --- numpy/_core/src/common/npy_dlpack.h | 3 --- numpy/_core/src/common/npy_hashtable.h | 3 --- numpy/_core/src/common/npy_import.h | 3 --- numpy/_core/src/common/npy_longdouble.c | 3 --- numpy/_core/src/common/npy_sort.h.src | 3 --- numpy/_core/src/common/numpyos.c | 3 --- numpy/_core/src/common/python_xerbla.c | 3 --- numpy/_core/src/dummymodule.c | 3 --- numpy/_core/src/multiarray/_multiarray_tests.c.src | 3 --- numpy/_core/src/multiarray/abstractdtypes.c | 3 --- numpy/_core/src/multiarray/alloc.c | 3 --- numpy/_core/src/multiarray/array_assign_array.c | 3 --- numpy/_core/src/multiarray/array_assign_scalar.c | 3 --- numpy/_core/src/multiarray/array_coercion.c | 3 --- numpy/_core/src/multiarray/array_converter.c | 3 --- numpy/_core/src/multiarray/array_method.h | 3 --- numpy/_core/src/multiarray/arrayfunction_override.c | 3 --- numpy/_core/src/multiarray/arrayobject.c | 3 --- numpy/_core/src/multiarray/arraytypes.c.src | 3 --- numpy/_core/src/multiarray/arraywrap.c | 3 --- numpy/_core/src/multiarray/buffer.c | 3 --- numpy/_core/src/multiarray/calculation.c | 3 --- numpy/_core/src/multiarray/common.c | 3 --- numpy/_core/src/multiarray/common_dtype.c | 3 --- numpy/_core/src/multiarray/compiled_base.c | 3 --- numpy/_core/src/multiarray/conversion_utils.c | 3 --- numpy/_core/src/multiarray/convert.c | 3 --- numpy/_core/src/multiarray/convert_datatype.c | 3 --- numpy/_core/src/multiarray/ctors.c | 3 --- numpy/_core/src/multiarray/datetime.c | 3 --- numpy/_core/src/multiarray/datetime_busday.c | 3 --- numpy/_core/src/multiarray/datetime_busdaycal.c | 3 --- numpy/_core/src/multiarray/datetime_strings.c | 3 --- numpy/_core/src/multiarray/descriptor.c | 3 --- numpy/_core/src/multiarray/dlpack.c | 3 --- numpy/_core/src/multiarray/dragon4.h | 3 --- numpy/_core/src/multiarray/dtype_transfer.c | 3 --- numpy/_core/src/multiarray/dtype_traversal.c | 3 --- numpy/_core/src/multiarray/dtypemeta.c | 3 --- numpy/_core/src/multiarray/einsum.c.src | 3 --- numpy/_core/src/multiarray/flagsobject.c | 3 --- numpy/_core/src/multiarray/fnv.c | 3 --- numpy/_core/src/multiarray/getset.c | 3 --- numpy/_core/src/multiarray/hashdescr.c | 3 --- numpy/_core/src/multiarray/item_selection.c | 3 --- numpy/_core/src/multiarray/iterators.c | 3 --- numpy/_core/src/multiarray/lowlevel_strided_loops.c.src | 3 --- numpy/_core/src/multiarray/mapping.c | 3 --- numpy/_core/src/multiarray/methods.c | 3 --- numpy/_core/src/multiarray/multiarraymodule.c | 3 --- numpy/_core/src/multiarray/nditer_impl.h | 3 --- numpy/_core/src/multiarray/nditer_pywrap.c | 3 --- numpy/_core/src/multiarray/npy_static_data.c | 3 --- numpy/_core/src/multiarray/number.c | 3 --- numpy/_core/src/multiarray/public_dtype_api.c | 3 --- numpy/_core/src/multiarray/scalarapi.c | 3 --- numpy/_core/src/multiarray/scalartypes.c.src | 3 --- numpy/_core/src/multiarray/sequence.c | 3 --- numpy/_core/src/multiarray/shape.c | 3 --- numpy/_core/src/multiarray/strfuncs.c | 3 --- numpy/_core/src/multiarray/stringdtype/casts.cpp | 3 --- numpy/_core/src/multiarray/stringdtype/dtype.c | 4 ---- numpy/_core/src/multiarray/stringdtype/static_string.c | 3 --- numpy/_core/src/multiarray/stringdtype/utf8_utils.c | 3 --- numpy/_core/src/multiarray/temp_elide.c | 3 --- numpy/_core/src/multiarray/textreading/conversions.c | 4 +--- numpy/_core/src/multiarray/textreading/field_types.h | 3 --- numpy/_core/src/multiarray/textreading/readtext.c | 3 --- numpy/_core/src/multiarray/textreading/rows.c | 4 +--- numpy/_core/src/multiarray/textreading/rows.h | 3 --- numpy/_core/src/multiarray/textreading/str_to_int.c | 4 +--- numpy/_core/src/multiarray/textreading/stream_pyobject.c | 3 --- numpy/_core/src/multiarray/textreading/stream_pyobject.h | 3 --- numpy/_core/src/multiarray/textreading/tokenize.cpp | 4 +--- numpy/_core/src/multiarray/textreading/tokenize.h | 3 --- numpy/_core/src/multiarray/unique.cpp | 4 ---- numpy/_core/src/multiarray/usertypes.c | 3 --- numpy/_core/src/multiarray/vdot.c | 3 --- numpy/_core/src/npymath/npy_math_common.h | 4 ---- numpy/_core/src/npymath/npy_math_private.h | 3 --- numpy/_core/src/umath/_operand_flag_tests.c | 3 --- numpy/_core/src/umath/_rational_tests.c | 4 ---- numpy/_core/src/umath/_struct_ufunc_tests.c | 3 --- numpy/_core/src/umath/_umath_tests.c.src | 3 --- numpy/_core/src/umath/_umath_tests.dispatch.c | 3 --- numpy/_core/src/umath/dispatching.cpp | 3 --- numpy/_core/src/umath/extobj.c | 3 --- numpy/_core/src/umath/legacy_array_method.c | 3 --- numpy/_core/src/umath/loops.c.src | 3 --- numpy/_core/src/umath/matmul.c.src | 3 --- numpy/_core/src/umath/reduction.c | 3 --- numpy/_core/src/umath/scalarmath.c.src | 3 --- numpy/_core/src/umath/special_integer_comparisons.cpp | 3 --- numpy/_core/src/umath/string_buffer.h | 3 --- numpy/_core/src/umath/string_fastsearch.h | 3 --- numpy/_core/src/umath/string_ufuncs.cpp | 4 ---- numpy/_core/src/umath/stringdtype_ufuncs.cpp | 4 ---- numpy/_core/src/umath/ufunc_object.c | 3 --- numpy/_core/src/umath/ufunc_type_resolution.c | 3 --- numpy/_core/src/umath/umathmodule.c | 3 --- numpy/_core/src/umath/wrapping_array_method.c | 3 --- numpy/_core/tests/examples/limited_api/limited_api1.c | 3 --- numpy/_core/tests/examples/limited_api/limited_api_latest.c | 3 --- numpy/f2py/src/fortranobject.h | 3 --- numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c | 3 --- numpy/fft/_pocketfft_umath.cpp | 3 --- numpy/linalg/lapack_lite/f2c.c | 3 --- numpy/linalg/lapack_lite/f2c.h | 3 --- numpy/linalg/lapack_lite/python_xerbla.c | 3 --- numpy/linalg/lapack_litemodule.c | 3 --- numpy/linalg/umath_linalg.cpp | 3 --- numpy/random/include/aligned_malloc.h | 3 --- 128 files changed, 4 insertions(+), 390 deletions(-) diff --git a/numpy/_core/include/numpy/halffloat.h b/numpy/_core/include/numpy/halffloat.h index 4468128d133f..950401664e10 100644 --- a/numpy/_core/include/numpy/halffloat.h +++ b/numpy/_core/include/numpy/halffloat.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_ #define NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/include/numpy/ndarrayobject.h b/numpy/_core/include/numpy/ndarrayobject.h index c1bb38365084..f06bafe5b52a 100644 --- a/numpy/_core/include/numpy/ndarrayobject.h +++ b/numpy/_core/include/numpy/ndarrayobject.h @@ -8,9 +8,6 @@ extern "C" { #endif -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "ndarraytypes.h" #include "dtype_api.h" diff --git a/numpy/_core/include/numpy/npy_3kcompat.h b/numpy/_core/include/numpy/npy_3kcompat.h index b3c0c37b6e6b..c2bf74faf09d 100644 --- a/numpy/_core/include/numpy/npy_3kcompat.h +++ b/numpy/_core/include/numpy/npy_3kcompat.h @@ -11,9 +11,6 @@ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/include/numpy/npy_common.h b/numpy/_core/include/numpy/npy_common.h index ff74981db36b..5eaa29035428 100644 --- a/numpy/_core/include/numpy/npy_common.h +++ b/numpy/_core/include/numpy/npy_common.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ /* need Python.h for npy_intp, npy_uintp */ #include diff --git a/numpy/_core/include/numpy/random/distributions.h b/numpy/_core/include/numpy/random/distributions.h index ea81207cb9e6..e7fa4bd00d43 100644 --- a/numpy/_core/include/numpy/random/distributions.h +++ b/numpy/_core/include/numpy/random/distributions.h @@ -5,9 +5,6 @@ extern "C" { #endif -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" #include diff --git a/numpy/_core/src/_simd/_simd.h b/numpy/_core/src/_simd/_simd.h index 2c454e4dff70..82a4451cc3a2 100644 --- a/numpy/_core/src/_simd/_simd.h +++ b/numpy/_core/src/_simd/_simd.h @@ -12,9 +12,6 @@ #ifndef _SIMD_SIMD_H_ #define _SIMD_SIMD_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" #include "npy_cpu_features.h" diff --git a/numpy/_core/src/_simd/_simd_inc.h.src b/numpy/_core/src/_simd/_simd_inc.h.src index d7c43bdf68a4..a023848831ed 100644 --- a/numpy/_core/src/_simd/_simd_inc.h.src +++ b/numpy/_core/src/_simd/_simd_inc.h.src @@ -1,9 +1,6 @@ #ifndef _SIMD_SIMD_INC_H_ #define _SIMD_SIMD_INC_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "simd/simd.h" diff --git a/numpy/_core/src/common/array_assign.c b/numpy/_core/src/common/array_assign.c index 64cf91037bdd..3c6d2f14cb65 100644 --- a/numpy/_core/src/common/array_assign.c +++ b/numpy/_core/src/common/array_assign.c @@ -10,9 +10,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/cblasfuncs.c b/numpy/_core/src/common/cblasfuncs.c index 8522b214a4c3..66a215dfeb64 100644 --- a/numpy/_core/src/common/cblasfuncs.c +++ b/numpy/_core/src/common/cblasfuncs.c @@ -6,9 +6,6 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/get_attr_string.h b/numpy/_core/src/common/get_attr_string.h index e7889df27a3f..324a92c5ef0c 100644 --- a/numpy/_core/src/common/get_attr_string.h +++ b/numpy/_core/src/common/get_attr_string.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_SRC_COMMON_GET_ATTR_STRING_H_ #define NUMPY_CORE_SRC_COMMON_GET_ATTR_STRING_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "npy_pycompat.h" diff --git a/numpy/_core/src/common/gil_utils.c b/numpy/_core/src/common/gil_utils.c index 15f3ce67ec51..95af26a2bf8e 100644 --- a/numpy/_core/src/common/gil_utils.c +++ b/numpy/_core/src/common/gil_utils.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/mem_overlap.c b/numpy/_core/src/common/mem_overlap.c index 1654ada5470f..d5b734cad120 100644 --- a/numpy/_core/src/common/mem_overlap.c +++ b/numpy/_core/src/common/mem_overlap.c @@ -183,9 +183,6 @@ */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/npy_argparse.c b/numpy/_core/src/common/npy_argparse.c index 8f42e87a0a28..6766b17043ac 100644 --- a/numpy/_core/src/common/npy_argparse.c +++ b/numpy/_core/src/common/npy_argparse.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/npy_argparse.h b/numpy/_core/src/common/npy_argparse.h index eaa5afae014e..e1eef918cb33 100644 --- a/numpy/_core/src/common/npy_argparse.h +++ b/numpy/_core/src/common/npy_argparse.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_ARGPARSE_H #define NUMPY_CORE_SRC_COMMON_NPY_ARGPARSE_H -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/ndarraytypes.h" diff --git a/numpy/_core/src/common/npy_cpu_features.h b/numpy/_core/src/common/npy_cpu_features.h index 173b906060c5..7d6a406f8789 100644 --- a/numpy/_core/src/common/npy_cpu_features.h +++ b/numpy/_core/src/common/npy_cpu_features.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_CPU_FEATURES_H_ #define NUMPY_CORE_SRC_COMMON_NPY_CPU_FEATURES_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include // for PyObject #include "numpy/numpyconfig.h" // for NPY_VISIBILITY_HIDDEN diff --git a/numpy/_core/src/common/npy_ctypes.h b/numpy/_core/src/common/npy_ctypes.h index ee1bf4409e02..78809732416c 100644 --- a/numpy/_core/src/common/npy_ctypes.h +++ b/numpy/_core/src/common/npy_ctypes.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_CTYPES_H_ #define NUMPY_CORE_SRC_COMMON_NPY_CTYPES_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "npy_import.h" diff --git a/numpy/_core/src/common/npy_dlpack.h b/numpy/_core/src/common/npy_dlpack.h index 7e026f9e0a78..1dd3ae7f88e5 100644 --- a/numpy/_core/src/common/npy_dlpack.h +++ b/numpy/_core/src/common/npy_dlpack.h @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include "Python.h" #include "dlpack/dlpack.h" diff --git a/numpy/_core/src/common/npy_hashtable.h b/numpy/_core/src/common/npy_hashtable.h index c729bc27e7c6..cd061ba6fa11 100644 --- a/numpy/_core/src/common/npy_hashtable.h +++ b/numpy/_core/src/common/npy_hashtable.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_NPY_HASHTABLE_H_ #define NUMPY_CORE_SRC_COMMON_NPY_NPY_HASHTABLE_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/common/npy_import.h b/numpy/_core/src/common/npy_import.h index f657a4b7b4a2..970efa8f549e 100644 --- a/numpy/_core/src/common/npy_import.h +++ b/numpy/_core/src/common/npy_import.h @@ -1,9 +1,6 @@ #ifndef NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ #define NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" diff --git a/numpy/_core/src/common/npy_longdouble.c b/numpy/_core/src/common/npy_longdouble.c index 0fe7d16e0565..ce80a9ae2bc3 100644 --- a/numpy/_core/src/common/npy_longdouble.c +++ b/numpy/_core/src/common/npy_longdouble.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/npy_sort.h.src b/numpy/_core/src/common/npy_sort.h.src index cef966c99237..d6e4357225a8 100644 --- a/numpy/_core/src/common/npy_sort.h.src +++ b/numpy/_core/src/common/npy_sort.h.src @@ -2,9 +2,6 @@ #define __NPY_SORT_H__ /* Python include is for future object sorts */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/common/numpyos.c b/numpy/_core/src/common/numpyos.c index 5bd3de4d1178..a5ca28081d52 100644 --- a/numpy/_core/src/common/numpyos.c +++ b/numpy/_core/src/common/numpyos.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/common/python_xerbla.c b/numpy/_core/src/common/python_xerbla.c index 49a5e90b2616..71a4c81edbf1 100644 --- a/numpy/_core/src/common/python_xerbla.c +++ b/numpy/_core/src/common/python_xerbla.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/dummymodule.c b/numpy/_core/src/dummymodule.c index 0fdff1427991..e1ef80ab3af3 100644 --- a/numpy/_core/src/dummymodule.c +++ b/numpy/_core/src/dummymodule.c @@ -7,9 +7,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define NO_IMPORT_ARRAY -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/_multiarray_tests.c.src b/numpy/_core/src/multiarray/_multiarray_tests.c.src index 52829adf407e..8012a32b070e 100644 --- a/numpy/_core/src/multiarray/_multiarray_tests.c.src +++ b/numpy/_core/src/multiarray/_multiarray_tests.c.src @@ -1,7 +1,4 @@ /* -*-c-*- */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/abstractdtypes.c b/numpy/_core/src/multiarray/abstractdtypes.c index bd024ad1eaab..120ada551e7f 100644 --- a/numpy/_core/src/multiarray/abstractdtypes.c +++ b/numpy/_core/src/multiarray/abstractdtypes.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/alloc.c b/numpy/_core/src/multiarray/alloc.c index c4a5de2d751b..cc9c5762a196 100644 --- a/numpy/_core/src/multiarray/alloc.c +++ b/numpy/_core/src/multiarray/alloc.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/array_assign_array.c b/numpy/_core/src/multiarray/array_assign_array.c index b5b5ec61532e..8886d1cacb40 100644 --- a/numpy/_core/src/multiarray/array_assign_array.c +++ b/numpy/_core/src/multiarray/array_assign_array.c @@ -10,9 +10,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/array_assign_scalar.c b/numpy/_core/src/multiarray/array_assign_scalar.c index 4652ff076d64..0199ba969eb9 100644 --- a/numpy/_core/src/multiarray/array_assign_scalar.c +++ b/numpy/_core/src/multiarray/array_assign_scalar.c @@ -10,9 +10,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/array_coercion.c b/numpy/_core/src/multiarray/array_coercion.c index 286a69ab72cf..ff7d98bd9c64 100644 --- a/numpy/_core/src/multiarray/array_coercion.c +++ b/numpy/_core/src/multiarray/array_coercion.c @@ -2,9 +2,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/array_converter.c b/numpy/_core/src/multiarray/array_converter.c index 5523c456b11c..496173038954 100644 --- a/numpy/_core/src/multiarray/array_converter.c +++ b/numpy/_core/src/multiarray/array_converter.c @@ -8,9 +8,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/array_method.h b/numpy/_core/src/multiarray/array_method.h index f3e983e204a0..bcf270899f13 100644 --- a/numpy/_core/src/multiarray/array_method.h +++ b/numpy/_core/src/multiarray/array_method.h @@ -4,9 +4,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/src/multiarray/arrayfunction_override.c b/numpy/_core/src/multiarray/arrayfunction_override.c index 0f298f331456..9834ab138cf6 100644 --- a/numpy/_core/src/multiarray/arrayfunction_override.c +++ b/numpy/_core/src/multiarray/arrayfunction_override.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "structmember.h" diff --git a/numpy/_core/src/multiarray/arrayobject.c b/numpy/_core/src/multiarray/arrayobject.c index 43c58b5808f9..6f520fd6abbb 100644 --- a/numpy/_core/src/multiarray/arrayobject.c +++ b/numpy/_core/src/multiarray/arrayobject.c @@ -23,9 +23,6 @@ maintainer email: oliphant.travis@ieee.org #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/arraytypes.c.src b/numpy/_core/src/multiarray/arraytypes.c.src index aee1ce0f1125..9e5588f98a83 100644 --- a/numpy/_core/src/multiarray/arraytypes.c.src +++ b/numpy/_core/src/multiarray/arraytypes.c.src @@ -1,7 +1,4 @@ /* -*- c -*- */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/arraywrap.c b/numpy/_core/src/multiarray/arraywrap.c index f54c22da102d..09e46bd4d3e7 100644 --- a/numpy/_core/src/multiarray/arraywrap.c +++ b/numpy/_core/src/multiarray/arraywrap.c @@ -5,9 +5,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/arrayobject.h" diff --git a/numpy/_core/src/multiarray/buffer.c b/numpy/_core/src/multiarray/buffer.c index b68a6b2f6c3f..fcff3ad6ca74 100644 --- a/numpy/_core/src/multiarray/buffer.c +++ b/numpy/_core/src/multiarray/buffer.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/calculation.c b/numpy/_core/src/multiarray/calculation.c index b8dff3ca03ac..87f03a94fa5f 100644 --- a/numpy/_core/src/multiarray/calculation.c +++ b/numpy/_core/src/multiarray/calculation.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/common.c b/numpy/_core/src/multiarray/common.c index fac8ad8d4fd1..8236ec5c65ae 100644 --- a/numpy/_core/src/multiarray/common.c +++ b/numpy/_core/src/multiarray/common.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/common_dtype.c b/numpy/_core/src/multiarray/common_dtype.c index b663fa617a44..fa3328e8f276 100644 --- a/numpy/_core/src/multiarray/common_dtype.c +++ b/numpy/_core/src/multiarray/common_dtype.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/compiled_base.c b/numpy/_core/src/multiarray/compiled_base.c index d8992e89fa0d..fee0d4a61a78 100644 --- a/numpy/_core/src/multiarray/compiled_base.c +++ b/numpy/_core/src/multiarray/compiled_base.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/conversion_utils.c b/numpy/_core/src/multiarray/conversion_utils.c index 883a964a5b97..5ada3e6e4faf 100644 --- a/numpy/_core/src/multiarray/conversion_utils.c +++ b/numpy/_core/src/multiarray/conversion_utils.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/convert.c b/numpy/_core/src/multiarray/convert.c index 235c95da5dba..8e0177616955 100644 --- a/numpy/_core/src/multiarray/convert.c +++ b/numpy/_core/src/multiarray/convert.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/convert_datatype.c b/numpy/_core/src/multiarray/convert_datatype.c index 5893c1147e4f..59b6298b5815 100644 --- a/numpy/_core/src/multiarray/convert_datatype.c +++ b/numpy/_core/src/multiarray/convert_datatype.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/ctors.c b/numpy/_core/src/multiarray/ctors.c index cd3b36159abb..f7efe5041ab3 100644 --- a/numpy/_core/src/multiarray/ctors.c +++ b/numpy/_core/src/multiarray/ctors.c @@ -2,9 +2,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/datetime.c b/numpy/_core/src/multiarray/datetime.c index 1588ccbff653..d820474532ca 100644 --- a/numpy/_core/src/multiarray/datetime.c +++ b/numpy/_core/src/multiarray/datetime.c @@ -9,9 +9,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/datetime_busday.c b/numpy/_core/src/multiarray/datetime_busday.c index b4e60b9fb7ae..73c88811a0a9 100644 --- a/numpy/_core/src/multiarray/datetime_busday.c +++ b/numpy/_core/src/multiarray/datetime_busday.c @@ -9,9 +9,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/datetime_busdaycal.c b/numpy/_core/src/multiarray/datetime_busdaycal.c index 1f1a37d9e7c9..3a7e3a383dca 100644 --- a/numpy/_core/src/multiarray/datetime_busdaycal.c +++ b/numpy/_core/src/multiarray/datetime_busdaycal.c @@ -10,9 +10,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/datetime_strings.c b/numpy/_core/src/multiarray/datetime_strings.c index 8ed09b8c3716..f92eec3f5a59 100644 --- a/numpy/_core/src/multiarray/datetime_strings.c +++ b/numpy/_core/src/multiarray/datetime_strings.c @@ -9,9 +9,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/descriptor.c b/numpy/_core/src/multiarray/descriptor.c index e472c0d75be6..f520e3c4bceb 100644 --- a/numpy/_core/src/multiarray/descriptor.c +++ b/numpy/_core/src/multiarray/descriptor.c @@ -2,9 +2,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/dlpack.c b/numpy/_core/src/multiarray/dlpack.c index a79b79bf8205..ac37a04c30c6 100644 --- a/numpy/_core/src/multiarray/dlpack.c +++ b/numpy/_core/src/multiarray/dlpack.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/dragon4.h b/numpy/_core/src/multiarray/dragon4.h index d0d605d679bb..8986c1672e71 100644 --- a/numpy/_core/src/multiarray/dragon4.h +++ b/numpy/_core/src/multiarray/dragon4.h @@ -32,9 +32,6 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_DRAGON4_H_ #define NUMPY_CORE_SRC_MULTIARRAY_DRAGON4_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/dtype_transfer.c b/numpy/_core/src/multiarray/dtype_transfer.c index 003284d9cc37..188a55a4b5f5 100644 --- a/numpy/_core/src/multiarray/dtype_transfer.c +++ b/numpy/_core/src/multiarray/dtype_transfer.c @@ -13,9 +13,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/dtype_traversal.c b/numpy/_core/src/multiarray/dtype_traversal.c index 2ef6fccd4fdb..91b1889b7d1f 100644 --- a/numpy/_core/src/multiarray/dtype_traversal.c +++ b/numpy/_core/src/multiarray/dtype_traversal.c @@ -14,9 +14,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/dtypemeta.c b/numpy/_core/src/multiarray/dtypemeta.c index 1653c9d36465..0b1b0fb39192 100644 --- a/numpy/_core/src/multiarray/dtypemeta.c +++ b/numpy/_core/src/multiarray/dtypemeta.c @@ -2,9 +2,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/einsum.c.src b/numpy/_core/src/multiarray/einsum.c.src index 63950845d091..3733c436cb1b 100644 --- a/numpy/_core/src/multiarray/einsum.c.src +++ b/numpy/_core/src/multiarray/einsum.c.src @@ -8,9 +8,6 @@ * See LICENSE.txt for the license. */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/flagsobject.c b/numpy/_core/src/multiarray/flagsobject.c index 6f9871cda667..8257727030c0 100644 --- a/numpy/_core/src/multiarray/flagsobject.c +++ b/numpy/_core/src/multiarray/flagsobject.c @@ -2,9 +2,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/fnv.c b/numpy/_core/src/multiarray/fnv.c index 33af34f225ed..2b7848519e61 100644 --- a/numpy/_core/src/multiarray/fnv.c +++ b/numpy/_core/src/multiarray/fnv.c @@ -7,9 +7,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" #include "fnv.h" diff --git a/numpy/_core/src/multiarray/getset.c b/numpy/_core/src/multiarray/getset.c index 060a072e8ce7..48da52dd3178 100644 --- a/numpy/_core/src/multiarray/getset.c +++ b/numpy/_core/src/multiarray/getset.c @@ -2,9 +2,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/hashdescr.c b/numpy/_core/src/multiarray/hashdescr.c index b9e4bb95fd33..f570caf1588f 100644 --- a/numpy/_core/src/multiarray/hashdescr.c +++ b/numpy/_core/src/multiarray/hashdescr.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/item_selection.c b/numpy/_core/src/multiarray/item_selection.c index 8f96a8faa861..5c036b704774 100644 --- a/numpy/_core/src/multiarray/item_selection.c +++ b/numpy/_core/src/multiarray/item_selection.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/iterators.c b/numpy/_core/src/multiarray/iterators.c index 114cb4249103..422c690882ab 100644 --- a/numpy/_core/src/multiarray/iterators.c +++ b/numpy/_core/src/multiarray/iterators.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src b/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src index 80a660496d09..0c4eb3dd9a8d 100644 --- a/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src +++ b/numpy/_core/src/multiarray/lowlevel_strided_loops.c.src @@ -8,9 +8,6 @@ * See LICENSE.txt for the license. */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/mapping.c b/numpy/_core/src/multiarray/mapping.c index 7910b452f1ce..7953e32fcbf0 100644 --- a/numpy/_core/src/multiarray/mapping.c +++ b/numpy/_core/src/multiarray/mapping.c @@ -2,9 +2,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/methods.c b/numpy/_core/src/multiarray/methods.c index 1ddefcf61c6f..58a554dc40be 100644 --- a/numpy/_core/src/multiarray/methods.c +++ b/numpy/_core/src/multiarray/methods.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/multiarraymodule.c b/numpy/_core/src/multiarray/multiarraymodule.c index ef585c9ef38e..e80c6c0cd45c 100644 --- a/numpy/_core/src/multiarray/multiarraymodule.c +++ b/numpy/_core/src/multiarray/multiarraymodule.c @@ -15,9 +15,6 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/nditer_impl.h b/numpy/_core/src/multiarray/nditer_impl.h index d78e179d0758..ab3724d67d11 100644 --- a/numpy/_core/src/multiarray/nditer_impl.h +++ b/numpy/_core/src/multiarray/nditer_impl.h @@ -13,9 +13,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/nditer_pywrap.c b/numpy/_core/src/multiarray/nditer_pywrap.c index 8eabc5f41305..27c392db8720 100644 --- a/numpy/_core/src/multiarray/nditer_pywrap.c +++ b/numpy/_core/src/multiarray/nditer_pywrap.c @@ -9,9 +9,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/npy_static_data.c b/numpy/_core/src/multiarray/npy_static_data.c index 88d3c439bfc4..62e1fd3c1b15 100644 --- a/numpy/_core/src/multiarray/npy_static_data.c +++ b/numpy/_core/src/multiarray/npy_static_data.c @@ -3,9 +3,6 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/number.c b/numpy/_core/src/multiarray/number.c index d0371d68de43..b801d7e041e2 100644 --- a/numpy/_core/src/multiarray/number.c +++ b/numpy/_core/src/multiarray/number.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/public_dtype_api.c b/numpy/_core/src/multiarray/public_dtype_api.c index e43dd93d1f79..9b2d7a393842 100644 --- a/numpy/_core/src/multiarray/public_dtype_api.c +++ b/numpy/_core/src/multiarray/public_dtype_api.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/scalarapi.c b/numpy/_core/src/multiarray/scalarapi.c index 4e1a266f2b86..e133b46d008a 100644 --- a/numpy/_core/src/multiarray/scalarapi.c +++ b/numpy/_core/src/multiarray/scalarapi.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/scalartypes.c.src b/numpy/_core/src/multiarray/scalartypes.c.src index aa266befa3fa..03165b10337e 100644 --- a/numpy/_core/src/multiarray/scalartypes.c.src +++ b/numpy/_core/src/multiarray/scalartypes.c.src @@ -1,7 +1,4 @@ /* -*- c -*- */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/sequence.c b/numpy/_core/src/multiarray/sequence.c index f8a5ebf37af1..4c94bb798072 100644 --- a/numpy/_core/src/multiarray/sequence.c +++ b/numpy/_core/src/multiarray/sequence.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/shape.c b/numpy/_core/src/multiarray/shape.c index 382b3acdc0a1..340fe7289ac8 100644 --- a/numpy/_core/src/multiarray/shape.c +++ b/numpy/_core/src/multiarray/shape.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/strfuncs.c b/numpy/_core/src/multiarray/strfuncs.c index cef5e3cf9792..efe5c8a4fdd8 100644 --- a/numpy/_core/src/multiarray/strfuncs.c +++ b/numpy/_core/src/multiarray/strfuncs.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/stringdtype/casts.cpp b/numpy/_core/src/multiarray/stringdtype/casts.cpp index 77dd9f0013ab..3632e359c9a9 100644 --- a/numpy/_core/src/multiarray/stringdtype/casts.cpp +++ b/numpy/_core/src/multiarray/stringdtype/casts.cpp @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include "numpy/npy_common.h" diff --git a/numpy/_core/src/multiarray/stringdtype/dtype.c b/numpy/_core/src/multiarray/stringdtype/dtype.c index 79a15b1167b7..a06e7a1ed1b6 100644 --- a/numpy/_core/src/multiarray/stringdtype/dtype.c +++ b/numpy/_core/src/multiarray/stringdtype/dtype.c @@ -1,8 +1,4 @@ /* The implementation of the StringDType class */ - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include "structmember.h" diff --git a/numpy/_core/src/multiarray/stringdtype/static_string.c b/numpy/_core/src/multiarray/stringdtype/static_string.c index ed7ab4ba2d47..89b53bcb8538 100644 --- a/numpy/_core/src/multiarray/stringdtype/static_string.c +++ b/numpy/_core/src/multiarray/stringdtype/static_string.c @@ -17,9 +17,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/stringdtype/utf8_utils.c b/numpy/_core/src/multiarray/stringdtype/utf8_utils.c index 17b86e3c998a..b40d23841471 100644 --- a/numpy/_core/src/multiarray/stringdtype/utf8_utils.c +++ b/numpy/_core/src/multiarray/stringdtype/utf8_utils.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/temp_elide.c b/numpy/_core/src/multiarray/temp_elide.c index e6d205537643..9236476c4213 100644 --- a/numpy/_core/src/multiarray/temp_elide.c +++ b/numpy/_core/src/multiarray/temp_elide.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/conversions.c b/numpy/_core/src/multiarray/textreading/conversions.c index c7d1062e0b26..692b67a95264 100644 --- a/numpy/_core/src/multiarray/textreading/conversions.c +++ b/numpy/_core/src/multiarray/textreading/conversions.c @@ -1,6 +1,4 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ + #include #include diff --git a/numpy/_core/src/multiarray/textreading/field_types.h b/numpy/_core/src/multiarray/textreading/field_types.h index a4c4ef2a42f6..078b740cfe0c 100644 --- a/numpy/_core/src/multiarray/textreading/field_types.h +++ b/numpy/_core/src/multiarray/textreading/field_types.h @@ -2,9 +2,6 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_FIELD_TYPES_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_FIELD_TYPES_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/readtext.c b/numpy/_core/src/multiarray/textreading/readtext.c index 65e5e6807fce..4df2446302d6 100644 --- a/numpy/_core/src/multiarray/textreading/readtext.c +++ b/numpy/_core/src/multiarray/textreading/readtext.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/rows.c b/numpy/_core/src/multiarray/textreading/rows.c index 545bdff42d42..c459fa826e53 100644 --- a/numpy/_core/src/multiarray/textreading/rows.c +++ b/numpy/_core/src/multiarray/textreading/rows.c @@ -1,6 +1,4 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ + #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/rows.h b/numpy/_core/src/multiarray/textreading/rows.h index 45358b4621ed..20eb9e186a19 100644 --- a/numpy/_core/src/multiarray/textreading/rows.h +++ b/numpy/_core/src/multiarray/textreading/rows.h @@ -2,9 +2,6 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_ROWS_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_ROWS_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/textreading/str_to_int.c b/numpy/_core/src/multiarray/textreading/str_to_int.c index c61558014958..5f58067228d1 100644 --- a/numpy/_core/src/multiarray/textreading/str_to_int.c +++ b/numpy/_core/src/multiarray/textreading/str_to_int.c @@ -1,6 +1,4 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ + #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/textreading/stream_pyobject.c b/numpy/_core/src/multiarray/textreading/stream_pyobject.c index 213a5519beec..3832ee84a4f3 100644 --- a/numpy/_core/src/multiarray/textreading/stream_pyobject.c +++ b/numpy/_core/src/multiarray/textreading/stream_pyobject.c @@ -4,9 +4,6 @@ * single line of a file. */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/stream_pyobject.h b/numpy/_core/src/multiarray/textreading/stream_pyobject.h index 49830e12d22b..45c11dd951a7 100644 --- a/numpy/_core/src/multiarray/textreading/stream_pyobject.h +++ b/numpy/_core/src/multiarray/textreading/stream_pyobject.h @@ -2,9 +2,6 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_STREAM_PYOBJECT_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_STREAM_PYOBJECT_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/multiarray/textreading/tokenize.cpp b/numpy/_core/src/multiarray/textreading/tokenize.cpp index 952ca8e279b8..e0ddc393d889 100644 --- a/numpy/_core/src/multiarray/textreading/tokenize.cpp +++ b/numpy/_core/src/multiarray/textreading/tokenize.cpp @@ -1,6 +1,4 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ + #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/multiarray/textreading/tokenize.h b/numpy/_core/src/multiarray/textreading/tokenize.h index 8580817f48b2..53e97760ff9e 100644 --- a/numpy/_core/src/multiarray/textreading/tokenize.h +++ b/numpy/_core/src/multiarray/textreading/tokenize.h @@ -2,9 +2,6 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_TOKENIZE_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_TOKENIZE_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/ndarraytypes.h" diff --git a/numpy/_core/src/multiarray/unique.cpp b/numpy/_core/src/multiarray/unique.cpp index 9029531fa53b..636f1ef0137c 100644 --- a/numpy/_core/src/multiarray/unique.cpp +++ b/numpy/_core/src/multiarray/unique.cpp @@ -2,10 +2,6 @@ #define _MULTIARRAYMODULE #define HASH_TABLE_INITIAL_BUCKETS 1024 - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include diff --git a/numpy/_core/src/multiarray/usertypes.c b/numpy/_core/src/multiarray/usertypes.c index d24913a0a7f1..445f7ad7fe67 100644 --- a/numpy/_core/src/multiarray/usertypes.c +++ b/numpy/_core/src/multiarray/usertypes.c @@ -23,9 +23,6 @@ maintainer email: oliphant.travis@ieee.org #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/multiarray/vdot.c b/numpy/_core/src/multiarray/vdot.c index cfc97fc5aa66..ff08ed2d4b07 100644 --- a/numpy/_core/src/multiarray/vdot.c +++ b/numpy/_core/src/multiarray/vdot.c @@ -1,9 +1,6 @@ #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/npymath/npy_math_common.h b/numpy/_core/src/npymath/npy_math_common.h index aaacb368e2cd..1f555a90a665 100644 --- a/numpy/_core/src/npymath/npy_math_common.h +++ b/numpy/_core/src/npymath/npy_math_common.h @@ -1,10 +1,6 @@ /* * Common headers needed by every npy math compilation unit */ - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/npymath/npy_math_private.h b/numpy/_core/src/npymath/npy_math_private.h index 79667ae2527f..e55af987f3f3 100644 --- a/numpy/_core/src/npymath/npy_math_private.h +++ b/numpy/_core/src/npymath/npy_math_private.h @@ -18,9 +18,6 @@ #ifndef _NPY_MATH_PRIVATE_H_ #define _NPY_MATH_PRIVATE_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #ifdef __cplusplus #include diff --git a/numpy/_core/src/umath/_operand_flag_tests.c b/numpy/_core/src/umath/_operand_flag_tests.c index c56ae22f8cba..5cdff6220280 100644 --- a/numpy/_core/src/umath/_operand_flag_tests.c +++ b/numpy/_core/src/umath/_operand_flag_tests.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/_rational_tests.c b/numpy/_core/src/umath/_rational_tests.c index ee52af7c0301..d257bc22d051 100644 --- a/numpy/_core/src/umath/_rational_tests.c +++ b/numpy/_core/src/umath/_rational_tests.c @@ -1,8 +1,4 @@ /* Fixed size rational numbers exposed to Python */ - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/umath/_struct_ufunc_tests.c b/numpy/_core/src/umath/_struct_ufunc_tests.c index ec36b543ed28..56c4be117e44 100644 --- a/numpy/_core/src/umath/_struct_ufunc_tests.c +++ b/numpy/_core/src/umath/_struct_ufunc_tests.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/_umath_tests.c.src b/numpy/_core/src/umath/_umath_tests.c.src index 4b61658c2d80..845f51ebc94f 100644 --- a/numpy/_core/src/umath/_umath_tests.c.src +++ b/numpy/_core/src/umath/_umath_tests.c.src @@ -5,9 +5,6 @@ ** INCLUDES ** ***************************************************************************** */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/_umath_tests.dispatch.c b/numpy/_core/src/umath/_umath_tests.dispatch.c index 723e42949c3a..e92356ac09f2 100644 --- a/numpy/_core/src/umath/_umath_tests.dispatch.c +++ b/numpy/_core/src/umath/_umath_tests.dispatch.c @@ -1,9 +1,6 @@ /** * Testing the utilities of the CPU dispatcher */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/dispatching.cpp b/numpy/_core/src/umath/dispatching.cpp index 887db86fc96b..ba98a9b5c5d1 100644 --- a/numpy/_core/src/umath/dispatching.cpp +++ b/numpy/_core/src/umath/dispatching.cpp @@ -38,9 +38,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/_core/src/umath/extobj.c b/numpy/_core/src/umath/extobj.c index 0e14b564e8f1..755d8665b11d 100644 --- a/numpy/_core/src/umath/extobj.c +++ b/numpy/_core/src/umath/extobj.c @@ -2,9 +2,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/legacy_array_method.c b/numpy/_core/src/umath/legacy_array_method.c index 297b4ba52d0f..705262fedd38 100644 --- a/numpy/_core/src/umath/legacy_array_method.c +++ b/numpy/_core/src/umath/legacy_array_method.c @@ -6,9 +6,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/loops.c.src b/numpy/_core/src/umath/loops.c.src index a4e580ce2efb..3928d2a0d0c4 100644 --- a/numpy/_core/src/umath/loops.c.src +++ b/numpy/_core/src/umath/loops.c.src @@ -1,7 +1,4 @@ /* -*- c -*- */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/matmul.c.src b/numpy/_core/src/umath/matmul.c.src index 5ed0c2b22fb7..11e014acec7f 100644 --- a/numpy/_core/src/umath/matmul.c.src +++ b/numpy/_core/src/umath/matmul.c.src @@ -1,7 +1,4 @@ /* -*- c -*- */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/reduction.c b/numpy/_core/src/umath/reduction.c index fee7e9abd78a..b376b94936bc 100644 --- a/numpy/_core/src/umath/reduction.c +++ b/numpy/_core/src/umath/reduction.c @@ -10,9 +10,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/scalarmath.c.src b/numpy/_core/src/umath/scalarmath.c.src index 2e93f658ab65..a565eee8f939 100644 --- a/numpy/_core/src/umath/scalarmath.c.src +++ b/numpy/_core/src/umath/scalarmath.c.src @@ -5,9 +5,6 @@ but still supports error-modes. */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/special_integer_comparisons.cpp b/numpy/_core/src/umath/special_integer_comparisons.cpp index 14e5aa18018e..06babeeda0a8 100644 --- a/numpy/_core/src/umath/special_integer_comparisons.cpp +++ b/numpy/_core/src/umath/special_integer_comparisons.cpp @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/umath/string_buffer.h b/numpy/_core/src/umath/string_buffer.h index 75e03f15a2db..dafedcbc03ff 100644 --- a/numpy/_core/src/umath/string_buffer.h +++ b/numpy/_core/src/umath/string_buffer.h @@ -1,9 +1,6 @@ #ifndef _NPY_CORE_SRC_UMATH_STRING_BUFFER_H_ #define _NPY_CORE_SRC_UMATH_STRING_BUFFER_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/umath/string_fastsearch.h b/numpy/_core/src/umath/string_fastsearch.h index 634835244e5b..95d0ee4fb214 100644 --- a/numpy/_core/src/umath/string_fastsearch.h +++ b/numpy/_core/src/umath/string_fastsearch.h @@ -3,9 +3,6 @@ /* stringlib: fastsearch implementation taken from CPython */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/_core/src/umath/string_ufuncs.cpp b/numpy/_core/src/umath/string_ufuncs.cpp index 7813fcd21e67..95f30ccb109e 100644 --- a/numpy/_core/src/umath/string_ufuncs.cpp +++ b/numpy/_core/src/umath/string_ufuncs.cpp @@ -1,8 +1,4 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include - #include #define NPY_NO_DEPRECATED_API NPY_API_VERSION diff --git a/numpy/_core/src/umath/stringdtype_ufuncs.cpp b/numpy/_core/src/umath/stringdtype_ufuncs.cpp index 1181a043897c..b0181d4186c9 100644 --- a/numpy/_core/src/umath/stringdtype_ufuncs.cpp +++ b/numpy/_core/src/umath/stringdtype_ufuncs.cpp @@ -1,8 +1,4 @@ /* Ufunc implementations for the StringDType class */ - -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/ufunc_object.c b/numpy/_core/src/umath/ufunc_object.c index c2f8e4a6af1c..4cdde8d3d77d 100644 --- a/numpy/_core/src/umath/ufunc_object.c +++ b/numpy/_core/src/umath/ufunc_object.c @@ -27,9 +27,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/ufunc_type_resolution.c b/numpy/_core/src/umath/ufunc_type_resolution.c index 80d500e24a3c..95670efb936f 100644 --- a/numpy/_core/src/umath/ufunc_type_resolution.c +++ b/numpy/_core/src/umath/ufunc_type_resolution.c @@ -24,9 +24,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/umathmodule.c b/numpy/_core/src/umath/umathmodule.c index 194b2771da68..e5cf2cf8acb3 100644 --- a/numpy/_core/src/umath/umathmodule.c +++ b/numpy/_core/src/umath/umathmodule.c @@ -10,9 +10,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/src/umath/wrapping_array_method.c b/numpy/_core/src/umath/wrapping_array_method.c index ac92cb27a3bb..9b3970561f3f 100644 --- a/numpy/_core/src/umath/wrapping_array_method.c +++ b/numpy/_core/src/umath/wrapping_array_method.c @@ -21,9 +21,6 @@ #define _MULTIARRAYMODULE #define _UMATHMODULE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/_core/tests/examples/limited_api/limited_api1.c b/numpy/_core/tests/examples/limited_api/limited_api1.c index e72ee28efa7a..3dbf5698f1d4 100644 --- a/numpy/_core/tests/examples/limited_api/limited_api1.c +++ b/numpy/_core/tests/examples/limited_api/limited_api1.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define Py_LIMITED_API 0x03060000 #include diff --git a/numpy/_core/tests/examples/limited_api/limited_api_latest.c b/numpy/_core/tests/examples/limited_api/limited_api_latest.c index d9b5a8ad6e67..92d83ea977a1 100644 --- a/numpy/_core/tests/examples/limited_api/limited_api_latest.c +++ b/numpy/_core/tests/examples/limited_api/limited_api_latest.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include #include diff --git a/numpy/f2py/src/fortranobject.h b/numpy/f2py/src/fortranobject.h index eb88c8e26a67..4aed2f60891b 100644 --- a/numpy/f2py/src/fortranobject.h +++ b/numpy/f2py/src/fortranobject.h @@ -4,9 +4,6 @@ extern "C" { #endif -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #ifndef NPY_NO_DEPRECATED_API diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index 7c5005a97e92..25866f1a40ec 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -10,9 +10,6 @@ extern "C" { /*********************** See f2py2e/cfuncs.py: includes ***********************/ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include "fortranobject.h" diff --git a/numpy/fft/_pocketfft_umath.cpp b/numpy/fft/_pocketfft_umath.cpp index 8147ef52e5ca..ab8af5aa522e 100644 --- a/numpy/fft/_pocketfft_umath.cpp +++ b/numpy/fft/_pocketfft_umath.cpp @@ -11,9 +11,6 @@ */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include #include diff --git a/numpy/linalg/lapack_lite/f2c.c b/numpy/linalg/lapack_lite/f2c.c index c6c9c3b8bbba..47e4d5729b83 100644 --- a/numpy/linalg/lapack_lite/f2c.c +++ b/numpy/linalg/lapack_lite/f2c.c @@ -7,9 +7,6 @@ it is available, and shipping a static library isn't portable. */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/lapack_lite/f2c.h b/numpy/linalg/lapack_lite/f2c.h index 09482f6fe5e9..60bce4a9f575 100644 --- a/numpy/linalg/lapack_lite/f2c.h +++ b/numpy/linalg/lapack_lite/f2c.h @@ -7,9 +7,6 @@ #ifndef F2C_INCLUDE #define F2C_INCLUDE -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/lapack_lite/python_xerbla.c b/numpy/linalg/lapack_lite/python_xerbla.c index 49a5e90b2616..71a4c81edbf1 100644 --- a/numpy/linalg/lapack_lite/python_xerbla.c +++ b/numpy/linalg/lapack_lite/python_xerbla.c @@ -1,6 +1,3 @@ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c index cd39dddc62b8..cad5f3f92f09 100644 --- a/numpy/linalg/lapack_litemodule.c +++ b/numpy/linalg/lapack_litemodule.c @@ -4,9 +4,6 @@ More modifications by Jeff Whitaker */ #define NPY_NO_DEPRECATED_API NPY_API_VERSION -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/linalg/umath_linalg.cpp b/numpy/linalg/umath_linalg.cpp index 2077bf653d6d..1b6850145bc8 100644 --- a/numpy/linalg/umath_linalg.cpp +++ b/numpy/linalg/umath_linalg.cpp @@ -5,9 +5,6 @@ ** INCLUDES ** ***************************************************************************** */ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #define PY_SSIZE_T_CLEAN #include diff --git a/numpy/random/include/aligned_malloc.h b/numpy/random/include/aligned_malloc.h index 02f206ef41af..0fff57b6c44d 100644 --- a/numpy/random/include/aligned_malloc.h +++ b/numpy/random/include/aligned_malloc.h @@ -1,9 +1,6 @@ #ifndef _RANDOMDGEN__ALIGNED_MALLOC_H_ #define _RANDOMDGEN__ALIGNED_MALLOC_H_ -/* Any file that includes Python.h must include it before any other files */ -/* https://docs.python.org/3/extending/extending.html#a-simple-example */ -/* npy_common.h includes Python.h so it also counts in this list */ #include #include "numpy/npy_common.h" From d21497be9e94a7abd96798403d40f109caf2297d Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 2 Jul 2025 07:20:19 -0400 Subject: [PATCH 10/14] BUG: Handle trailing comments on include lines in check_python_h_first.py --- numpy/_core/src/common/blas_utils.c | 2 +- tools/check_python_h_first.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/numpy/_core/src/common/blas_utils.c b/numpy/_core/src/common/blas_utils.c index 25824ead00b6..f0a819019dc3 100644 --- a/numpy/_core/src/common/blas_utils.c +++ b/numpy/_core/src/common/blas_utils.c @@ -1,5 +1,5 @@ -#include "numpy/numpyconfig.h" // NPY_VISIBILITY_HIDDEN #include "numpy/npy_math.h" // npy_get_floatstatus_barrier +#include "numpy/numpyconfig.h" // NPY_VISIBILITY_HIDDEN #include "blas_utils.h" #include diff --git a/tools/check_python_h_first.py b/tools/check_python_h_first.py index 79b755cb4332..a40ec5109c19 100755 --- a/tools/check_python_h_first.py +++ b/tools/check_python_h_first.py @@ -37,7 +37,7 @@ PARSER.add_argument( "files", nargs="*", - help="Lint these files or directories; use **/*.py to lint all files", + help="Lint these files or directories; use **/*.c to lint all files", ) @@ -76,6 +76,7 @@ def check_python_h_included_first(name_to_check: str) -> int: if "*/" in line: in_comment = False continue + line = line.split("//", 1)[0].strip() match = HEADER_PATTERN.match(line) if match: includes_headers = True @@ -114,7 +115,7 @@ def check_python_h_included_first(name_to_check: str) -> int: file=sys.stderr, ) warned_python_construct = True - if includes_headers: + if not includes_headers: LEAF_HEADERS.append(this_header) return included_python and len(included_non_python_header) @@ -140,7 +141,7 @@ def find_c_cpp_files(root: str) -> list[str]: result = [] - for dirpath, dirnames, filenames in os.walk("scipy"): + for dirpath, dirnames, filenames in os.walk("numpy"): # I'm assuming other people have checked boost for name in ("build", ".git", "boost"): try: @@ -192,7 +193,7 @@ def diff_files(sha: str) -> list[str]: if __name__ == "__main__": args = PARSER.parse_args() - if not (len(args.files) == 0): + if len(args.files) == 0: files = find_c_cpp_files("numpy") else: files = args.files From 619c25aeec4b9c60f41f29a659571cf9c4be64d4 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 2 Jul 2025 18:02:09 -0400 Subject: [PATCH 11/14] FIX: The leaf header would be the header just checked Not whichever was last included --- tools/check_python_h_first.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_python_h_first.py b/tools/check_python_h_first.py index a40ec5109c19..4a6c204c14d2 100755 --- a/tools/check_python_h_first.py +++ b/tools/check_python_h_first.py @@ -116,7 +116,7 @@ def check_python_h_included_first(name_to_check: str) -> int: ) warned_python_construct = True if not includes_headers: - LEAF_HEADERS.append(this_header) + LEAF_HEADERS.append(basename_to_check) return included_python and len(included_non_python_header) From 83597ace18f575ac509afea0f131fc6dfd5cb300 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Thu, 3 Jul 2025 06:44:32 -0400 Subject: [PATCH 12/14] DEV,ENH: Recognize vendored files from .gitattributes --- tools/get_submodule_paths.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/get_submodule_paths.py b/tools/get_submodule_paths.py index 9cff4f3cdc58..abab86140712 100644 --- a/tools/get_submodule_paths.py +++ b/tools/get_submodule_paths.py @@ -1,4 +1,5 @@ -import os +import glob +import os.path def get_submodule_paths(): @@ -15,7 +16,14 @@ def get_submodule_paths(): submodule_paths = [os.path.join(root_directory, path) for path in submodule_paths] # vendored with a script rather than via gitmodules - submodule_paths.append(os.path.join(root_directory, 'scipy/_lib/pyprima')) + with open( + os.path.join(root_directory, ".gitattributes"), "r" + ) as attr_file: + for line in attr_file: + if "vendored" in line: + pattern = line.split(" ", 1)[0] + submodule_paths.extend(glob.glob(pattern)) + return submodule_paths From cba759f498dc60d7312aca056557bd2afee07a2d Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Thu, 3 Jul 2025 07:31:11 -0400 Subject: [PATCH 13/14] DEV,ENH: Streamline the Python.h linter to reduce false positives. Also allow passing a specific directory. --- tools/check_python_h_first.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tools/check_python_h_first.py b/tools/check_python_h_first.py index 4a6c204c14d2..fad7cb01860e 100755 --- a/tools/check_python_h_first.py +++ b/tools/check_python_h_first.py @@ -20,15 +20,23 @@ "Python.h", # This isn't all of Python.h, but it is the visibility macros "pyconfig.h", - "numpy/arrayobject.h", - "numpy/ndarrayobject.h", "numpy/npy_common.h", "numpy/npy_math.h", + "numpy/arrayobject.h", + "numpy/ndarrayobject.h", + "numpy/ndarraytypes.h", "numpy/random/distributions.h", + "npy_sort.h", # Boost::Python "boost/python.hpp", ] -LEAF_HEADERS = [] +LEAF_HEADERS = [ + "numpyconfig.h", + "_numpyconfig.h", + "numpy/numpyconfig.h", + "numpy/npy_os.h", + "numpy/npy_cpu.h", +] C_CPP_EXTENSIONS = (".c", ".h", ".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx") # check against list in diff_files @@ -37,7 +45,8 @@ PARSER.add_argument( "files", nargs="*", - help="Lint these files or directories; use **/*.c to lint all files", + help="Lint these files or directories; use **/*.c to lint all files\n" + "Expects relative paths", ) @@ -91,10 +100,12 @@ def check_python_h_included_first(name_to_check: str) -> int: ) included_python = True PYTHON_INCLUDING_HEADERS.append(basename_to_check) + elif this_header in LEAF_HEADERS: + continue elif not included_python and ( - "numpy" in this_header + "numpy/" in this_header and this_header != "numpy/utils.h" - or "python" in this_header + or "python" in this_header.lower() ): print( f"Python.h not included before python-including header " @@ -108,7 +119,7 @@ def check_python_h_included_first(name_to_check: str) -> int: not included_python and not warned_python_construct and ".h" not in basename_to_check - ) and ("py::" in line or "PYBIND11_" in line or "npy_" in line): + ) and ("py::" in line or "PYBIND11_" in line): print( "Python-including header not used before python constructs " f"in file {name_to_check:s}\nConstruct on line {i:d}", @@ -130,6 +141,8 @@ def process_files(file_list: list[str]) -> int: name_to_check = os.path.join(root_directory, name_to_check) if any(submodule_path in name_to_check for submodule_path in submodule_paths): continue + if ".dispatch." in name_to_check: + continue try: n_out_of_order += check_python_h_included_first(name_to_check) except UnicodeDecodeError: @@ -141,7 +154,7 @@ def find_c_cpp_files(root: str) -> list[str]: result = [] - for dirpath, dirnames, filenames in os.walk("numpy"): + for dirpath, dirnames, filenames in os.walk(root): # I'm assuming other people have checked boost for name in ("build", ".git", "boost"): try: @@ -197,6 +210,8 @@ def diff_files(sha: str) -> list[str]: files = find_c_cpp_files("numpy") else: files = args.files + if len(files) == 1 and os.path.isdir(files[0]): + files = find_c_cpp_files(files[0]) # See which of the headers include Python.h and add them to the list n_out_of_order = process_files(files) From e9c8cd022c224cc207e3caa59fd0c974ec0a93b0 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Thu, 3 Jul 2025 18:27:47 -0400 Subject: [PATCH 14/14] DEV,ENH: Get Python.h linter passing. --- numpy/_core/src/common/binop_override.h | 2 +- numpy/_core/src/multiarray/array_method.c | 2 +- numpy/_core/src/multiarray/common.h | 2 + .../src/multiarray/textreading/conversions.h | 4 +- numpy/_core/src/npysort/npysort_common.h | 2 +- numpy/_core/src/umath/clip.cpp | 2 +- numpy/random/src/mt19937/randomkit.c | 2 + tools/check_python_h_first.py | 48 ++++++++++++++++--- 8 files changed, 52 insertions(+), 12 deletions(-) diff --git a/numpy/_core/src/common/binop_override.h b/numpy/_core/src/common/binop_override.h index a6b4747ca560..e17b147c1d0a 100644 --- a/numpy/_core/src/common/binop_override.h +++ b/numpy/_core/src/common/binop_override.h @@ -1,8 +1,8 @@ #ifndef NUMPY_CORE_SRC_COMMON_BINOP_OVERRIDE_H_ #define NUMPY_CORE_SRC_COMMON_BINOP_OVERRIDE_H_ -#include #include +#include #include "numpy/arrayobject.h" #include "get_attr_string.h" diff --git a/numpy/_core/src/multiarray/array_method.c b/numpy/_core/src/multiarray/array_method.c index 5554cad5e2dd..ba3b7962a632 100644 --- a/numpy/_core/src/multiarray/array_method.c +++ b/numpy/_core/src/multiarray/array_method.c @@ -30,8 +30,8 @@ #define _UMATHMODULE #define _MULTIARRAYMODULE -#include #include +#include #include "arrayobject.h" #include "array_coercion.h" #include "array_method.h" diff --git a/numpy/_core/src/multiarray/common.h b/numpy/_core/src/multiarray/common.h index a18f74bda71a..d6b9ad36588f 100644 --- a/numpy/_core/src/multiarray/common.h +++ b/numpy/_core/src/multiarray/common.h @@ -1,6 +1,8 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_COMMON_H_ #define NUMPY_CORE_SRC_MULTIARRAY_COMMON_H_ +#include + #include #include "numpy/npy_common.h" #include "numpy/ndarraytypes.h" diff --git a/numpy/_core/src/multiarray/textreading/conversions.h b/numpy/_core/src/multiarray/textreading/conversions.h index 09f2510413b5..e30b28a9a7af 100644 --- a/numpy/_core/src/multiarray/textreading/conversions.h +++ b/numpy/_core/src/multiarray/textreading/conversions.h @@ -1,12 +1,12 @@ #ifndef NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_CONVERSIONS_H_ #define NUMPY_CORE_SRC_MULTIARRAY_TEXTREADING_CONVERSIONS_H_ -#include - #define NPY_NO_DEPRECATED_API NPY_API_VERSION #define _MULTIARRAYMODULE #include "numpy/arrayobject.h" +#include + #include "textreading/parser_config.h" NPY_NO_EXPORT int diff --git a/numpy/_core/src/npysort/npysort_common.h b/numpy/_core/src/npysort/npysort_common.h index 0680ae52afe3..8b7e0ef43f88 100644 --- a/numpy/_core/src/npysort/npysort_common.h +++ b/numpy/_core/src/npysort/npysort_common.h @@ -1,8 +1,8 @@ #ifndef __NPY_SORT_COMMON_H__ #define __NPY_SORT_COMMON_H__ -#include #include +#include #include #include "dtypemeta.h" diff --git a/numpy/_core/src/umath/clip.cpp b/numpy/_core/src/umath/clip.cpp index e051692c6d48..127b019ef8ae 100644 --- a/numpy/_core/src/umath/clip.cpp +++ b/numpy/_core/src/umath/clip.cpp @@ -1,7 +1,6 @@ /** * This module provides the inner loops for the clip ufunc */ -#include #define _UMATHMODULE #define _MULTIARRAYMODULE @@ -10,6 +9,7 @@ #define PY_SSIZE_T_CLEAN #include +#include #include "numpy/halffloat.h" #include "numpy/ndarraytypes.h" #include "numpy/npy_common.h" diff --git a/numpy/random/src/mt19937/randomkit.c b/numpy/random/src/mt19937/randomkit.c index 32f40fa49cc1..21d270234c9a 100644 --- a/numpy/random/src/mt19937/randomkit.c +++ b/numpy/random/src/mt19937/randomkit.c @@ -62,6 +62,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + /* static char const rcsid[] = "@(#) $Jeannot: randomkit.c,v 1.28 2005/07/21 22:14:09 js Exp $"; */ diff --git a/tools/check_python_h_first.py b/tools/check_python_h_first.py index fad7cb01860e..c0d44ad635f4 100755 --- a/tools/check_python_h_first.py +++ b/tools/check_python_h_first.py @@ -27,15 +27,17 @@ "numpy/ndarraytypes.h", "numpy/random/distributions.h", "npy_sort.h", + "npy_config.h", + "common.h", + "npy_cpu_features.h", # Boost::Python "boost/python.hpp", ] LEAF_HEADERS = [ - "numpyconfig.h", - "_numpyconfig.h", "numpy/numpyconfig.h", "numpy/npy_os.h", "numpy/npy_cpu.h", + "numpy/utils.h", ] C_CPP_EXTENSIONS = (".c", ".h", ".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx") @@ -92,19 +94,27 @@ def check_python_h_included_first(name_to_check: str) -> int: this_header = match.group(1) if this_header in PYTHON_INCLUDING_HEADERS: if included_non_python_header and not included_python: + # Headers before python-including header print( f"Header before Python.h in file {name_to_check:s}\n" f"Python.h on line {i:d}, other header(s) on line(s)" f" {included_non_python_header}", file=sys.stderr, ) + # else: # no headers before python-including header included_python = True PYTHON_INCLUDING_HEADERS.append(basename_to_check) + if os.path.dirname(name_to_check).endswith("include/numpy"): + PYTHON_INCLUDING_HEADERS.append(f"numpy/{basename_to_check:s}") + # We just found out where Python.h comes in this file + break elif this_header in LEAF_HEADERS: + # This header is just defines, so it won't include + # the system headers that cause problems continue elif not included_python and ( "numpy/" in this_header - and this_header != "numpy/utils.h" + and this_header not in LEAF_HEADERS or "python" in this_header.lower() ): print( @@ -113,6 +123,8 @@ def check_python_h_included_first(name_to_check: str) -> int: f"{this_header:s} on line {i:d}", file=sys.stderr, ) + included_python = True + PYTHON_INCLUDING_HEADERS.append(basename_to_check) elif not included_python and this_header not in LEAF_HEADERS: included_non_python_header.append(i) elif ( @@ -131,13 +143,37 @@ def check_python_h_included_first(name_to_check: str) -> int: return included_python and len(included_non_python_header) +def sort_order(path: str) -> tuple[int, str]: + if "include/numpy" in path: + # Want to process numpy/*.h first, to work out which of those + # include Python.h directly + priority = 0x00 + elif "h" in os.path.splitext(path)[1].lower(): + # Then other headers, which tend to include numpy/*.h + priority = 0x10 + else: + # Source files after headers, to give the best chance of + # properly checking whether they include Python.h + priority = 0x20 + if "common" in path: + priority -= 8 + path_basename = os.path.basename(path) + if path_basename.startswith("npy_"): + priority -= 4 + elif path_basename.startswith("npy"): + priority -= 3 + elif path_basename.startswith("np"): + priority -= 2 + if "config" in path_basename: + priority -= 1 + return priority, path + + def process_files(file_list: list[str]) -> int: n_out_of_order = 0 submodule_paths = get_submodule_paths() root_directory = os.path.dirname(os.path.dirname(__file__)) - for name_to_check in sorted( - file_list, key=lambda name: "h" not in os.path.splitext(name)[1].lower() - ): + for name_to_check in sorted(file_list, key=sort_order): name_to_check = os.path.join(root_directory, name_to_check) if any(submodule_path in name_to_check for submodule_path in submodule_paths): continue