Setting up manual HA development environment on RPi5

A mini-howto for setting up a manual dev environment on the Raspberry Pi 5, figured I might save someone some time including myself in case I forget in the future.

  1. Install Raspberry Pi OS (64-bit) Lite per the instructions here.

At this time RPi OS uses Python 3.11 but HA Core needs at least version 3.12, so…

  1. Download and install Python 3.12.4 or later from source.
# Download source
$ wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz
# Install the build tools
$ sudo apt update
$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev  libsqlite3-dev
# Configure, make and make install
# This will install Python at /usr/local/bin/python3.12
$ tar -xzvf Python-3.12.4.tgz 
$ cd Python-3.12.4/
$ ./configure --enable-optimizations
$ sudo make altinstall
  1. Install HA manual development environment, following the instructions here). But before you get to this step:
# Install the requirements with a provided script named `setup` .
$ script/setup

Edit the setup script, modifying the following line.

python3 -m venv venv

to

/usr/local/bin/python3 -m venv venv

Then proceed with running the setup script. You should remove the above edit after the installation.

Of course this is basically a hack but since RPi OS will eventually use a more recent Python version its not worth modifying the script properly to handle this case at runtime.