Numpy issue on HA core 2024.10.1

I finally managed to install numpy 2.2.2 using the following steps with help from this post and Gemini.

Workaround Steps: This involves downloading the NumPy source, manually patching the vendored Meson file, and then installing the patched source.

(Run these commands as the user who manages your Home Assistant virtual environment, e.g., homeassistant or pi)

  1. Navigate to a workspace directory:cd ~
  2. Download NumPy 2.2.2 Source Code:wget https://files.pythonhosted.org/packages/ec/d0/c12ddfd3a02274be06ffc71f3efc6d0e457b0409c4481596881e748cb264/numpy-2.2.2.tar.gz
  3. Extract the Source Code:tar -xzf numpy-2.2.2.tar.gz
  4. Edit the Vendored Meson File: Use a text editor like nano:nano numpy-2.2.2/vendored-meson/meson/mesonbuild/environment.py
  5. Apply the Patch:
  • Inside the editor, find the function definition line (around line 960-970):def need_exe_wrapper(self, for_machine: MachineChoice = MachineChoice.HOST):
  • Immediately after this def line, insert the following two lines. Crucially, ensure correct indentation: the if line should have 4 spaces, and the return line should have 8 spaces.if not self.is_cross_build(): return False
  • The beginning of the function should now look like this:
def need_exe_wrapper(self, for_machine: MachineChoice = MachineChoice.HOST):
    # ---- Start of Inserted Patch ----
    if not self.is_cross_build():
        return False
    # ---- End of Inserted Patch ----
 
    # Original code continues below
    value = self.properties[for_machine].get('needs_exe_wrapper', None)`
    # ... rest of function
  • Save the file and exit nano (Ctrl+X, then Y, then Enter).
  1. Install the Patched NumPy:
  • Activate your Home Assistant virtual environment: source /srv/homeassistant/bin/activate

  • Make sure you are in the directory containing the numpy-2.2.2 folder (e.g., cd ~).

  • Run the installation:pip install ./numpy-2.2.2

Important Notes & Warnings:

  • Workaround, Not a Fix: This manually patches the NumPy source for this specific installation. If you update/reinstall NumPy or recreate your virtual environment, you’ll need to repeat the patch.
  • Indentation Matters: Python errors (TabError) will occur if the indentation of the added lines is incorrect. Use spaces, not tabs (4 for the if, 8 for the return).
  • !! Potential for Incorrect Final Package !!: Even after this patch allows the build to complete, the underlying platform detection issue within Meson might persist. In testing, this resulted in the final wheel being incorrectly tagged (linux_armv7l instead of linux_aarch64) and NumPy linking against incorrect 32-bit libraries (arm-linux-gnueabihf instead of aarch64-linux-gnu).