From 61f43b86773030af4a244431f2ba13c17d8273e9 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Wed, 19 Feb 2025 22:21:16 -0800 Subject: [PATCH] fix: llama stack build use UV_SYSTEM_PYTHON to install dependencies to system environment (#1163) # What does this PR do? - resolves issue: #1159 - Root cause: https://github.com/meta-llama/llama-stack/pull/980 forces `build_venv.sh` to install in a venv environment, which do not work on Colab notebook environment image ## This PR Use `UV_SYSTEM_PYTHON` to make sure dependencies are installed in current system environment. Which will be used in the Colab environment. ``` UV_SYSTEM_PYTHON=1 llama stack build --template together --image-type venv ``` ## Test Plan - Works in Colab environment image --- llama_stack/distribution/build_venv.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/llama_stack/distribution/build_venv.sh b/llama_stack/distribution/build_venv.sh index 0b0bffcfda..00e70afe7e 100755 --- a/llama_stack/distribution/build_venv.sh +++ b/llama_stack/distribution/build_venv.sh @@ -73,11 +73,16 @@ run() { local env_name="$1" local pip_dependencies="$2" local special_pip_deps="$3" + + if [ -n "${UV_SYSTEM_PYTHON:-}" ]; then + echo "Installing dependencies in system Python environment" + else + echo "Using virtual environment $env_name" + uv venv "$env_name" + # shellcheck source=/dev/null + source "$env_name/bin/activate" + fi - echo "Using virtual environment $env_name" - uv venv "$env_name" - # shellcheck source=/dev/null - source "$env_name/bin/activate" if [ -n "$TEST_PYPI_VERSION" ]; then # these packages are damaged in test-pypi, so install them first uv pip install fastapi libcst