From 84e93cd7d0f1908abcdfc72fed3ff97c4fee2715 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 7 Jun 2025 02:54:48 -0400 Subject: [PATCH] Immich UV test (#5032) - Simplifies UV use in Immich install & update - Uses Python 3.11 (No official support for 3.12 yet) - Restores python3-dev package --- ct/immich.sh | 20 ++++++++------------ install/immich-install.sh | 21 ++++++++------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/ct/immich.sh b/ct/immich.sh index 1a38bbd9b..323683fac 100644 --- a/ct/immich.sh +++ b/ct/immich.sh @@ -27,6 +27,9 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + + setup_uv + STAGING_DIR=/opt/staging BASE_DIR=${STAGING_DIR}/base-images SOURCE_DIR=${STAGING_DIR}/image-source @@ -251,23 +254,16 @@ EOF msg_ok "Updated ${APP} web and microservices" cd "$SRC_DIR"/machine-learning - $STD python3 -m venv "$ML_DIR"/ml-venv + export VIRTUAL_ENV="${ML_DIR}/ml-venv" + $STD uv venv "$VIRTUAL_ENV" if [[ -f ~/.openvino ]]; then msg_info "Updating HW-accelerated machine-learning" - ( - source "$ML_DIR"/ml-venv/bin/activate - $STD pip3 install -U 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 + uv -q sync --extra openvino --no-cache --active + patchelf --clear-execstack "${VIRTUAL_ENV}/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-311-x86_64-linux-gnu.so" msg_ok "Updated HW-accelerated machine-learning" else msg_info "Updating machine-learning" - ( - source "$ML_DIR"/ml-venv/bin/activate - $STD pip3 install -U uv - uv -q sync --extra cpu --no-cache --active - ) + uv -q sync --extra cpu --no-cache --active msg_ok "Updated machine-learning" fi cd "$SRC_DIR" diff --git a/install/immich-install.sh b/install/immich-install.sh index f85d05a86..2ccee7f0c 100644 --- a/install/immich-install.sh +++ b/install/immich-install.sh @@ -13,7 +13,7 @@ setting_up_container network_check update_os -PYTHON_VERSION="3.12" setup_uv +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 @@ -29,6 +29,7 @@ $STD apt-get install --no-install-recommends -y \ redis \ autoconf \ build-essential \ + python3-dev \ cmake \ jq \ libbrotli-dev \ @@ -304,22 +305,16 @@ cp LICENSE "$APP_DIR" msg_ok "Installed Immich Web Components" cd "$SRC_DIR"/machine-learning -$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 - +export VIRTUAL_ENV="${ML_DIR}/ml-venv" +$STD uv venv "$VIRTUAL_ENV" if [[ -f ~/.openvino ]]; then msg_info "Installing HW-accelerated machine-learning" - $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" + uv -q sync --no-cache --extra openvino --active + patchelf --clear-execstack "${VIRTUAL_ENV}/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-311-x86_64-linux-gnu.so" msg_ok "Installed HW-accelerated machine-learning" - else msg_info "Installing machine-learning" - $STD "$ML_DIR/.venv/bin/uv" sync --no-cache --extra cpu + uv -q sync --no-cache --extra cpu --active msg_ok "Installed machine-learning" fi @@ -396,7 +391,7 @@ set -a . ${INSTALL_DIR}/.env set +a -python -m immich_ml +python3 -m immich_ml EOF chmod +x "$ML_DIR"/ml_start.sh cat </etc/systemd/system/"${APPLICATION}"-web.service