Skip to content

Commit 135eccc

Browse files
Copilotjustinchuby
andauthored
Replace pip with uv in GitHub workflows and nox (onnx#245)
Migrates all GitHub workflow jobs from `pip` to `uv` for faster package installation and better caching. Also configures nox to use uv as the default virtual environment backend. ## Changes - **Package installation**: Replace `python -m pip install` and `pip install` with `uv pip install --system` - **Workflow setup**: Add `astral-sh/setup-uv@v5` with `enable-cache: true` to all jobs requiring package installation - **Consistency**: Update `pip list` to `uv pip list` in version checking steps - **Cleanup**: Remove `--upgrade pip setuptools` commands and duplicate checkout action in pages.yml - **Nox configuration**: Set `nox.options.default_venv_backend = "uv"` in noxfile.py and add `NOX_DEFAULT_VENV_BACKEND=uv` environment variable to test job ## Example ```yaml # Before - name: Install dependencies run: | python -m pip install --upgrade pip setuptools python -m pip install -r requirements-dev.txt # After - name: Install uv uses: astral-sh/setup-uv@v5 with: enable-cache: true - name: Install dependencies run: uv pip install --system -r requirements-dev.txt ``` ## Files Modified - `.github/workflows/main.yml` - test, build_docs, and build jobs - `.github/workflows/lint.yml` - enforce-style job - `.github/workflows/pages.yml` - deploy job - `.github/workflows/copilot-setup-steps.yml` - setup job - `noxfile.py` - configure uv as default venv backend <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Use uv to replace pip install in github workflows </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/onnx/ir-py/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com> Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent b6c59ca commit 135eccc

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ jobs:
3232
uses: actions/setup-python@v6
3333
with:
3434
python-version: "3.12"
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v5
3537
- name: Install Python build dependencies
3638
run: |
37-
python -m pip install -r requirements-dev.txt
38-
python -m pip install -e .
39+
uv pip install --system -r requirements-dev.txt
40+
uv pip install --system -e .

.github/workflows/lint.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ jobs:
4848
uses: actions/setup-python@v6
4949
with:
5050
python-version: "3.12"
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v5
53+
with:
54+
enable-cache: true
5155
- name: Install onnx-ir
5256
run: |
5357
# Install dependencies
54-
python -m pip install --upgrade pip
55-
python -m pip install --upgrade setuptools
56-
python -m pip install -r requirements-dev.txt
58+
uv pip install --system -r requirements-dev.txt
5759
# Install packages
58-
python -m pip install -e .
60+
uv pip install --system -e .
5961
lintrunner init
6062
- name: Run lintrunner on all files
6163
run: |

.github/workflows/main.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ jobs:
5151
uses: actions/setup-python@v6
5252
with:
5353
python-version: ${{ matrix.python-version }}
54+
- name: Install uv
55+
uses: astral-sh/setup-uv@v5
5456
- name: Install nox
55-
run: python -m pip install nox
57+
run: uv pip install --system nox
5658
- name: Pull Test Data
5759
run: git lfs pull
5860
- name: Run tests
61+
env:
62+
NOX_DEFAULT_VENV_BACKEND: uv
5963
run: nox -t ${{ matrix.nox-tag }} --forcecolor -- --cov=src/onnx_ir --cov-report=xml --cov-append --cov-branch -n=auto --junitxml junit.xml
6064
- name: Upload coverage to Codecov
6165
if: always()
@@ -80,19 +84,18 @@ jobs:
8084
uses: actions/setup-python@v6
8185
with:
8286
python-version: "3.12"
83-
cache: pip
84-
cache-dependency-path: "**/requirements-dev.txt"
87+
- name: Install uv
88+
uses: astral-sh/setup-uv@v5
8589
- name: Install dependencies
8690
run: |
87-
python -m pip install --upgrade pip setuptools
88-
python -m pip install -r requirements-dev.txt
91+
uv pip install --system -r requirements-dev.txt
8992
- name: Versions
9093
run: |
91-
pip list | grep numpy
92-
pip list | grep onnx
93-
pip list | grep torch
94+
uv pip list | grep numpy
95+
uv pip list | grep onnx
96+
uv pip list | grep torch
9497
- name: Install package
95-
run: pip install .
98+
run: uv pip install --system .
9699
- name: Build documentation
97100
run: python -m sphinx docs dist/html
98101

@@ -108,9 +111,11 @@ jobs:
108111
uses: actions/setup-python@v6
109112
with:
110113
python-version: "3.12"
114+
- name: Install uv
115+
uses: astral-sh/setup-uv@v5
111116
- name: Install Python build dependencies
112117
run: |
113-
python -m pip install --upgrade pip build wheel
118+
uv pip install --system build wheel
114119
- name: Build wheels
115120
run: |
116121
python -m build

.github/workflows/pages.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ jobs:
3232
uses: actions/setup-python@v6
3333
with:
3434
python-version: "3.10"
35-
- uses: actions/checkout@v5
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v5
37+
with:
38+
enable-cache: true
3639
- name: Install dependencies
3740
run: |
38-
python -m pip install --upgrade pip setuptools
39-
python -m pip install -r requirements-dev.txt
41+
uv pip install --system -r requirements-dev.txt
4042
- name: Install package
41-
run: pip install .
43+
run: uv pip install --system .
4244
- name: Build documentation
4345
run: python -m sphinx docs dist/html
4446
- name: Upload documentation archive

noxfile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import nox
1010

1111
nox.options.error_on_missing_interpreters = False
12+
nox.options.default_venv_backend = "uv"
1213

1314

1415
COMMON_TEST_DEPENDENCIES = (
@@ -54,7 +55,7 @@ def test(session):
5455
)
5556
session.install(ONNXSCRIPT, "--no-deps")
5657
session.install(".", "--no-deps")
57-
session.run("pip", "list")
58+
session.run("uv", "pip", "list")
5859
session.run("pytest", "src", "--doctest-modules", *session.posargs)
5960
session.run("pytest", "tests", *session.posargs)
6061

@@ -66,7 +67,7 @@ def test_onnx_weekly(session):
6667
session.install("-r", "requirements/ci/requirements-onnx-weekly.txt")
6768
session.install(ONNXSCRIPT, "--no-deps")
6869
session.install(".", "--no-deps")
69-
session.run("pip", "list")
70+
session.run("uv", "pip", "list")
7071
session.run("pytest", "src", "--doctest-modules", *session.posargs)
7172
session.run("pytest", "tests", *session.posargs)
7273

@@ -79,7 +80,7 @@ def test_torch_nightly(session):
7980
session.install("-r", "requirements/ci/requirements-pytorch-nightly.txt")
8081
session.install(ONNXSCRIPT, "--no-deps")
8182
session.install(".", "--no-deps")
82-
session.run("pip", "list")
83+
session.run("uv", "pip", "list")
8384
session.run("pytest", "src", "--doctest-modules", *session.posargs)
8485
session.run("pytest", "tests", *session.posargs)
8586

0 commit comments

Comments
 (0)