Skip to content

Commit dd50779

Browse files
authored
Use uv for running check.py (#1040)
Use uv to run and manage the environment in which the check.py runs. * Add the dependencies required to run the check.py script to a new check dependency group. Note that to avoid automatically installing these dependencies into the environment the dev group is not used. * Update check.py to use `uv run` * Update the check workflow to use uv.
1 parent 264a73c commit dd50779

4 files changed

Lines changed: 249 additions & 30 deletions

File tree

.github/workflows/check.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ jobs:
2222
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2323
with:
2424
persist-credentials: false
25-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
25+
- name: Set up uv
26+
uses: astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7.5.0
2627
with:
27-
python-version: "3.12"
28+
enable-cache: false
2829

2930
- name: "Run checks"
3031
run: |
31-
python ./check.py
32+
./check.py

check.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S uv run --group check
22
# This Source Code Form is subject to the terms of the Mozilla Public
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
@@ -7,30 +7,8 @@
77

88
import argparse
99
import os
10-
import pathlib
1110
import subprocess
1211
import sys
13-
import venv
14-
15-
ROOT = pathlib.Path(os.path.abspath(__file__)).parent
16-
VENV = ROOT / "venv.dev"
17-
PIP = VENV / "bin" / "pip"
18-
PYTHON = VENV / "bin" / "python"
19-
REQUIREMENTS = ROOT / "requirements.dev.txt"
20-
21-
22-
def bootstrap():
23-
venv.create(VENV, with_pip=True)
24-
25-
subprocess.run([str(PIP), "install", "-r", str(REQUIREMENTS)], check=True)
26-
27-
os.environ["PYBUILD_BOOTSTRAPPED"] = "1"
28-
os.environ["PATH"] = "%s:%s" % (str(VENV / "bin"), os.environ["PATH"])
29-
os.environ["PYTHONPATH"] = str(ROOT)
30-
31-
args = [str(PYTHON), __file__, *sys.argv[1:]]
32-
33-
os.execv(str(PYTHON), args)
3412

3513

3614
def run_command(command: list[str]) -> int:
@@ -76,9 +54,6 @@ def run():
7654

7755
if __name__ == "__main__":
7856
try:
79-
if "PYBUILD_BOOTSTRAPPED" not in os.environ:
80-
bootstrap()
81-
else:
82-
run()
57+
run()
8358
except subprocess.CalledProcessError as e:
8459
sys.exit(e.returncode)

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ build-backend = "uv_build"
2222
[tool.uv.build-backend]
2323
module-name = "pythonbuild"
2424
module-root = ""
25+
26+
[dependency-groups]
27+
check = [
28+
"mypy>=1.19.1",
29+
"ruff>=0.15.7",
30+
"types-jinja2>=2.11.9",
31+
"types-jsonschema>=4.26.0.20260324",
32+
"types-pyyaml>=6.0.12.20250915",
33+
]

0 commit comments

Comments
 (0)