Use uv pip install instead of pip install (#921)

## What does this PR do? 

See issue: #747 -- `uv` is just plain better. This PR does the bare
minimum of replacing `pip install` by `uv pip install` and ensuring `uv`
exists in the environment.

## Test Plan 

First: create new conda, `uv pip install -e .` on `llama-stack` -- all
is good.
Next: run `llama stack build --template together` followed by `llama
stack run together` -- all good
Next: run `llama stack build --template together --image-name yoyo`
followed by `llama stack run together --image-name yoyo` -- all good
Next: fresh conda and `uv pip install -e .` and `llama stack build
--template together --image-type venv` -- all good.

Docker: `llama stack build --template together --image-type container`
works!
This commit is contained in:
Ashwin Bharambe 2025-01-31 22:29:41 -08:00 committed by GitHub
parent c6d9ff2054
commit 5b1e69e58e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 85 additions and 64 deletions

View file

@ -78,10 +78,12 @@ ensure_conda_env_python310() {
eval "$(conda shell.bash hook)"
conda deactivate && conda activate "${env_name}"
$CONDA_PREFIX/bin/pip install uv
if [ -n "$TEST_PYPI_VERSION" ]; then
# these packages are damaged in test-pypi, so install them first
$CONDA_PREFIX/bin/pip install fastapi libcst
$CONDA_PREFIX/bin/pip install --extra-index-url https://test.pypi.org/simple/ \
uv pip install fastapi libcst
uv pip install --extra-index-url https://test.pypi.org/simple/ \
llama-models==$TEST_PYPI_VERSION \
llama-stack-client==$TEST_PYPI_VERSION \
llama-stack==$TEST_PYPI_VERSION \
@ -90,7 +92,7 @@ ensure_conda_env_python310() {
IFS='#' read -ra parts <<<"$special_pip_deps"
for part in "${parts[@]}"; do
echo "$part"
$CONDA_PREFIX/bin/pip install $part
uv pip install $part
done
fi
else
@ -102,7 +104,7 @@ ensure_conda_env_python310() {
fi
printf "Installing from LLAMA_STACK_DIR: $LLAMA_STACK_DIR\n"
$CONDA_PREFIX/bin/pip install --no-cache-dir -e "$LLAMA_STACK_DIR"
uv pip install --no-cache-dir -e "$LLAMA_STACK_DIR"
else
PYPI_VERSION="${PYPI_VERSION:-}"
if [ -n "$PYPI_VERSION" ]; then
@ -110,7 +112,7 @@ ensure_conda_env_python310() {
else
SPEC_VERSION="llama-stack"
fi
$CONDA_PREFIX/bin/pip install --no-cache-dir $SPEC_VERSION
uv pip install --no-cache-dir $SPEC_VERSION
fi
if [ -n "$LLAMA_MODELS_DIR" ]; then
@ -120,18 +122,18 @@ ensure_conda_env_python310() {
fi
printf "Installing from LLAMA_MODELS_DIR: $LLAMA_MODELS_DIR\n"
$CONDA_PREFIX/bin/pip uninstall -y llama-models
$CONDA_PREFIX/bin/pip install --no-cache-dir -e "$LLAMA_MODELS_DIR"
uv pip uninstall -y llama-models
uv pip install --no-cache-dir -e "$LLAMA_MODELS_DIR"
fi
# Install pip dependencies
printf "Installing pip dependencies\n"
$CONDA_PREFIX/bin/pip install $pip_dependencies
uv pip install $pip_dependencies
if [ -n "$special_pip_deps" ]; then
IFS='#' read -ra parts <<<"$special_pip_deps"
for part in "${parts[@]}"; do
echo "$part"
$CONDA_PREFIX/bin/pip install $part
uv pip install $part
done
fi
fi