Use UV to install server for speed, package locks in dev setup, workflows

It's much faster than pip, includes dependency locks via uv.lock and
comes with standard convenience utilities (e.g pipx, venv replacement)
This commit is contained in:
Debanjum
2025-06-08 19:01:01 -07:00
parent e0f363d718
commit 006b958071
8 changed files with 3788 additions and 37 deletions

View File

@@ -35,18 +35,20 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: 3.11
version: "latest"
- name: Set up Python 3.11
run: uv python install 3.11
- name: ⏬️ Install Dependencies
run: |
sudo apt update && sudo apt install -y libegl1
python -m pip install --upgrade pip
- name: ⬇️ Install Application
run: pip install --no-cache-dir --upgrade .[dev]
run: uv sync --all-extras
- name: 🌡️ Validate Application
run: pre-commit run --hook-stage manual --all

View File

@@ -34,13 +34,16 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: '3.11.12'
version: "latest"
- name: Set up Python 3.11
run: uv python install 3.11
- name: ⬇️ Install Server
run: python -m pip install --upgrade pip && pip install --upgrade .
run: uv sync --all-extras
- name: ⬇️ Install Web Client
run: |
@@ -51,7 +54,7 @@ jobs:
- name: 📂 Copy Generated Files
run: |
mkdir -p src/khoj/interface/compiled
cp -r /opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/site-packages/khoj/interface/compiled/* src/khoj/interface/compiled/
cp -r $(uv python find-python 3.11)/lib/python3.11/site-packages/khoj/interface/compiled/* src/khoj/interface/compiled/
- name: ⚙️ Build Python Package
run: |
@@ -61,13 +64,13 @@ jobs:
rm -rf dist
# Build PyPI Package
pipx run build
uv build
- name: 🌡️ Validate Python Package
run: |
# Validate PyPi Package
pipx run check-wheel-contents dist/*.whl --ignore W004
pipx run twine check dist/*
uv tool run check-wheel-contents dist/*.whl --ignore W004
uv tool run twine check dist/*
- name: ⏫ Upload Python Package Artifacts
uses: actions/upload-artifact@v4

View File

@@ -106,10 +106,13 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: '3.10'
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Get App Version
id: hatch
@@ -127,16 +130,14 @@ jobs:
DEBIAN_FRONTEND: noninteractive
run: |
# install dependencies
sudo apt update && sudo apt install -y git python3-pip libegl1 sqlite3 libsqlite3-dev libsqlite3-0 ffmpeg libsm6 libxext6
# upgrade pip
python -m ensurepip --upgrade && python -m pip install --upgrade pip
sudo apt update && sudo apt install -y git libegl1 sqlite3 libsqlite3-dev libsqlite3-0 ffmpeg libsm6 libxext6
# install terrarium for code sandbox
git clone https://github.com/khoj-ai/terrarium.git && cd terrarium && npm install --legacy-peer-deps && mkdir pyodide_cache
- name: ⬇️ Install Application
run: |
sed -i 's/dynamic = \["version"\]/version = "${{ steps.hatch.outputs.version }}"/' pyproject.toml
pip install --upgrade .[dev]
uv sync --all-extras
- name: 📝 Run Eval
env:

View File

@@ -54,10 +54,13 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python_version }}
version: "latest"
- name: Set up Python ${{ matrix.python_version }}
run: uv python install ${{ matrix.python_version }}
- name: ⏬️ Install Dependencies
env:
@@ -71,17 +74,11 @@ jobs:
run : |
apt install -y postgresql postgresql-client && apt install -y postgresql-server-dev-16
- name: ⬇️ Install pip
run: |
apt install -y python3-pip
python3 -m ensurepip --upgrade
python3 -m pip install --upgrade pip
- name: ⬇️ Install Application
env:
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu https://abetlen.github.io/llama-cpp-python/whl/cpu"
CUDA_VISIBLE_DEVICES: ""
run: sed -i 's/dynamic = \["version"\]/version = "0.0.0"/' pyproject.toml && pip install --break-system-packages --upgrade .[dev]
run: sed -i 's/dynamic = \["version"\]/version = "0.0.0"/' pyproject.toml && uv sync --all-extras
- name: 🧪 Test Application
env: