Skip to content

Use pre-compiled versions of Python from uv #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
10 changes: 5 additions & 5 deletions files/python/install-packages.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
set -eux -o pipefail

# Load pyenv python into path
# Ensure correct Python is being used
source ~/.profile

pip install --upgrade pip setuptools wheel
uv pip install --upgrade pip setuptools wheel

# Install base python packages
pip install -r /tmp/packer/python/requirements.txt
uv pip install -r /tmp/packer/python/requirements.txt

# Install additional useful libraries for the competitors
pip install -r /tmp/packer/python/libraries.txt
uv pip install -r /tmp/packer/python/libraries.txt

# Make the entrypoint folder
mkdir -p ~/.local/bin

# Record the installed packages
pip freeze > py-packages.txt
uv pip freeze > py-packages.txt
23 changes: 0 additions & 23 deletions files/python/install-pyenv.sh

This file was deleted.

23 changes: 23 additions & 0 deletions files/python/install-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -eux -o pipefail

python_version="3.11.5"

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Source environment for access to uv
source $HOME/.cargo/env

# Install Python
uv python install $python_version

# Create virtualenv
uv venv /opt/venv

# Use uv Python by default
cat << "EOF" >> ~/.profile
export PATH=/opt/venv/bin/:${PATH}
EOF

source ~/.profile
13 changes: 5 additions & 8 deletions scripts/040-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ apt-get -y install \
cmake \
build-essential

# Package install for pyenv
apt-get -y install \
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev libgdbm-dev lzma lzma-dev \
tcl-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev wget curl \
make build-essential openssl
# Create directory for virtualenv
mkdir /opt/venv
chown $user /opt/venv

chmod +x /tmp/packer/python/install-pyenv.sh /tmp/packer/python/install-packages.sh
su - $user -c /tmp/packer/python/install-pyenv.sh
chmod +x /tmp/packer/python/install-python.sh /tmp/packer/python/install-packages.sh
su - $user -c /tmp/packer/python/install-python.sh
su - $user -c /tmp/packer/python/install-packages.sh
14 changes: 5 additions & 9 deletions scripts/060-astoria.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ mv /tmp/packer/astoria/astoria/* /usr/lib/systemd/system/
chmod 644 /usr/lib/systemd/system/ast*d.service /usr/lib/systemd/system/astoria-udiskie.service
systemctl enable astdiskd.service astmetad.service astoria-udiskie.service astprocd.service astwifid.service

# Make pyenv python entrypoint globally available
home="/home/$(id -un 1000)"
if [ -d $home/.pyenv ]; then
python_bin_path="$(echo $home/.pyenv/versions/*/bin)"
ln -s $python_bin_path/astdiskd /usr/local/bin/astdiskd
ln -s $python_bin_path/astmetad /usr/local/bin/astmetad
ln -s $python_bin_path/astprocd /usr/local/bin/astprocd
ln -s $python_bin_path/astwifid /usr/local/bin/astwifid
fi
# Make entrypoints globally available
ln -s /opt/venv/bin/astdiskd /usr/local/bin/astdiskd
ln -s /opt/venv/bin/astmetad /usr/local/bin/astmetad
ln -s /opt/venv/bin/astprocd /usr/local/bin/astprocd
ln -s /opt/venv/bin/astwifid /usr/local/bin/astwifid
9 changes: 3 additions & 6 deletions scripts/080-kch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ mv /tmp/packer/kchd/{kchd.service,boot_40.service} /usr/lib/systemd/system/
chmod 644 /usr/lib/systemd/system/{kchd.service,boot_40.service}
systemctl enable kchd.service boot_40.service

# Make pyenv python entrypoint globally available
home=/home/$(id -un 1000)
if [ -d $home/.pyenv ]; then
python_bin_path="$(echo $home/.pyenv/versions/*/bin/)"
ln -s $python_bin_path/kchd /usr/local/bin/kchd
fi

# Make entrypoint globally available
ln -s /opt/venv/bin/kchd /usr/local/bin/kchd
Loading