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

<img width="1004" alt="image"
src="https://github.com/user-attachments/assets/1f9be409-5313-4926-b078-74e141cf29eb"
/>

## 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
<img width="621" alt="image"
src="https://github.com/user-attachments/assets/ae93bc3d-e05a-44b9-bb21-fb88f29969b8"
/>
This commit is contained in:
Xi Yan 2025-02-19 22:21:16 -08:00 committed by GitHub
parent 2b752df79a
commit 61f43b8677
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -74,10 +74,15 @@ run() {
local pip_dependencies="$2" local pip_dependencies="$2"
local special_pip_deps="$3" 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" echo "Using virtual environment $env_name"
uv venv "$env_name" uv venv "$env_name"
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$env_name/bin/activate" source "$env_name/bin/activate"
fi
if [ -n "$TEST_PYPI_VERSION" ]; then if [ -n "$TEST_PYPI_VERSION" ]; then
# these packages are damaged in test-pypi, so install them first # these packages are damaged in test-pypi, so install them first
uv pip install fastapi libcst uv pip install fastapi libcst