Unable to successfully install scikit-learn development version with MacBookPro with chip Apple M1 Pro

### Describe the bug

I installed the development version of scikit-learn on my computer (MacBookPro with chip Apple M1 Pro). When I ran pytest I got the following error: 
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```

I investigated what's going on an this is the result: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

I'm using a conda environment. I used the Miniforge3-MacOSX-arm64 download from here: https://github.com/conda-forge/miniforge#miniforge

This is the content of my sklearn-dev conda environment: 
https://gist.github.com/marenwestermann/c01fc4d3044522e329ce83d16680e1a5

### Steps/Code to Reproduce

```
pytest
```

```
python -vvv -c "import sklearn"
```

### Expected Results

The expected result would be that when the command `pytest` is run all test are either skipped or are successful. 

### Actual Results

Pytest result:
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```
Further investigation: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

### Versions

```shell
function>
```

COMMENT:
I can reproduce  in the following env I create a few days ago. I build scikit-learn from scratch (`make clean in`) but did not install it.

<details>

```
name: dev310
channels:
  - conda-forge
dependencies:
  - asttokens=2.0.5=pyhd8ed1ab_0
  - attrs=21.4.0=pyhd8ed1ab_0
  - backcall=0.2.0=pyh9f0ad1d_0
  - backports=1.0=py_2
  - backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
  - black=22.1.0=pyhd8ed1ab_0
  - bzip2=1.0.8=h3422bc3_4
  - c-compiler=1.4.0=hccd94f0_0
  - ca-certificates=2021.10.8=h4653dfc_0
  - cctools=973.0.1=ha9384d2_7
  - cctools_osx-arm64=973.0.1=h83ffe51_7
  - clang=12.0.1=hce30654_4
  - clang-12=12.0.1=default_h2cfa9b4_4
  - clang_osx-arm64=12.0.1=hc0c6576_6
  - clangxx=12.0.1=default_hf584372_4
  - clangxx_osx-arm64=12.0.1=hc2331a0_6
  - cloudpickle=2.0.0=pyhd8ed1ab_0
  - compiler-rt=12.0.1=h94c6b0c_0
  - compiler-rt_osx-arm64=12.0.1=h44bac85_0
  - compilers=1.4.0=hce30654_0
  - cxx-compiler=1.4.0=h3e96240_0
  - dataclasses=0.8=pyhc8e2a94_3
  - decorator=5.1.1=pyhd8ed1ab_0
  - execnet=1.9.0=pyhd8ed1ab_0
  - executing=0.8.2=pyhd8ed1ab_0
  - fortran-compiler=1.4.0=haab47bd_0
  - gfortran=11.0.1.dev0=h40eb566_15
  - gfortran_impl_osx-arm64=11.0.1.dev0=hbce66ab_23
  - gfortran_osx-arm64=11.0.1.dev0=h57527a5_15
  - gmp=6.2.1=h9f76cd9_0
  - iniconfig=1.1.1=pyh9f0ad1d_0
  - isl=0.22.1=hb904e53_2
  - joblib=1.1.0=pyhd8ed1ab_0
  - ld64=609=h08716b2_7
  - ld64_osx-arm64=609=h7c97014_7
  - libblas=3.9.0=13_osxarm64_openblas
  - libcblas=3.9.0=13_osxarm64_openblas
  - libclang-cpp12=12.0.1=default_h2cfa9b4_4
  - libcxx=12.0.1=h168391b_1
  - libffi=3.4.2=h3422bc3_5
  - libgfortran=5.0.0.dev0=11_0_1_hf114ba7_23
  - libgfortran-devel_osx-arm64=11.0.1.dev0=hf114ba7_23
  - libgfortran5=11.0.1.dev0=hf114ba7_23
  - libiconv=1.16=h642e427_0
  - liblapack=3.9.0=13_osxarm64_openblas
  - libllvm12=12.0.1=h93073aa_2
  - libopenblas=0.3.18=openmp_h5dd58f0_0
  - libzlib=1.2.11=hee7b306_1013
  - llvm-openmp=13.0.1=hf3c4609_0
  - llvm-tools=12.0.1=h93073aa_2
  - loky=3.0.0=pyhd8ed1ab_0
  - matplotlib-inline=0.1.3=pyhd8ed1ab_0
  - mpc=1.2.1=h309154c_0
  - mpfr=4.1.0=h6d7a090_1
  - mypy_extensions=0.4.3=py310hbe9552e_4
  - ncurses=6.3=hc470f4d_0
  - openssl=3.0.0=h3422bc3_2
  - packaging=21.3=pyhd8ed1ab_0
  - parso=0.8.3=pyhd8ed1ab_0
  - pathspec=0.9.0=pyhd8ed1ab_0
  - pexpect=4.8.0=pyh9f0ad1d_2
  - pickleshare=0.7.5=py_1003
  - pip=22.0.3=pyhd8ed1ab_0
  - platformdirs=2.5.1=pyhd8ed1ab_0
  - prompt-toolkit=3.0.27=pyha770c72_0
  - ptyprocess=0.7.0=pyhd3deb0d_0
  - pure_eval=0.2.2=pyhd8ed1ab_0
  - py=1.11.0=pyh6c4a22f_0
  - pygments=2.11.2=pyhd8ed1ab_0
  - pyparsing=3.0.7=pyhd8ed1ab_0
  - pytest-forked=1.4.0=pyhd8ed1ab_0
  - pytest-xdist=2.5.0=pyhd8ed1ab_0
  - python=3.10.2=h38ef502_3_cpython
  - python-dateutil=2.8.2=pyhd8ed1ab_0
  - python_abi=3.10=2_cp310
  - pytz=2021.3=pyhd8ed1ab_0
  - readline=8.1=hedafd6a_0
  - sigtool=0.1.3=h44b9a77_0
  - six=1.16.0=pyh6c4a22f_0
  - sqlite=3.37.0=h72a2b83_0
  - stack_data=0.2.0=pyhd8ed1ab_0
  - tapi=1100.0.11=he4954df_0
  - threadpoolctl=3.1.0=pyh8a188c0_0
  - tk=8.6.12=he1e0b03_0
  - tomli=2.0.1=pyhd8ed1ab_0
  - traitlets=5.1.1=pyhd8ed1ab_0
  - typing_extensions=4.1.1=pyha770c72_0
  - tzdata=2021e=he74cb21_0
  - wcwidth=0.2.5=pyh9f0ad1d_2
  - wheel=0.37.1=pyhd8ed1ab_0
  - xz=5.2.5=h642e427_1
  - zlib=1.2.11=hee7b306_1013
  - pip:
    - appnope==0.1.2
    - click==8.0.4
    - cython==0.29.28
    - ipython==8.0.1
    - jedi==0.18.1
    - mypy-extensions==0.4.3
    - numpy==1.22.2
    - pandas==1.4.1
    - pluggy==1.0.0
    - psutil==5.9.0
    - pytest==7.0.1
    - scipy==1.8.0
    - setuptools==60.9.3
    - typed-ast==1.5.2
prefix: /Users/ogrisel/mambaforge/envs/dev310
```

