From a8ddfaddf0aaec8b9b98e4544f37f81df35bea97 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 4 Jun 2025 09:12:36 +0200 Subject: [PATCH] more uv migrations --- install/documenso-install.sh | 10 ++++++---- install/esphome-install.sh | 23 ++++++++++------------- install/grist-install.sh | 25 +++++++++++++------------ install/homeassistant-install.sh | 17 ++--------------- install/homer-install.sh | 7 +++---- install/immich-install.sh | 28 ++++++++++++++-------------- 6 files changed, 48 insertions(+), 62 deletions(-) diff --git a/install/documenso-install.sh b/install/documenso-install.sh index 861f3f40e..142765c85 100644 --- a/install/documenso-install.sh +++ b/install/documenso-install.sh @@ -23,13 +23,12 @@ $STD apt-get install -y \ libc6 \ make \ cmake \ - jq \ - python3 \ - python3-bcrypt + jq msg_ok "Installed Dependencies" NODE_VERSION="22" NODE_MODULE="turbo@1.9.3" install_node_and_modules PG_VERSION="16" install_postgresql +PYTHON_VERSION="3.12" setup_uv msg_info "Setting up PostgreSQL" DB_NAME="documenso_db" @@ -55,6 +54,9 @@ curl -fsSL "https://github.com/documenso/documenso/archive/refs/tags/v${RELEASE} $STD unzip v${RELEASE}.zip mv documenso-${RELEASE} /opt/documenso cd /opt/documenso +$STD uv venv /opt/documenso/.venv +source /opt/documenso/.venv/bin/activate +$STD /opt/documenso/.venv/bin/uv pip install bcrypt mv .env.example /opt/documenso/.env sed -i \ -e "s|^NEXTAUTH_SECRET=.*|NEXTAUTH_SECRET='$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)'|" \ @@ -78,7 +80,7 @@ echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Installed Documenso" msg_info "Create User" -PASSWORD_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw(b'helper-scripts', bcrypt.gensalt(rounds=12)).decode())") +PASSWORD_HASH=$(/opt/documenso/.venv/bin/python3 -c "import bcrypt; print(bcrypt.hashpw(b'helper-scripts', bcrypt.gensalt(rounds=12)).decode())") $STD sudo -u postgres psql -d documenso_db -c "INSERT INTO \"User\" (name, email, \"emailVerified\", password, \"identityProvider\", roles, \"createdAt\", \"lastSignedIn\", \"updatedAt\", \"customerId\") VALUES ('helper-scripts', 'helper-scripts@local.com', '2025-01-20 17:14:45.058', '$PASSWORD_HASH', 'DOCUMENSO', ARRAY['USER', 'ADMIN']::\"Role\"[], '2025-01-20 16:04:05.543', '2025-01-20 16:14:55.249', '2025-01-20 16:14:55.25', NULL) RETURNING id;" $STD npm run prisma:migrate-deploy msg_ok "User created" diff --git a/install/esphome-install.sh b/install/esphome-install.sh index 37e2d71d0..2ceaaf407 100644 --- a/install/esphome-install.sh +++ b/install/esphome-install.sh @@ -17,34 +17,31 @@ msg_info "Installing Dependencies" $STD apt-get install -y git msg_ok "Installed Dependencies" -msg_info "Setup Python3" -$STD apt-get install -y \ - python3 \ - python3-dev \ - python3-pip \ - python3-venv -rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED -msg_ok "Setup Python3" +PYTHON_VERSION="3.12" setup_uv -msg_info "Installing ESPHome" -mkdir /root/config -$STD pip install esphome tornado esptool -msg_ok "Installed ESPHome" +msg_info "Setting up Virtual Environment" +mkdir -p /opt/esphome +$STD uv venv /opt/esphome/.venv +source /opt/esphome/.venv/bin/activate +$STD /opt/esphome/.venv/bin/uv pip install esphome tornado esptool +msg_ok "Setup and Installed ESPHome" msg_info "Creating Service" +mkdir -p /root/config cat </etc/systemd/system/esphomeDashboard.service [Unit] Description=ESPHome Dashboard After=network.target [Service] -ExecStart=/usr/local/bin/esphome dashboard /root/config/ +ExecStart=/opt/esphome/.venv/bin/esphome dashboard /root/config/ Restart=always User=root [Install] WantedBy=multi-user.target EOF + systemctl enable -q --now esphomeDashboard msg_ok "Created Service" diff --git a/install/grist-install.sh b/install/grist-install.sh index 9649accf4..9c239e84a 100644 --- a/install/grist-install.sh +++ b/install/grist-install.sh @@ -14,12 +14,10 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y \ - make \ - ca-certificates \ - python3.11-venv +$STD apt-get install -y make ca-certificates msg_ok "Installed Dependencies" +PYTHON_VERSION="3.12" setup_uv NODE_VERSION="22" NODE_MODULE="yarn@latest" install_node_and_modules msg_info "Installing Grist" @@ -28,20 +26,22 @@ export CYPRESS_INSTALL_BINARY=0 export NODE_OPTIONS="--max-old-space-size=2048" cd /opt curl -fsSL "https://github.com/gristlabs/grist-core/archive/refs/tags/v${RELEASE}.zip" -o "v${RELEASE}.zip" -$STD unzip v$RELEASE.zip -mv grist-core-${RELEASE} grist -cd grist +$STD unzip "v${RELEASE}.zip" +mv "grist-core-${RELEASE}" /opt/grist +cd /opt/grist +$STD uv venv /opt/grist/sandbox_venv3 +$STD /opt/grist/sandbox_venv3/bin/uv pip install -r sandbox/requirements.txt $STD yarn install $STD yarn run build:prod -$STD yarn run install:python +ln -sf /opt/grist/sandbox_venv3/bin/python3 /opt/grist/sandbox_venv3/bin/python cat </opt/grist/.env NODE_ENV=production GRIST_HOST=0.0.0.0 EOF -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +echo "${RELEASE}" >/opt/grist_version.txt msg_ok "Installed Grist" -msg_info "Create Service" +msg_info "Creating Service" cat </etc/systemd/system/grist.service [Unit] Description=Grist @@ -49,9 +49,10 @@ After=network.target [Service] Type=exec -WorkingDirectory=/opt/grist +WorkingDirectory=/opt/grist ExecStart=/usr/bin/yarn run start:prod EnvironmentFile=-/opt/grist/.env +Restart=always [Install] WantedBy=multi-user.target @@ -64,7 +65,7 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf /opt/v${RELEASE}.zip +rm -rf "/opt/v${RELEASE}.zip" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned" diff --git a/install/homeassistant-install.sh b/install/homeassistant-install.sh index e041e72fc..6111c033d 100644 --- a/install/homeassistant-install.sh +++ b/install/homeassistant-install.sh @@ -13,19 +13,6 @@ setting_up_container network_check update_os -msg_info "Setup Python3" -$STD apt-get install -y \ - python3 \ - python3-dev \ - python3-pip \ - python3-venv -rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED -msg_ok "Setup Python3" - -msg_info "Installing runlike" -$STD pip install runlike -msg_ok "Installed runlike" - get_latest_release() { curl -fsSL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 } @@ -36,8 +23,8 @@ PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") msg_info "Installing Docker $DOCKER_LATEST_VERSION" DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -echo -e '{\n "log-driver": "journald"\n}' >/etc/docker/daemon.json +mkdir -p $(dirname "$DOCKER_CONFIG_PATH") +echo -e '{\n "log-driver": "journald"\n}' >"$DOCKER_CONFIG_PATH" $STD sh <(curl -fsSL https://get.docker.com) msg_ok "Installed Docker $DOCKER_LATEST_VERSION" diff --git a/install/homer-install.sh b/install/homer-install.sh index 525dd3a4f..3c0b6ab07 100644 --- a/install/homer-install.sh +++ b/install/homer-install.sh @@ -13,12 +13,11 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" -$STD apt-get install -y pip -msg_ok "Installed Dependencies" +PYTHON_VERSION="3.12" setup_uv msg_info "Installing Homer" mkdir -p /opt/homer +$STD uv venv /opt/homer/.venv cd /opt/homer curl -fsSL "https://github.com/bastienwirtz/homer/releases/latest/download/homer.zip" -o "homer.zip" $STD unzip homer.zip @@ -34,7 +33,7 @@ After=network-online.target [Service] Type=simple WorkingDirectory=/opt/homer -ExecStart=python3 -m http.server 8010 +ExecStart=/opt/homer/.venv/bin/python3 -m http.server 8010 [Install] WantedBy=multi-user.target EOF diff --git a/install/immich-install.sh b/install/immich-install.sh index ae766de05..f85d05a86 100644 --- a/install/immich-install.sh +++ b/install/immich-install.sh @@ -13,6 +13,8 @@ setting_up_container network_check update_os +PYTHON_VERSION="3.12" setup_uv + msg_info "Configuring apt and installing dependencies" echo "deb http://deb.debian.org/debian testing main contrib" >/etc/apt/sources.list.d/immich.list cat </etc/apt/preferences.d/immich @@ -27,8 +29,6 @@ $STD apt-get install --no-install-recommends -y \ redis \ autoconf \ build-essential \ - python3-venv \ - python3-dev \ cmake \ jq \ libbrotli-dev \ @@ -304,25 +304,25 @@ cp LICENSE "$APP_DIR" msg_ok "Installed Immich Web Components" cd "$SRC_DIR"/machine-learning -$STD python3 -m venv "$ML_DIR/ml-venv" +$STD uv venv "$ML_DIR/.venv" +$ML_DIR/.venv/bin/uv pip install --upgrade uv +$ML_DIR/.venv/bin/uv sync --no-cache +cd "$SRC_DIR"/machine-learning +$STD uv venv "$ML_DIR/.venv" +$ML_DIR/.venv/bin/uv pip install --upgrade uv + if [[ -f ~/.openvino ]]; then msg_info "Installing HW-accelerated machine-learning" - ( - source "$ML_DIR"/ml-venv/bin/activate - $STD pip3 install uv - uv -q sync --extra openvino --no-cache --active - ) - patchelf --clear-execstack "$ML_DIR"/ml-venv/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-311-x86_64-linux-gnu.so + $STD "$ML_DIR/.venv/bin/uv" sync --no-cache --extra openvino + patchelf --clear-execstack "$ML_DIR/.venv/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-312-x86_64-linux-gnu.so" msg_ok "Installed HW-accelerated machine-learning" + else msg_info "Installing machine-learning" - ( - source "$ML_DIR"/ml-venv/bin/activate - $STD pip3 install uv - uv -q sync --extra cpu --no-cache --active - ) + $STD "$ML_DIR/.venv/bin/uv" sync --no-cache --extra cpu msg_ok "Installed machine-learning" fi + cd "$SRC_DIR" cp -a machine-learning/{ann,immich_ml} "$ML_DIR" if [[ -f ~/.openvino ]]; then