Compiling Fails due to sklearn/metrics/pairwise.py

### Describe the bug

_This may be a duplicate of [29754](https://github.com/scikit-learn/scikit-learn/issues/29754)._ 

Having merged from upstream, the imports in `sklearn/metrics/pairwise.py` do not compile. 

I am getting error:
"sklearn/metrics/_dist_metrics.pyx", line 1, in init sklearn.metrics._dist_metrics"

I have tried rebuilding my conda environment and sklearn.


### Steps/Code to Reproduce

$ python -m sklearn.kernel_approximation

### Expected Results

not an error

### Actual Results

```python
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/conradstevens/scikit-learn/sklearn/kernel_approximation.py", line 20, in <module>
    from .metrics.pairwise import KERNEL_PARAMS, PAIRWISE_KERNEL_FUNCTIONS, pairwise_kernels
  File "/Users/conradstevens/scikit-learn/sklearn/metrics/__init__.py", line 6, in <module>
    from . import cluster
  File "/Users/conradstevens/scikit-learn/sklearn/metrics/cluster/__init__.py", line 28, in <module>
    from ._unsupervised import (
  File "/Users/conradstevens/scikit-learn/sklearn/metrics/cluster/_unsupervised.py", line 21, in <module>
    from ..pairwise import _VALID_METRICS, pairwise_distances, pairwise_distances_chunked
  File "/Users/conradstevens/scikit-learn/sklearn/metrics/pairwise.py", line 46, in <module>
    from ._pairwise_distances_reduction import ArgKmin
  File "/Users/conradstevens/scikit-learn/sklearn/metrics/_pairwise_distances_reduction/__init__.py", line 97, in <module>
    from ._dispatcher import (
  File "/Users/conradstevens/scikit-learn/sklearn/metrics/_pairwise_distances_reduction/_dispatcher.py", line 11, in <module>
    from .._dist_metrics import (
  File "sklearn/metrics/_dist_metrics.pyx", line 1, in init sklearn.metrics._dist_metrics
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
```

### Versions

```shell
$ python -c "import sklearn; sklearn.show_versions()"

System:
    python: 3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:31:54) [Clang 16.0.6 ]
executable: /opt/homebrew/Caskroom/miniconda/base/envs/sklearn-dev-3/bin/python
   machine: macOS-14.4.1-x86_64-i386-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.2
   setuptools: 72.2.0
        numpy: 2.1.0
        scipy: 1.14.1
       Cython: 3.0.11
       pandas: None
   matplotlib: None
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 10
         prefix: libopenblas
       filepath: /opt/homebrew/Caskroom/miniconda/base/envs/sklearn-dev-3/lib/libopenblasp-r0.3.27.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: Nehalem

       user_api: openmp
   internal_api: openmp
    num_threads: 10
         prefix: libomp
       filepath: /opt/homebrew/Caskroom/miniconda/base/envs/sklearn-dev-3/lib/libomp.dylib
        version: None
```

COMMENT:
Thank you @glemaitre I have rebuild from source and getting the same issue. 
I am not entirely sure what you mean by 'with shown dependencies'. Below is what is in my conda environment:


```
\# packages in environment at /opt/homebrew/Caskroom/miniconda/base/envs/sklearn-dev-5:
\#
\# Name                    Version                   Build  Channel
bzip2                     1.0.8                hfdf4475_7    conda-forge
c-compiler                1.7.0                h282daa2_1    conda-forge
ca-certificates           2024.8.30            h8857fd0_0    conda-forge
cctools                   986                  h40f6528_3    conda-forge
cctools_osx-64            986                  h303a5ab_3    conda-forge
clang                     16.0.6          default_h179603d_13    conda-forge
clang-16                  16.0.6          default_h0c94c6a_13    conda-forge
clang_impl_osx-64         16.0.6              h8787910_19    conda-forge
clang_osx-64              16.0.6              hb91bd55_19    conda-forge
clangxx                   16.0.6          default_h179603d_13    conda-forge
clangxx_impl_osx-64       16.0.6              h6d92fbe_19    conda-forge
clangxx_osx-64            16.0.6              hb91bd55_19    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
compiler-rt               16.0.6               ha38d28d_2    conda-forge
compiler-rt_osx-64        16.0.6               ha38d28d_2    conda-forge
compilers                 1.7.0                h694c41f_1    conda-forge
cxx-compiler              1.7.0                h7728843_1    conda-forge
cython                    3.0.11          py312h5861a67_1    conda-forge
exceptiongroup            1.2.2              pyhd8ed1ab_0    conda-forge
fortran-compiler          1.7.0                h6c2ab21_1    conda-forge
gfortran                  12.3.0               h2c809b3_1    conda-forge
gfortran_impl_osx-64      12.3.0               hc328e78_3    conda-forge
gfortran_osx-64           12.3.0               h18f7dce_1    conda-forge
gmp                       6.3.0                hf036a51_2    conda-forge
icu                       75.1                 h120a0e1_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
isl                       0.26            imath32_h2e86a7b_101    conda-forge
joblib                    1.4.2              pyhd8ed1ab_0    conda-forge
ld64                      711                  ha02d983_3    conda-forge
ld64_osx-64               711                  h04ffbf3_3    conda-forge
libblas                   3.9.0           22_osx64_openblas    conda-forge
libcblas                  3.9.0           22_osx64_openblas    conda-forge
libclang-cpp16            16.0.6          default_h0c94c6a_13    conda-forge
libcxx                    18.1.8               hd876a4e_6    conda-forge
libcxx-devel              16.0.6               h8f8a49f_2    conda-forge
libexpat                  2.6.2                h73e2aa4_0    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libgfortran               5.0.0           13_2_0_h97931a8_3    conda-forge
libgfortran-devel_osx-64  12.3.0               h0b6f5ec_3    conda-forge
libgfortran5              13.2.0               h2873a65_3    conda-forge
libiconv                  1.17                 hd75f5a5_2    conda-forge
liblapack                 3.9.0           22_osx64_openblas    conda-forge
libllvm16                 16.0.6               hbedff68_3    conda-forge
libopenblas               0.3.27          openmp_h8869122_1    conda-forge
libsqlite                 3.46.0               h1b8f9f3_0    conda-forge
libxml2                   2.12.7               heaf3512_4    conda-forge
libzlib                   1.3.1                h87427d6_1    conda-forge
llvm-openmp               18.1.8               h15ab845_1    conda-forge
llvm-tools                16.0.6               hbedff68_3    conda-forge
meson                     1.5.1              pyhd8ed1ab_1    conda-forge
meson-python              0.16.0             pyh0c530f3_0    conda-forge
mpc                       1.3.1                h9d8efa1_0    conda-forge
mpfr                      4.2.1                hc80595b_2    conda-forge
ncurses                   6.5                  hf036a51_1    conda-forge
ninja                     1.12.1               h3c5361c_0    conda-forge
numpy                     2.1.0           py312h8813227_0    conda-forge
openssl                   3.3.1                hd23fc13_3    conda-forge
packaging                 24.1               pyhd8ed1ab_0    conda-forge
pip                       24.2               pyh8b19718_1    conda-forge
pluggy                    1.5.0              pyhd8ed1ab_0    conda-forge
pyproject-metadata        0.8.0              pyhd8ed1ab_0    conda-forge
pytest                    8.3.2              pyhd8ed1ab_0    conda-forge
python                    3.12.5          h37a9e06_0_cpython    conda-forge
python_abi                3.12                    5_cp312    conda-forge
readline                  8.2                  h9e318b2_1    conda-forge
scikit-learn              1.6.dev0                 pypi_0    pypi
scipy                     1.14.1          py312he82a568_0    conda-forge
setuptools                72.2.0             pyhd8ed1ab_0    conda-forge
sigtool                   0.1.3                h88f4db0_0    conda-forge
tapi                      1100.0.11            h9ce4665_0    conda-forge
threadpoolctl             3.5.0              pyhc1e730c_0    conda-forge
tk                        8.6.13               h1abcd95_1    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tzdata                    2024a                h8827d51_1    conda-forge
wheel                     0.44.0             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h775f41a_0    conda-forge
zlib                      1.3.1                h87427d6_1    conda-forge
zstd                      1.5.6                h915ae27_0    conda-forge
```

When compiling I get warning: 

```
[139/251] Compiling C object sklearn/metrics/_dist_metrics.cpython-312-darwin.so.p/meson-generated_sklearn_metrics__dist_metrics.pyx.c.o
  sklearn/metrics/_dist_metrics.cpython-312-darwin.so.p/sklearn/metrics/_dist_metrics.pyx.c:29538:29: warning: assigning to '__pyx_t_7sklearn_5utils_9_typedefs_float64_t *' (aka 'double *') from 'const __pyx_t_7sklearn_5utils_9_typedefs_float64_t *' (aka 'const double *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
              __pyx_v_x2_data = ((&(*((__pyx_t_7sklearn_5utils_9_typedefs_float64_t const  *) ( /* dim=1 */ ((char *) (((__pyx_t_7sklearn_5utils_9_typedefs_float64_t const  *) ( /* dim=0 */ (__pyx_v_Y_data.data + __pyx_t_18 * __pyx_v_Y_data.strides[0]) )) + __pyx_t_19)) )))) + (__pyx_v_i2 * __pyx_v_n_features));
```

Labels: Question