</details>

In this env, if I run pytest I get the killed python error:

```
python -m pytest
```
```
==================================================== test session starts ====================================================
platform darwin -- Python 3.10.2, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/ogrisel/code/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0
collecting ... [1]    34002 killed     python -m pytest
```

When trying to debug this with lldb to get a post-mortem backtrace I got the surprise that running this in lldb got the lldb process itself to get killed:

```
lldb -- python -m pytest
```
```
(lldb) target create "python"
Current executable set to 'python' (arm64).
(lldb) settings set -- target.run-args  "-m" "pytest"
(lldb) run
Process 39693 launched: '/Users/ogrisel/mambaforge/envs/dev310/bin/python' (arm64)
============================= test session starts ==============================
platform darwin -- Python 3.10.2, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/ogrisel/code/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0
collecting ... [1]    39691 killed     lldb -- python -m pytest
```

Then I tried again with a new env and this time got an explicit error message instead of a crash:

```
mamba install -y -n tmp scipy cython compilers joblib threadpoolctl
conda activate tmp
make clean in
pytest
```
```
[...]
    raise ImportError(
E   ImportError: No module named 'sklearn.__check_build._check_build'
```

and then I get the error message that tells me to install scikit-learn before trying to import it. If you run:

```
pip install -e . --no-build-isolation
```

then everything works fine. And it does work fine in both environments!

@marenwestermann  how did you build and install scikit-learn? Did run `pip install -e .  --no-build-isolation`? or something else?

Labels: Bug, Build / CI