PYTHON_VERSION="3.12" setup_uv

This commit is contained in:
CanbiZ 2025-06-03 16:38:41 +02:00
parent 44c98dda24
commit ddb01f602a
5 changed files with 25 additions and 20 deletions

View File

@ -18,12 +18,10 @@ msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt-get install -y \
gdal-bin \ gdal-bin \
libgdal-dev \ libgdal-dev \
git \ git
python3-venv \
python3-pip
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_uv PYTHON_VERSION="3.12" setup_uv
NODE_VERSION="22" NODE_MODULE="pnpm@latest" install_node_and_modules NODE_VERSION="22" NODE_MODULE="pnpm@latest" install_node_and_modules
PG_VERSION="16" PG_MODULES="postgis" install_postgresql PG_VERSION="16" PG_MODULES="postgis" install_postgresql
@ -80,13 +78,12 @@ DISABLE_REGISTRATION=False
EOF EOF
cd /opt/adventurelog/backend/server cd /opt/adventurelog/backend/server
mkdir -p /opt/adventurelog/backend/server/media mkdir -p /opt/adventurelog/backend/server/media
$STD uv venv /opt/adventurelog/backend/server/venv $STD uv venv --python $UV_PYTHON_VERSION /opt/adventurelog/backend/server/venv
source /opt/adventurelog/backend/server/venv/bin/activate
$STD uv pip install --upgrade pip $STD uv pip install --upgrade pip
$STD uv pip install -r requirements.txt $STD uv pip install -r requirements.txt
$STD uv python3 manage.py collectstatic --noinput $STD uv run python manage.py collectstatic --noinput
$STD uv python3 manage.py migrate $STD uv run python manage.py migrate
$STD uv python3 manage.py download-countries $STD uv run python manage.py download-countries
cat <<EOF >/opt/adventurelog/frontend/.env cat <<EOF >/opt/adventurelog/frontend/.env
PUBLIC_SERVER_URL=http://$LOCAL_IP:8000 PUBLIC_SERVER_URL=http://$LOCAL_IP:8000
BODY_SIZE_LIMIT=Infinity BODY_SIZE_LIMIT=Infinity
@ -99,7 +96,7 @@ echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed AdventureLog" msg_ok "Installed AdventureLog"
msg_info "Setting up Django Admin" msg_info "Setting up Django Admin"
$STD uv python3 /opt/adventurelog/backend/server/manage.py shell <<EOF $STD uv run python /opt/adventurelog/backend/server/manage.py shell <<EOF
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
UserModel = get_user_model() UserModel = get_user_model()
user = UserModel.objects.create_user('$DJANGO_ADMIN_USER', password='$DJANGO_ADMIN_PASS') user = UserModel.objects.create_user('$DJANGO_ADMIN_USER', password='$DJANGO_ADMIN_PASS')
@ -123,7 +120,7 @@ After=network.target postgresql.service
[Service] [Service]
WorkingDirectory=/opt/adventurelog/backend/server WorkingDirectory=/opt/adventurelog/backend/server
ExecStart=python3 manage.py runserver 0.0.0.0:8000 ExecStart=/opt/adventurelog/backend/server/venv/bin/python manage.py runserver 0.0.0.0:8000
Restart=always Restart=always
EnvironmentFile=/opt/adventurelog/backend/server/.env EnvironmentFile=/opt/adventurelog/backend/server/.env

View File

@ -19,12 +19,7 @@ $STD apt-get install -y git \
build-essential build-essential
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_uv PYTHON_VERSION="3.12" setup_uv
UV_PYTHON_VERSION="3.12"
msg_info "Installing Python $UV_PYTHON_VERSION via uv"
$STD uv python install $UV_PYTHON_VERSION
msg_ok "Installed Python $UV_PYTHON_VERSION"
msg_info "Creating user octoprint" msg_info "Creating user octoprint"
useradd -m -s /bin/bash -p $(openssl passwd -1 octoprint) octoprint useradd -m -s /bin/bash -p $(openssl passwd -1 octoprint) octoprint

View File

@ -19,7 +19,7 @@ $STD apt-get install -y \
p7zip-full p7zip-full
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_uv setup_uv PYTHON_VERSION="3.12"
msg_info "Setup Unrar" msg_info "Setup Unrar"
cat <<EOF >/etc/apt/sources.list.d/non-free.list cat <<EOF >/etc/apt/sources.list.d/non-free.list

View File

@ -20,8 +20,7 @@ $STD apt-get install -y \
libapache2-mod-wsgi-py3 libapache2-mod-wsgi-py3
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_uv PYTHON_VERSION="3.12" setup_uv
$STD uv python install
NODE_VERSION="22" NODE_MODULE="yarn@latest,sass" install_node_and_modules NODE_VERSION="22" NODE_MODULE="yarn@latest,sass" install_node_and_modules
msg_info "Setting up wger" msg_info "Setting up wger"

View File

@ -1065,6 +1065,20 @@ function setup_uv() {
# set path # set path
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
msg_ok "uv installed/updated to $LATEST_VERSION" msg_ok "uv installed/updated to $LATEST_VERSION"
if [[ -n "$PYTHON_VERSION" ]]; then
$STD msg_info "Ensuring Python $PYTHON_VERSION is available via uv..."
if ! uv python list | grep -q "cpython-${PYTHON_VERSION}-linux"; then
msg_error "Python version $PYTHON_VERSION not available via uv"
return 1
fi
if ! uv python list | grep -q "cpython-${PYTHON_VERSION}-linux.*.local/share/uv/python"; then
$STD uv python install "$PYTHON_VERSION"
msg_ok "Installed Python $PYTHON_VERSION via uv"
else
$STD msg_ok "Python $PYTHON_VERSION already installed via uv"
fi
fi
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------