mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-15 06:00:48 +00:00
fix: exclude llama-stack when installing external-providers
using `--constraint` with `uv pip install` allows us to effectively skip llama-stack if found in an external providers dependencies Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
parent
c4c64a1c8f
commit
68d7dc521e
3 changed files with 68 additions and 14 deletions
|
@ -143,8 +143,17 @@ ensure_conda_env_python310() {
|
|||
if [ -n "$external_provider_deps" ]; then
|
||||
IFS='#' read -ra parts <<<"$external_provider_deps"
|
||||
for part in "${parts[@]}"; do
|
||||
echo "$part"
|
||||
uv pip install "$part"
|
||||
echo "Installing external provider: $part"
|
||||
|
||||
# Create a temporary constraint file to exclude llama-stack
|
||||
cat > /tmp/constraints.txt << 'EOF'
|
||||
# Exclude llama-stack to avoid circular dependencies
|
||||
llama-stack==0.0.0
|
||||
EOF
|
||||
|
||||
# Install the external provider with constraints to exclude llama-stack
|
||||
uv pip install --constraint /tmp/constraints.txt "$part"
|
||||
rm -f /tmp/constraints.txt
|
||||
done
|
||||
fi
|
||||
else
|
||||
|
@ -193,7 +202,12 @@ try:
|
|||
module = importlib.import_module(f'$package_name.provider')
|
||||
spec = module.get_provider_spec()
|
||||
if hasattr(spec, 'pip_packages') and spec.pip_packages:
|
||||
print('\\n'.join(spec.pip_packages))
|
||||
# Filter out llama-stack from pip_packages to avoid circular dependency
|
||||
filtered_packages = [pkg for pkg in spec.pip_packages if not pkg.startswith('llama-stack')]
|
||||
if filtered_packages:
|
||||
print('\\n'.join(filtered_packages))
|
||||
else:
|
||||
print('No non-llama-stack dependencies found', file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f'Error getting provider spec for $package_name: {e}', file=sys.stderr)
|
||||
" | uv pip install -r -
|
||||
|
|
|
@ -199,10 +199,11 @@ if [ -n "$external_provider_deps" ]; then
|
|||
read -ra pip_args <<< "$part"
|
||||
quoted_deps=$(printf " %q" "${pip_args[@]}")
|
||||
add_to_container <<EOF
|
||||
RUN uv pip install --no-cache $quoted_deps
|
||||
EOF
|
||||
add_to_container <<EOF
|
||||
RUN python3 - <<PYTHON | uv pip install --no-cache -r -
|
||||
# Create constraint file to exclude llama-stack
|
||||
RUN echo "# Exclude llama-stack to avoid circular dependencies" > /tmp/constraints.txt && \\
|
||||
echo "llama-stack==0.0.0" >> /tmp/constraints.txt && \\
|
||||
|
||||
RUN python3 - <<PYTHON | uv pip install --no-cache --constraint /tmp/constraints.txt -r -
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
|
@ -212,10 +213,17 @@ try:
|
|||
spec = module.get_provider_spec()
|
||||
if hasattr(spec, 'pip_packages') and spec.pip_packages:
|
||||
if isinstance(spec.pip_packages, (list, tuple)):
|
||||
print('\n'.join(spec.pip_packages))
|
||||
# Filter out llama-stack from pip_packages to avoid circular dependency
|
||||
filtered_packages = [pkg for pkg in spec.pip_packages if not pkg.startswith('llama-stack')]
|
||||
if filtered_packages:
|
||||
print('\n'.join(filtered_packages))
|
||||
else:
|
||||
print('No additional dependencies needed', file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f'Error getting provider spec for {package_name}: {e}', file=sys.stderr)
|
||||
PYTHON
|
||||
|
||||
RUN rm -f /tmp/constraints.txt
|
||||
EOF
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -147,7 +147,18 @@ run() {
|
|||
IFS='#' read -ra parts <<<"$external_provider_deps"
|
||||
for part in "${parts[@]}"; do
|
||||
echo "$part"
|
||||
uv pip install "$part"
|
||||
|
||||
# Create a temporary constraint file to exclude llama-stack
|
||||
cat > /tmp/constraints.txt << 'EOF'
|
||||
# Exclude llama-stack to avoid circular dependencies
|
||||
llama-stack==0.0.0
|
||||
EOF
|
||||
|
||||
# Install the external provider with constraints to exclude llama-stack
|
||||
uv pip install --constraint /tmp/constraints.txt "$part"
|
||||
|
||||
# Clean up constraint file
|
||||
rm -f /tmp/constraints.txt
|
||||
done
|
||||
fi
|
||||
else
|
||||
|
@ -183,21 +194,42 @@ run() {
|
|||
if [ -n "$external_provider_deps" ]; then
|
||||
IFS='#' read -ra parts <<<"$external_provider_deps"
|
||||
for part in "${parts[@]}"; do
|
||||
echo "Installing external provider module: $part"
|
||||
uv pip install "$part"
|
||||
echo "Getting provider spec for module: $part and installing dependencies"
|
||||
echo "Installing external provider: $part"
|
||||
|
||||
# Create a temporary constraint file to exclude llama-stack
|
||||
cat > /tmp/constraints.txt << 'EOF'
|
||||
# Exclude llama-stack to avoid circular dependencies
|
||||
llama-stack==0.0.0
|
||||
llama-stack-client==0.0.0
|
||||
EOF
|
||||
|
||||
# Install the external provider with constraints to exclude llama-stack
|
||||
uv pip install --constraint /tmp/constraints.txt "$part"
|
||||
|
||||
echo "Getting provider spec for module: $part and installing additional dependencies"
|
||||
package_name=$(echo "$part" | sed 's/[<>=!].*//')
|
||||
|
||||
# Get additional dependencies from the provider spec (excluding llama-stack)
|
||||
python3 -c "
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
try:
|
||||
module = importlib.import_module(f'$package_name.provider')
|
||||
spec = module.get_provider_spec()
|
||||
if hasattr(spec, 'pip_packages') and spec.pip_packages:
|
||||
print('\\n'.join(spec.pip_packages))
|
||||
# Filter out llama-stack from pip_packages to avoid circular dependency
|
||||
filtered_packages = [pkg for pkg in spec.pip_packages if not pkg.startswith('llama-stack')]
|
||||
if filtered_packages:
|
||||
print('\\n'.join(filtered_packages))
|
||||
else:
|
||||
print('No additional dependencies needed', file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f'Error getting provider spec for $package_name: {e}', file=sys.stderr)
|
||||
" | uv pip install -r -
|
||||
" | uv pip install --constraint /tmp/constraints.txt -r -
|
||||
|
||||
# Clean up constraint file
|
||||
rm -f /tmp/constraints.txt
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue