Build failure under Termux: can not execute sklearn/_build_utils/version.py

### Describe the bug

When attempting to install the newest (and older) versions of scikit-learn-1.6.dev0 using regular pip install, the installation fails due to a missing version.py file. This issue occurs on an Android system using Termux.
Environment details:
OS: Linux localhost 4.14.186+ (Android)
Architecture: aarch64
Python: 3.11
The error occurs during the Meson build process, which tries to execute a non-existent file:
/data/data/com.termux/files/home/downloads/scikit-learn/sklearn/_build_utils/version.py
A workaround patch has been developed to address this issue:
```
#!/bin/bash

# Navigate to the scikit-learn directory, e.g.:
cd ~/downloads/scikit-learn

# Extract version from pyproject.toml and remove "dev" suffix
VERSION=$(grep 'version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/' | sed 's/\.dev0//')

# Create the directory if it doesn't exist
mkdir -p sklearn/_build_utils

# Create the version.py file with the correct content
cat << EOF > sklearn/_build_utils/version.py
#!/usr/bin/env python
print('${VERSION}')
EOF

# Make the file executable
chmod +x sklearn/_build_utils/version.py

echo "Created sklearn/_build_utils/version.py with version ${VERSION}"
```
This patch:
- Extracts the version number from pyproject.toml
- Removes the "dev" suffix
- Creates the missing version.py file with a generic Python shebang
- Makes the file executable

After applying this patch, the Meson build process completes successfully, and the installation can proceed: 
```
cpu family: aarch64
Host machine cpu: aarch64
Compiler for C supports arguments -Wno-unused-but-set-variable: YE
Compiler for C supports arguments -Wno-unused-function: YES
Compiler for C supports arguments -Wno-conversion: YES
Compiler for C supports arguments -Wno-misleading-indentation: YES
Library m found: YES
Program python3 found: YES (/data/data/com.termux/files/usr/bin/python3.11)
Run-time dependency OpenMP for c found: YES 5.1
Found pkg-config: YES (/data/data/com.termux/files/usr/bin/pkg-config) 0.29.2
Run-time dependency python found: YES 3.11    Build targets in project: 111
Found ninja-1.11.1.git.kitware.jobserver-1 ...
```
and:
```
Successfully installed scikit-learn-1.6.dev0  ~/downloads/scikit-learn $
```

### Steps/Code to Reproduce

pip install -U -v scikit-learn

### Expected Results

.

### Actual Results

.

### Versions

```shell
scikit-learn-1.6.dev0, and older
```

COMMENT:
As I wrote: `using regular pip install` and "Steps/Code to Reproduce
pip install -U -v scikit-learn" . 
 (Also after git clone etc.).   Let me retry today. 

1. Uninstalling the manually patched version: 
```
    /data/data/com.termux/files/usr/lib/python3.11/site-packages/sklearn/utils/murmurhash.cpython-311-aarch64-linux-gnu.so
    /data/data/com.termux/files/usr/lib/python3.11/site-packages/sklearn/utils/sparsefuncs_fast.cpython-311-aarch64-linux-gnu.so
Proceed (Y/n)? y
  Successfully uninstalled scikit-learn-1.6.dev0

```

2. Uninstalling yet another version, not sure where it came from - possibly patched in a similar way: 

```
    /data/data/com.termux/files/usr/lib/python3.11/site-packages/sklearn/utils/arrayfuncs.cpython-311-aarch64-linux-gnu.so
    /data/data/com.termux/files/usr/lib/python3.11/site-packages/sklearn/utils/murmurhash.cpython-311-aarch64-linux-gnu.so
    /data/data/com.termux/files/usr/lib/python3.11/site-packages/sklearn/utils/sparsefuncs_fast.cpython-311-aarch64-linux-gnu.so
Proceed (Y/n)? y
  Successfully uninstalled scikit-learn-1.5.0
```

