install.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env bash
  2. # Set error handling
  3. set -o errexit
  4. set -o nounset
  5. set -o pipefail
  6. # Get the root directory and third_party directory
  7. ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
  8. # Include the common functions
  9. source "${ROOT_DIR}/hack/lib/init.sh"
  10. function download_deps() {
  11. if ! command -v uv &> /dev/null; then
  12. pip install uv
  13. fi
  14. # uv sync --all-extras to install all dependencies
  15. uv sync --locked
  16. if [[ "${DEPS_ONLY:-false}" == "false" ]]; then
  17. uv pip install pre-commit==3.7.1
  18. uv run pre-commit install
  19. fi
  20. }
  21. # Update community backends
  22. function make_community_backends() {
  23. local tmp_dir
  24. tmp_dir=$(mktemp -d -t gpustack-community-backends.XXXXXX)
  25. # shellcheck disable=SC2064
  26. trap "rm -rf \"${tmp_dir}\"" EXIT
  27. local target_dir="${ROOT_DIR}/gpustack/assets/"
  28. gpustack::log::info "pulling community backends"
  29. # Clone the repository
  30. git clone https://github.com/gpustack/community-inference-backends "${tmp_dir}"
  31. # Build the community backends
  32. (
  33. cd "${tmp_dir}"
  34. if [[ "${UV_SYSTEM_PYTHON:-}" == "1" ]]; then
  35. # In Docker build, use system Python directly
  36. uv pip install PyYAML && uv run make
  37. else
  38. # For local development, use virtual environment
  39. uv venv && source .venv/bin/activate && uv pip install PyYAML && uv run make
  40. fi
  41. )
  42. # Create target directory and copy the yaml file
  43. mkdir -p "${target_dir}"
  44. cp "${tmp_dir}/dist/community-inference-backends.yaml" "${target_dir}/community-inference-backends.yaml"
  45. gpustack::log::info "community backends updated successfully"
  46. }
  47. #
  48. # main
  49. #
  50. gpustack::log::info "+++ DEPENDENCIES +++"
  51. download_deps
  52. make_community_backends
  53. gpustack::log::info "--- DEPENDENCIES ---"