Skip to content

Commit b28b61c

Browse files
committed
Use uv in CI and update for PEP 639.
1 parent 9079dc9 commit b28b61c

File tree

4 files changed

+85
-60
lines changed

4 files changed

+85
-60
lines changed

.github/workflows/ci.yml

+23-22
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,32 @@ on:
77
tags:
88
- "v*"
99
pull_request:
10-
release:
11-
types: [published]
1210
schedule:
1311
# Daily at 7:37
1412
- cron: "37 7 * * *"
1513
workflow_dispatch:
1614

17-
env:
18-
PIP_DISABLE_PIP_VERSION_CHECK: "1"
19-
PIP_NO_PYTHON_VERSION_WARNING: "1"
20-
2115
jobs:
2216
list:
2317
runs-on: ubuntu-latest
2418
outputs:
2519
noxenvs: ${{ steps.noxenvs-matrix.outputs.noxenvs }}
2620
steps:
2721
- uses: actions/checkout@v4
28-
- name: Set up nox
29-
uses: wntrblm/[email protected]
22+
- name: Set up uv
23+
uses: astral-sh/setup-uv@v5
24+
with:
25+
enable-cache: true
3026
- id: noxenvs-matrix
3127
run: |
3228
echo >>$GITHUB_OUTPUT noxenvs=$(
33-
nox --list-sessions --json | jq '[.[].session]'
29+
uvx nox --list-sessions --json | jq '[.[].session]'
3430
)
3531
3632
ci:
3733
needs: list
3834
runs-on: ${{ matrix.os }}
35+
3936
strategy:
4037
fail-fast: false
4138
matrix:
@@ -44,7 +41,7 @@ jobs:
4441
posargs: [""]
4542
include:
4643
- os: ubuntu-latest
47-
noxenv: "tests-3.11"
44+
noxenv: tests-3.13
4845
posargs: coverage github
4946

5047
steps:
@@ -59,39 +56,43 @@ jobs:
5956
uses: actions/setup-python@v5
6057
with:
6158
python-version: |
62-
3.8
6359
3.9
6460
3.10
6561
3.11
6662
3.12
63+
3.13
6764
pypy3.10
6865
allow-prereleases: true
69-
- name: Set up nox
70-
uses: wntrblm/[email protected]
66+
67+
- name: Set up uv
68+
uses: astral-sh/setup-uv@v5
69+
with:
70+
enable-cache: true
71+
7172
- name: Run nox
72-
run: nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }}
73+
run: uvx nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }}
7374

7475
packaging:
7576
needs: ci
7677
runs-on: ubuntu-latest
7778
environment:
7879
name: PyPI
7980
url: https://pypi.org/p/jsonschema-lexer
81+
8082
permissions:
8183
contents: write
8284
id-token: write
8385

8486
steps:
8587
- uses: actions/checkout@v4
86-
- name: Set up Python
87-
uses: actions/setup-python@v5
88+
- name: Set up uv
89+
uses: astral-sh/setup-uv@v5
8890
with:
89-
cache: pip
90-
python-version: "3.x"
91-
- name: Install dependencies
92-
run: python -m pip install build
93-
- name: Create packages
94-
run: python -m build .
91+
enable-cache: true
92+
93+
- name: Build our distributions
94+
run: uv run --frozen --with 'build[uv]' -m build --installer=uv
95+
9596
- name: Publish to PyPI
9697
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
9798
uses: pypa/gh-action-pypi-publish@release/v1

noxfile.py

+32-24
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
REQUIREMENTS = dict(
1313
tests=ROOT / "test-requirements.txt",
1414
)
15-
REQUIREMENTS_IN = {
16-
path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values()
17-
}
15+
REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other
16+
(path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values()
17+
]
1818

19-
20-
SUPPORTED = ["pypy3.10", "3.10", "3.11", "3.12"]
19+
SUPPORTED = ["pypy3.10", "3.10", "3.11", "3.12", "3.13"]
2120
LATEST = SUPPORTED[-1]
2221

22+
nox.options.default_venv_backend = "uv|virtualenv"
2323
nox.options.sessions = []
2424

2525

@@ -35,7 +35,7 @@ def _session(fn):
3535
@session(python=SUPPORTED)
3636
def tests(session):
3737
"""
38-
Run the test suite.
38+
Run the test suite with a corresponding Python version.
3939
"""
4040
session.install("-r", REQUIREMENTS["tests"])
4141

@@ -60,7 +60,7 @@ def tests(session):
6060
stdout=summary,
6161
)
6262
else:
63-
session.run("python", "-m", "pytest", *session.posargs, PACKAGE)
63+
session.run("pytest", *session.posargs, PACKAGE)
6464