3. Now installing the regular way:
```
~/downloads $ pip install -U -v scikit-learn
Using pip 24.1.1 from /data/data/com.termux/files/usr/lib/python3.11/site-packages/pip (python 3.11)
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu
Collecting scikit-learn
  Using cached scikit_learn-1.5.0.tar.gz (7.8 MB)
  Running command pip subprocess to install build dependencies
  Using pip 24.1.1 from /data/data/com.termux/files/usr/lib/python3.11/site-packages/pip (python 3.11)
  Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu, https://download.pytorch.org/whl/cpu
  Collecting meson-python>=0.15.0
    Obtaining dependency information for meson-python>=0.15.0 from https://files.pythonhosted.org/packages/91/c0/104cb6244c83fe6bc3886f144cc433db0c0c78efac5dc00e409a5a08c87d/meson_python-0.16.0-py3-none-any.whl.metadata
    Using cached meson_python-0.16.0-py3-none-any.whl.metadata (4.1 kB)
  Collecting Cython>=3.0.10
    Obtaining dependency information for Cython>=3.0.10 from https://files.pythonhosted.org/packages/b6/83/b0a63fc7b315edd46821a1a381d18765c1353d201246da44558175cddd56/Cython-3.0.10-py2.py3-none-any.whl.metadata
    Using cached Cython-3.0.10-py2.py3-none-any.whl.metadata (3.2 kB)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/3a/be/650f9c091ef71cb01d735775d554e068752d3ff63d7943b26316dc401749/numpy-1.21.2.zip (from https://pypi.org/simple/numpy/) (requires-python:>=3.7,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/5f/d6/ad58ded26556eaeaa8c971e08b6466f17c4ac4d786cd3d800e26ce59cc01/numpy-1.21.3.zip (from https://pypi.org/simple/numpy/) (requires-python:>=3.7,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/fb/48/b0708ebd7718a8933f0d3937513ef8ef2f4f04529f1f66ca86d873043921/numpy-1.21.4.zip (from https://pypi.org/simple/numpy/) (requires-python:>=3.7,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/c2/a8/a924a09492bdfee8c2ec3094d0a13f2799800b4fdc9c890738aeeb12c72e/numpy-1.21.5.zip (from https://pypi.org/simple/numpy/) (requires-python:>=3.7,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/45/b7/de7b8e67f2232c26af57c205aaad29fe17754f793404f59c8a730c7a191a/numpy-1.21.6.zip (from https://pypi.org/simple/numpy/) (requires-python:>=3.7,<3.11)
  Collecting numpy>=2.0.0rc2
    Using cached numpy-2.0.0-cp311-cp311-linux_aarch64.whl
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.10'): https://files.pythonhosted.org/packages/99/f1/c00d6be56e1a718a3068079e3ec8ce044d7179345280f6a3f5066068af0d/scipy-1.6.2.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.10)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.10'): https://files.pythonhosted.org/packages/fe/fd/8704c7b7b34cdac850485e638346025ca57c5a859934b9aa1be5399b33b7/scipy-1.6.3.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.10)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.10'): https://files.pythonhosted.org/packages/bb/bb/944f559d554df6c9adf037aa9fc982a9706ee0e96c0d5beac701cb158900/scipy-1.7.0.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.10)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.10'): https://files.pythonhosted.org/packages/47/33/a24aec22b7be7fdb10ec117a95e1e4099890d8bbc6646902f443fc7719d1/scipy-1.7.1.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.10)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/0e/23/58c4f995475a2a97cb5f4a032aedaf881ad87cd976a7180c55118d105a1d/scipy-1.7.2.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.7,<3.11'): https://files.pythonhosted.org/packages/61/67/1a654b96309c991762ee9bc39c363fc618076b155fe52d295211cf2536c7/scipy-1.7.3.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.8,<3.11'): https://files.pythonhosted.org/packages/c0/ad/e3c052ed4e0027a8abef0a5e8441a044427d252d17d9aee06d56e62fc698/scipy-1.8.0rc1.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.8,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.8,<3.11'): https://files.pythonhosted.org/packages/29/d2/151a54944b333e465f98804dced31dab1284f3c37b752b9cefa710b64681/scipy-1.8.0rc2.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.8,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.8,<3.11'): https://files.pythonhosted.org/packages/e4/26/83dd1c6378513a6241d984bda9f08c512b6e35fff13fba3acc1b3c195f02/scipy-1.8.0rc3.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.8,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.8,<3.11'): https://files.pythonhosted.org/packages/22/78/056cc43e7737811b6f50886788a940f852773dd9804f5365952805db9648/scipy-1.8.0rc4.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.8,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.8,<3.11'): https://files.pythonhosted.org/packages/b4/a2/4faa34bf0cdbefd5c706625f1234987795f368eb4e97bde9d6f46860843e/scipy-1.8.0.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.8,<3.11)
    Link requires a different Python (3.11.9 not in: '>=3.8,<3.11'): https://files.pythonhosted.org/packages/26/b5/9330f004b9a3b2b6a31f59f46f1617ce9ca15c0e7fe64288c20385a05c9d/scipy-1.8.1.tar.gz (from https://pypi.org/simple/scipy/) (requires-python:>=3.8,<3.11)
  Collecting scipy>=1.6.0
    Using cached scipy-1.14.0-cp311-cp311-linux_aarch64.whl
  Collecting meson>=0.63.3 (from meson-python>=0.15.0)
    Obtaining dependency information for meson>=0.63.3 from https://files.pythonhosted.org/packages/44/b2/d4433391a7c5e94a39b50ca7295a8ceba736e7c72c455752a60122f52453/meson-1.4.1-py3-none-any.whl.metadata
    Using cached meson-1.4.1-py3-none-any.whl.metadata (1.8 kB)
  Collecting packaging>=19.0 (from meson-python>=0.15.0)
    Obtaining dependency information for packaging>=19.0 from https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl.metadata
    Using cached packaging-24.1-py3-none-any.whl.metadata (3.2 kB)
  Collecting pyproject-metadata>=0.7.1 (from meson-python>=0.15.0)
    Obtaining dependency information for pyproject-metadata>=0.7.1 from https://files.pythonhosted.org/packages/aa/5f/bb5970d3d04173b46c9037109f7f05fc8904ff5be073ee49bb6ff00301bc/pyproject_metadata-0.8.0-py3-none-any.whl.metadata
    Using cached pyproject_metadata-0.8.0-py3-none-any.whl.metadata (3.0 kB)
  Using cached meson_python-0.16.0-py3-none-any.whl (26 kB)
  Using cached Cython-3.0.10-py2.py3-none-any.whl (1.2 MB)
  Using cached meson-1.4.1-py3-none-any.whl (937 kB)
  Using cached packaging-24.1-py3-none-any.whl (53 kB)
  Using cached pyproject_metadata-0.8.0-py3-none-any.whl (7.5 kB)
  Installing collected packages: packaging, numpy, meson, Cython, scipy, pyproject-metadata, meson-python
    Creating /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin
    changing mode of /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin/f2py to 755
    changing mode of /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin/numpy-config to 755
    changing mode of /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin/meson to 755
    changing mode of /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin/cygdb to 755
    changing mode of /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin/cython to 755
    changing mode of /data/data/com.termux/files/usr/tmp/pip-build-env-kd2fzqe_/overlay/bin/cythonize to 755
  ... 
  Successfully installed Cython-3.0.10 meson-1.4.1 meson-python-0.16.0 numpy-2.0.0 packaging-24.1 pyproject-metadata-0.8.0 scipy-1.14.0
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  Getting requirements to build wheel ... done
  Running command Preparing metadata (pyproject.toml)
  + meson setup /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1 /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1/.mesonpy-ljngdcfu -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1/.mesonpy-ljngdcfu/meson-python-native-file.ini
  The Meson build system
  Version: 1.4.1
  Source dir: /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1
  Build dir: /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1/.mesonpy-ljngdcfu
  Build type: native build

  ../meson.build:4:11: ERROR: Could not execute command `/usr/bin/env python /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1/sklearn/_build_utils/version.py`.

  A full log can be found at /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1/.mesonpy-ljngdcfu/meson-logs/meson-log.txt
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /data/data/com.termux/files/usr/bin/python3.11 /data/data/com.termux/files/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /data/data/com.termux/files/usr/tmp/tmp2njzxn_z
  cwd: /data/data/com.termux/files/usr/tmp/pip-install-2c1ik6pc/scikit-learn_e619a22e86e14479a9431ce3a7de84a1
  Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
~/downloads $ 

```

So the identical error. 

I hope that helps.

Labels: Build / CI, Low Priority