Python 3.12 backport for Debian 12 bookworm
Fellow Debian HASS core users: I am back again with another backport for Python 3.12 which you can use for Home Assistant! Although demand for these backports is rapidly declining and more and more people start shifting towards Container or OS, I still prefer the minimalistic nature of core. In the past I’ve created Python backports for Debian 10 and Debian 11.
Home Assistant 2024.4 has dropped support for Python 3.11 so now we are forced to use Python 3.12. Debian 12 bookworm doesn’t have Python 3.12 however and the next release of Debian is still far away.
There are of course other ways to install Python 3.12 such as pyenv
or compiling from scratch. Packages are much better manageable than compiling the source from scratch. In my opinion it is also more manageable than using pyenv
. By using my packages you will also be sure to get the latest patches (on a best effort basis).
Scope
The scope of this project is limited to backporting just Python 3.12 itself. So no defaults (which provide virtual packages so python3
get’s automatically linked to python3.12
) and no precompiled pip-packages or wheels besides pip itself. Therefore it can coexist with your regular Python (3.11) installation without any interference and still being simple to maintain. It’s main use is for in virtual environments where you can use pip to compile and install any packages you desire. It does provide all the packages and dependencies needed to create a Python 3.12 virtual environment.
So if you want something to use Python 3.12, just execute the command as python3.12
instead of python3
or python
.
Usage for Home Assistant Core
The usage of my packages is tested for people who followed the Install Home Assistant Core advanced guide.
You can follow the steps below to add my repository to your system and then follow that guide while replacing every instance of python3
with python3.12
to get a working virtual environment. There is one major exception:
- There is no
python3.12-pip
package. Pip is included inside the venv-package (in contrary to normally in Debian).
So if you already used that guide before, you only have to install python3.12
, python3.12-dev
and python3.12-venv:
sudo apt install python3.12 python3.12-venv python3.12-dev
Existing users of a Home Assistant virtual environment created with a different Python version must recreate the environment. This can take a very long time, especially if there are no wheels available for your architecture (armhf
is known for this). Upgrading an existing environment is difficult/impossible. It is however possible to create an environment while Home Assistant is running in a different directory, stop Home Assistant and swap them out to minimize downtime.
Repository
NOTE: You should never install keys and add repositories from developers you don’t trust. Decide for yourself if I’m trustworthy and if you have any doubts, check out the source and compile the packages yourself.
Packages can be downloaded from my repository at deb.pascalroeleven.nl
. First you should also add my PGP (which you can get from my website via https) to APT’s sources keyring:
wget -qO- https://pascalroeleven.nl/deb-pascalroeleven.gpg | sudo tee /etc/apt/keyrings/deb-pascalroeleven.gpg
Now you can add my repository by adding a file with my repository to the sources.list.d
directory:
cat <<EOF | sudo tee /etc/apt/sources.list.d/pascalroeleven.sources
Types: deb
URIs: http://deb.pascalroeleven.nl/python3.12
Suites: bookworm-backports
Components: main
Signed-By: /etc/apt/keyrings/deb-pascalroeleven.gpg
EOF
After running apt update
you should now be able to install Python 3.12 related packages.
Chain of trust (sort of)
Packages are built using Github actions along with a file containing the checksums of all packages. Therefore, you can compare the checksums of the packages in the repository with the checksums in Github Actions and trace the entire process (up to 90 days after the build after which the artifacts and logs get removed). This way, if you trust the Github Actions build system, you can be sure that the packages I provide are actually built using the instructions in this repo.
Support
Currently there is support for amd64
, arm64
and armhf
architectures. The amd64
packages are build natively while the arm64
and armhf
packages are crossbuilt. Testing is not possible while crossbuilding, so these packages did not undergo the same amount of testing as usual Debian packages do.
Extra note for people running on armhf
(armv7
)
As there aren’t a lot of pip wheels available for this architecture, it can be a pain to install Home Assistant Core this way. It requires a lot of extra dependencies such as rustc
, ninja-build
, cmake
and libopenblas0
from what I can remember. Also it can therefore take ages to build this. As I will be using this on armv7 myself, I might provide a tutorial on how to install HASS Core on this architecture in the future.
Questions
For more technical details, you can checkout Github
If something is unclear or if you have any problems, please let me know! I consider myself a somewhat advanced system administrator and I might have skipped over some non-trivial steps somehow.