Skip to content

Commit a3b1b23

Browse files
authored
Switch to uv in build, test, and CI (#494)
## Summary <!-- Include a short paragraph of the changes introduced in this PR. If this PR requires additional context or rationale, explain why the changes are necessary. --> Switch from PDM to using `uv` in development, testing, and building. See #484 and #483 for why. ## Test Plan - Workflows should pass (PR jobs are sufficient to test changes) - Container should build - Manually check that container contains locked versions (and no dev dependencies) - New pre-commits should run and update `uv.lock` as well as `pylock.toml` when appropriate - `./script/update_pylock.sh` should now update the pylock based on `uv` (can test with `tox -e lock`) ## Related Issues <!-- Link any relevant issues that this PR addresses. --> - Resolves #483 --- - [x] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [ ] Includes AI-assisted code completion - [ ] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`)
2 parents 3abb712 + fa04600 commit a3b1b23

File tree

13 files changed

+7898
-2229
lines changed

13 files changed

+7898
-2229
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Setup Python and uv'
2+
description: 'Configures a Python version and uv'
3+
inputs:
4+
python-version:
5+
type: string
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- uses: actions/setup-python@v6
11+
with:
12+
python-version: ${{ inputs.python-version }}
13+
- name: Setup Python with UV
14+
uses: astral-sh/setup-uv@v7
15+
with:
16+
python-version: ${{ inputs.python-version }}
17+
enable-cache: "true"

.github/actions/run-tox/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Run tox with environment'
2-
description: 'Runs tox with pdm as the package manager'
2+
description: 'Runs tox with uv as the package manager'
33
inputs:
44
python-version:
55
type: string
@@ -13,8 +13,8 @@ inputs:
1313
runs:
1414
using: "composite"
1515
steps:
16-
- name: Setup Python with PDM
17-
uses: pdm-project/setup-pdm@v4
16+
- name: Setup Python with UV
17+
uses: ./.github/actions/python-uv
1818
with:
1919
python-version: ${{ inputs.python-version }}
2020
- name: Install system dependencies
@@ -23,11 +23,11 @@ runs:
2323
shell: bash
2424
- name: Install dependencies
2525
run: |
26-
pip install tox tox-pdm
26+
uv pip install --system tox tox-uv
2727
shell: bash
2828
- name: Run tox
2929
run: |
30-
tox run -e "${{ inputs.tox-env }}" -- ${{ inputs.tox-args }} || ret=$?
30+
tox run --runner uv-venv-lock-runner -e "${{ inputs.tox-env }}" -- ${{ inputs.tox-args }} || ret=$?
3131
# errno 5 means all tests were filtered out, ignore
3232
[[ "${ret:=0}" -eq 5 ]] && exit 0; exit $ret
3333
shell: bash

.github/workflows/nightly.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929
uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 0
32-
- name: Set up Python
33-
uses: pdm-project/setup-pdm@v4
32+
- name: Setup Python with UV
33+
uses: ./.github/actions/python-uv
3434
with:
3535
python-version: ${{ matrix.python }}
3636
- name: Install dependencies
3737
run: |
38-
pip install tox tox-pdm
38+
uv pip install --system tox tox-pdm
3939
- name: Build the package
4040
run: |
4141
export GUIDELLM_BUILD_TYPE=nightly

.github/workflows/release-candidate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ jobs:
2828
uses: actions/checkout@v4
2929
with:
3030
fetch-depth: 0
31-
- name: Set up Python
32-
uses: pdm-project/setup-pdm@v4
31+
- name: Setup Python with UV
32+
uses: ./.github/actions/python-uv
3333
with:
3434
python-version: ${{ matrix.python }}
3535
- name: Install dependencies
3636
run: |
37-
pip install tox tox-pdm
37+
uv pip install --system tox tox-pdm
3838
- name: Build the package
3939
run: |
4040
export GUIDELLM_BUILD_TYPE=candidate

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727
uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 0
30-
- name: Set up Python
31-
uses: pdm-project/setup-pdm@v4
30+
- name: Setup Python with UV
31+
uses: ./.github/actions/python-uv
3232
with:
3333
python-version: ${{ matrix.python }}
3434
- name: Install dependencies
3535
run: |
36-
pip install tox tox-pdm
36+
uv pip install --system tox tox-pdm
3737
- name: Build the package
3838
run: |
3939
export GUIDELLM_BUILD_TYPE=release

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ipython_config.py
9595
# pyenv
9696
# For a library or package, you might want to ignore these files since the code is
9797
# intended to run in multiple environments; otherwise, check them in:
98-
# .python-version
98+
.python-version
9999

100100
# pipenv
101101
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

.pre-commit-config.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ repos:
66
exclude: ^tests/?.*/assets/.+
77
- id: end-of-file-fixer
88
exclude: ^tests/?.*/assets/.+
9-
- repo: https://github.com/pdm-project/pdm
10-
rev: 2.25.6
9+
- repo: https://github.com/astral-sh/uv-pre-commit
10+
rev: 0.9.15
1111
hooks:
12-
- id: pdm-lock-check
13-
name: check lock file matches pyproject
14-
entry: sh -c "pdm lock -v --check || pdm lock --update-reuse"
12+
- id: uv-lock
13+
name: check uv.lock file matches pyproject
14+
- id: uv-export
15+
name: Update pylock to match uv.lock
16+
# NOTE: Arguments should match ./scripts/generate_pylock.sh
17+
args:
18+
- "--frozen"
19+
- "--all-groups"
20+
- "--all-extras"
21+
- "--format=pylock.toml"
22+
- "--output-file=pylock.toml"
23+
- "--quiet"
1524
- repo: https://github.com/astral-sh/ruff-pre-commit
1625
rev: v0.11.7
1726
hooks:

Containerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@ USER root
1515

1616
# Install build tooling
1717
RUN dnf install -y git \
18-
&& /usr/bin/python3 -m venv /tmp/pdm \
19-
&& /tmp/pdm/bin/pip install --no-cache-dir -U pdm \
20-
&& ln -s /tmp/pdm/bin/pdm /usr/local/bin/pdm
18+
&& /usr/bin/python3 -m venv /tmp/uv \
19+
&& /tmp/uv/bin/pip install --no-cache-dir -U uv \
20+
&& ln -s /tmp/uv/bin/uv /usr/local/bin/uv
2121

22-
# Disable pdm update check
22+
# Set the default venv for uv
23+
# Copy instead of link files with uv
2324
# Set correct build type for versioning
24-
ENV PDM_CHECK_UPDATE=false \
25+
ENV VIRTUAL_ENV=/opt/app-root \
26+
UV_LINK_MODE="copy" \
2527
GUIDELLM_BUILD_TYPE=$GUIDELLM_BUILD_TYPE
2628

2729
# Copy repository files
2830
# Do this as late as possible to leverage layer caching
2931
COPY / /src
3032

3133
# Install guidellm and locked dependencies
32-
RUN pdm use -p /src -f /opt/app-root \
33-
&& pdm install -p /src -G all --check --prod --no-editable
34+
RUN uv sync --active --project /src --frozen --no-dev --extra all --no-editable
3435

3536
# Prod image
3637
FROM $BASE_IMAGE

0 commit comments

Comments
 (0)