6565

6666
@session(python=SUPPORTED)
@@ -77,9 +77,15 @@ def build(session):
7777
"""
7878
Build a distribution suitable for PyPI and check its validity.
7979
"""
80-
session.install("build", "twine")
80+
session.install("build[uv]", "twine")
8181
with TemporaryDirectory() as tmpdir:
82-
session.run("python", "-m", "build", ROOT, "--outdir", tmpdir)
82+
session.run(
83+
"pyproject-build",
84+
"--installer=uv",
85+
ROOT,
86+
"--outdir",
87+
tmpdir,
88+
)
8389
session.run("twine", "check", "--strict", tmpdir + "/*")
8490

8591

@@ -95,33 +101,35 @@ def secrets(session):
95101
@session(tags=["style"])
96102
def style(session):
97103
"""
98-
Check for coding style.
104+
Check Python code style.
99105
"""
100106
session.install("ruff")
101-
session.run("ruff", "check", ROOT)
107+
session.run("ruff", "check", ROOT, __file__)
102108

103109

104110
@session()
105111
def typing(session):
106112
"""
107-
Statically check typing annotations.
113+
Check static typing.
108114
"""
109115
session.install("pyright", ROOT)
110-
session.run("pyright", PACKAGE)
116+
session.run("pyright", *session.posargs, PACKAGE)
111117

112118

113119
@session(default=False)
114120
def requirements(session):
115121
"""
116-
Update requirements files.
122+
Update the project's pinned requirements.
123+
124+
You should commit the result afterwards.
117125
"""
118-
session.install("pip-tools")
119-
for each in REQUIREMENTS_IN:
120-
session.run(
121-
"pip-compile",
122-
"--resolver",
123-
"backtracking",
124-
"--strip-extras",
125-
"-U",
126-
each.relative_to(ROOT),
127-
)
126+
if session.venv_backend == "uv":
127+
cmd = ["uv", "pip", "compile"]
128+
else:
129+
session.install("pip-tools")
130+
cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"]
131+
132+
for each, out in REQUIREMENTS_IN:
133+
# otherwise output files end up with silly absolute path comments...
134+
relative = each.relative_to(ROOT)
135+
session.run(*cmd, "--upgrade", "--output-file", out, relative)

pyproject.toml

+9-14
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ name = "jsonschema-lexer"
1010
description = "A Pygments lexer for JSON Schema"
1111
requires-python = ">=3.10"
1212
readme = "README.rst"
13+
license = "MIT"
14+
license-files = ["COPYING"]
1315
keywords = ["json", "jsonschema"]
1416
authors = [
1517
{ name = "Julian Berman", email = "[email protected]" },
1618
]
1719
classifiers = [
1820
"Development Status :: 3 - Alpha",
19-
"License :: OSI Approved :: MIT License",
21+
"Intended Audience :: Developers",
2022
"Operating System :: OS Independent",
2123
"Programming Language :: Python",
2224
"Programming Language :: Python :: 3.10",
2325
"Programming Language :: Python :: 3.11",
2426
"Programming Language :: Python :: 3.12",
25-
"Programming Language :: Python :: 3",
27+
"Programming Language :: Python :: 3.13",
2628
"Programming Language :: Python :: Implementation :: CPython",
2729
"Programming Language :: Python :: Implementation :: PyPy",
2830
"Topic :: File Formats :: JSON",
@@ -56,24 +58,16 @@ skip_covered = true
5658

5759
[tool.doc8]
5860
ignore = [
59-
"D000", # see PyCQA/doc8#125
60-
"D001", # one sentence per line, so max length doesn't make sense
61+
"D000", # see PyCQA/doc8#125
62+
"D001", # one sentence per line, so max length doesn't make sense
6163
]
6264

63-
[tool.isort]
64-
combine_as_imports = true
65-
ensure_newline_before_comments = true
66-
from_first = true
67-
include_trailing_comma = true
68-
multi_line_output = 3
69-
use_parentheses = true
70-
7165
[tool.pyright]
7266
reportUnnecessaryTypeIgnoreComment = true
7367
strict = ["**/*.py"]
7468
exclude = [
75-
"**/tests/__init__.py",
76-
"**/tests/test_*.py",
69+
"**/tests/__init__.py",
70+
"**/tests/test_*.py",
7771
]
7872

7973
[tool.ruff]
@@ -85,6 +79,7 @@ ignore = [
8579
"A001", # It's fine to shadow builtins
8680
"A002",
8781
"A003",
82+
"A005",
8883
"ARG", # This is all wrong whenever an interface is involved
8984
"ANN", # Just let the type checker do this
9085
"B006", # Mutable arguments require care but are OK if you don't abuse them

uv.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)