Skip to content

Commit

Permalink
Update core installation instructions to use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
sdb9696 committed Oct 14, 2024
1 parent bf7ce6b commit 7bbff57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
4 changes: 3 additions & 1 deletion source/_includes/common-tasks/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ To update Home Assistant Core when you run Home Assistant {{ page.installation_n

4. Download and install the new version

N.B. If you have not previously installed core using uv [install uv](https://docs.astral.sh/uv/getting-started/installation/).

```bash
pip3 install --upgrade homeassistant
uv pip install --upgrade homeassistant
```

5. When that is complete start the service again for it to use the new files.
Expand Down
35 changes: 20 additions & 15 deletions source/_includes/installation/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ This is an advanced installation process, and some steps might differ on your sy

### Prerequisites

This guide assumes that you already have an operating system setup and have installed Python {{site.installation.versions.python}} (including the package `python3-dev`) or newer.
This guide assumes that you already have an operating system setup.
The instructions below will guide you through installing [uv](https://docs.astral.sh/uv/) which ships with downloadable python installations for most platforms.
If for some reason it cannot find a python download for your operating system you will need to install Python {{site.installation.versions.python}} yourself.

### Install dependencies

Expand All @@ -28,7 +30,7 @@ sudo apt-get upgrade -y
Install the dependencies:

```bash
sudo apt-get install -y python3 python3-dev python3-venv python3-pip bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff6 libturbojpeg0-dev tzdata ffmpeg liblapack3 liblapack-dev libatlas-base-dev
sudo apt-get install -y bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff6 libturbojpeg0-dev tzdata ffmpeg liblapack3 liblapack-dev libatlas-base-dev
```

The above-listed dependencies might differ or missing, depending on your system or personal use of Home Assistant.
Expand All @@ -52,38 +54,41 @@ sudo useradd -rm homeassistant

{% endif %}

### Create the virtual environment
### Create the homeassistant user

First we will create a directory for the installation of Home Assistant Core and change the owner to the `homeassistant` account.
First we will create a directory for the installation of Home Assistant Core, change the owner to the `homeassistant` account, and login as the new user.

```bash
sudo mkdir /srv/homeassistant
sudo chown homeassistant:homeassistant /srv/homeassistant
sudo -u homeassistant -H -s
```

Next up is to create and change to a virtual environment for Home Assistant Core. This will be done as the `homeassistant` account.
### Install uv

This will install the uv package and project manager.

```bash
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3 -m venv .
source bin/activate
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
```

Once you have activated the virtual environment (notice the prompt change to `(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $`) you will need to run the following command to install a required Python package.
### Create the virtual environment

Next up is to create and change to a virtual environment for Home Assistant Core. This will be done as the `homeassistant` account.

```bash
python3 -m pip install wheel
cd /srv/homeassistant
uv venv --python {{ site.installation.versions.python }} .
source bin/activate
```

Once you have installed the required Python package, it is now time to install Home Assistant Core!
Once you have activated the virtual environment (notice the prompt change to `(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $`) it is now time to install Home Assistant Core!

```bash
pip3 install homeassistant=={{ site.current_major_version }}.{{ site.current_minor_version }}.{{ site.current_patch_version }}
uv pip install homeassistant=={{ site.current_major_version }}.{{ site.current_minor_version }}.{{ site.current_patch_version }}
```

**Troubleshooting**: If you do not see the above version of Home Assistant package in your environment, make sure you have the correct Python version installed, as defined under the [Prerequisites](#prerequisites).

Start Home Assistant Core for the first time. This will complete the installation for you, automatically creating the `.homeassistant` configuration directory in the `/home/homeassistant` directory, and installing any basic dependencies.

```bash
Expand Down

0 comments on commit 7bbff57

Please sign in to comment.