Home Assistant Core - Python 3.10 backport for Debian 11 bullseye

Super :slight_smile:
You saved xx hours of valuable time!

sudo apt install python3.10 python3.10-venv python3.10-dev

Maybe add this to instructions as my stupid brain always forgets the -venv part :frowning:
Best and hope to see You again when 3.11 hits breaking changesā€¦ , JR

Youā€™re welcome. Iā€™ve added the command to clarify that.

If Iā€™m still using Home Assistant (canā€™t see why not), then I probably will be. Python releases roughly every year, Debian roughly every two years and Home Assistant supports only the latest two stable Python versions. So for the time being there will always be overlap.

Thanks :slight_smile:
As of latest beta Python 3.11 is already supported and promises HUGE speed improvement in HA- so a humble request: could You make a backport for it also before breaking changes hit next year?
Best, JR

I have read about the speed improvements in 3.11 as well.

At the moment the maintainer in Debian is regularly making some core changes to the packaging (to comply with all the ā€˜Debian standardsā€™ etc.) of 3.11, so it might not be that stable yet. In my opinion itā€™s best to stay on 3.10 for now until they have ironed out all the issues. But then I prefer my software to be stable and secure instead of bleeding-edge.

However Iā€™ll see what I can do and if the backport works you can then decide for yourself if you want to use it already.

Thanks for a prompt reply.
I was not thinking of ASAP solution but thought that 3.11 would be a nice step forward in near future when all its compatibility issues are ironed out.
Best, JR

Just wanted to say thanks for this. I had left off upgrading for too long, and this certainly shortened a lot of the steps.

Just a shameless :frowning: desire for 3.11 as HA beta 2023.6 is rolling out with resolved Python problems I guess :slight_smile:
Would be super nice and TIAā€¦
Best, JR

Hi, I am sorry for the late reply, Iā€™ve been quite busy lately. I really appreciate your interest in my project.

If all goes to plan, Debian 12 bookworm will be releasing on the 10th of June which contains Python 3.11. I guess upgrading to Debian 12 will be your best and safest bet of using Python 3.11 successfully without any 3rd party ā€˜hacksā€™. Although personally I always hold off upgrading until the first point release, upgrading should be pretty safe to do. Please note that, and this applies to anyone upgrading to Debian 12, you need to remove my repository from your APT sources and remove all Python 3.10 specific packages before upgrading. Maybe it is handled automatically by the installer, but I canā€™t guarantee that.

You will also need to recreate any virtual environments you have made for Home Assistant or any other Python project using my Python packages.

Thanks for Your time and effort :slight_smile:
Seems that I must split my house iot stuff- move HA from core venv to OS and offload other stuff to another host :frowning:
But anyway so the world is moving on now- less options and settings, all available at max 3 clicks/swipes- pity :frowning:
Best and thanks once again for some years of painless backports :slight_smile: , JR

1 Like

Whatā€™s wrong with upgrading your entire system? Debian 11 will be EOL in one year from now anyway. Sooner or later you must upgrade.

Might be others that ā€œneedā€ to stay on bullseye.
My notes on RPI4 bullseye
From https://aruljohn.com/blog/python-raspberrypi/ as user pi

cd /tmp
wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libsqlite3-dev
tar -xzvf Python-3.11.4.tgz 
cd Python-3.11.4/
./configure --enable-optimizations
sudo make altinstall

From ā€œaboveā€

sudo mkdir /srv/homeassistant3.11
sudo chown homeassistant:homeassistant /srv/homeassistant3.11
sudo -u homeassistant -H -s
cd /srv/homeassistant3.11
python3.11 -m venv .
source bin/activate
pip install --upgrade setuptools
python -m pip install wheel
pip install homeassistant==2023.6.1 # Current version

exit to pi

sudo systemctl stop [email protected]
sudo vi /etc/systemd/system/[email protected]
*Comment ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant"*
*New line ExecStart=/srv/homeassistant3.11/bin/hass -c "/home/%i/.homeassistant"*
sudo systemctl daemon-reload
sudo systemctl start [email protected]

You can definitely install Python manually like that, but that directly contradicts everything I was trying to achieve with this backport.

Considering Debian is always ā€˜lacking behindā€™ when it comes to software versions (which is a feature, donā€™t get me wrong), when there finally is a new version available, I would strongly consider updating. In many cases there is no valid reason to stay on an older version for much longer.

Sorry if Iā€™ve done something ā€œwrongā€.
I do have my reasons, read more than ā€œdeb Index of /python3.10 ā€¦ā€ under /etc/apt and running in a virtual environment should be safe until I resolve the ā€œbookworm issiuesā€ for my other repositories.
BTW
Thanks!

Of course you havenā€™t done anything wrong. Any experience of how you solved a problem is a good one and worth sharing.

Itā€™s just not the goal I had in mind. I wanted people to have an easy way to install Python 3.10 without messing with compiling it and possibly bricking their systems by installing it wrong.

:+1: :ok_hand:

Hello,

It looks Python 3.11 will be deprecated soon, 2023.2 if I understand correctly.

Do you plan to make a similar backport for Python 3.12 in Bookworm?

I personally am still using Debian Buster and Python 3.10, so I am still on 2023.7 or something. Havenā€™t taken the time to upgrade fully.

It is a shame that theyā€™re dropping Python support even faster nowadays but I can somewhat understand it.

Youā€™re correct, Iā€™ve taken a look at the code, and theyā€™re deprecating Python 3.11 in 2024.2 and removing support in 2024.4. So we still have 2 months left.

I currently have no plans to support it, however as I will probably need it myself in the future, there is a high change that I will create a backport. The question is if I am on time before 2024.4ā€¦

Thanks for letting me know and when I have a backport for 3.12 ready, Iā€™ll link it here.

FYI, in my case the upgrade from Bullseye to Bookworm had no particular issue but I donā€™t know your specific setup :slight_smile:

I also have been surprised, I thought two last versions of Python was supported by Home Assistant but looks it is not really the case anymore.

It looks I will have to use pyenv again :slight_smile: except if I can do anything to help you to have a backport on time, I have some experience on GitHub and less on Debian packaging even if I am now maintaining two official little packages on Debian now so if I can do anything, do not hesitate to ask, I am OK to test for example.

Thank you! I want to do a full reinstall because I want to make some changes such as full disk encryption which require a reinstall anyway. So it takes a bit of time before my new image is ready :wink:

Yeah thatā€™s correct, they changed it in ADR-0020 to just one unfortunately. Reasoning that 96% of the users use Container based installations and therefore Python support doesnā€™t matter.

Thanks for your offer! Backporting Python can be quite cumbersome because of dependencies on all the wheels and pip etc. Backporting the full suite will cost a lot of time and may even be impossible because of dependency clashes (which is probably why it isnā€™t done in the -backports repository). So Iā€™ve sort of hacked it together by only backporting Python itself and linking them to the Python pip and wheels already present on the system. This has worked reasonably well.

If it doesnā€™t work out, you can still go pyenv in two months :wink:

For @Nardol and everyone else who might be interested in running HASS Core 2024.4 on Debian: This might interest you :wink: Python 3.12 backport for Debian 12 bookworm

1 Like