Skip to content

Commit e942982

Browse files
committed
chore: use dependency-groups
1 parent 0bf0047 commit e942982

File tree

4 files changed

+45
-32
lines changed

4 files changed

+45
-32
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
uses: docker/[email protected]
7171
if: runner.os == 'Linux' && runner.arch == 'X64'
7272

73-
- uses: yezz123/setup-uv@v4
73+
- uses: astral-sh/setup-uv@v5
7474

7575
- name: Build wheels
7676
uses: pypa/[email protected]
@@ -120,8 +120,17 @@ jobs:
120120
- uses: actions/checkout@v4
121121
- uses: actions/setup-python@v5
122122
name: Install Python ${{ matrix.python }}
123+
id: python
123124
with:
124125
python-version: ${{ matrix.python }}
126+
update-environment: false
127+
128+
- uses: astral-sh/setup-uv@v5
129+
with:
130+
python-version: "${{ steps.python.outputs.python-path }}"
131+
132+
- name: Setup environment
133+
run: uv pip install pip --group test
125134

126135
- uses: actions/download-artifact@v4
127136
with:
@@ -145,7 +154,7 @@ jobs:
145154
done
146155
147156
- name: Install SDist
148-
run: pip install --no-binary=ninja $(ls sdist/*.tar.gz)[test]
157+
run: pip install --no-binary=ninja $(ls sdist/*.tar.gz)
149158

150159
- name: Test installed SDist
151160
run: pip check && pytest ./tests

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repos:
1010
- id: debug-statements
1111
- id: end-of-file-fixer
1212
- id: mixed-line-ending
13-
- id: requirements-txt-fixer
1413
- id: trailing-whitespace
1514

1615
- repo: https://github.com/astral-sh/ruff-pre-commit

noxfile.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# /// script
2+
# dependencies = ["nox>=2025.2.9"]
3+
# ///
4+
15
from __future__ import annotations
26

37
import argparse
@@ -6,9 +10,8 @@
610

711
import nox
812

9-
nox.needs_version = ">=2024.4.15"
13+
nox.needs_version = ">=2025.2.9"
1014
nox.options.default_venv_backend = "uv|virtualenv"
11-
nox.options.sessions = ["lint", "build", "tests"]
1215

1316
if sys.platform.startswith("darwin"):
1417
BUILD_ENV = {
@@ -18,29 +21,29 @@
1821
else:
1922
BUILD_ENV = {}
2023

21-
built = ""
24+
wheel = ""
2225

2326

2427
@nox.session
2528
def build(session: nox.Session) -> str:
2629
"""
2730
Make an SDist and a wheel. Only runs once.
2831
"""
29-
global built # noqa: PLW0603
30-
if not built:
31-
session.log(
32-
"The files produced locally by this job are not intended to be redistributable"
33-
)
34-
session.install("build")
35-
tmpdir = session.create_tmp()
36-
session.run("python", "-m", "build", "--outdir", tmpdir, env=BUILD_ENV)
37-
(wheel_path,) = Path(tmpdir).glob("*.whl")
38-
(sdist_path,) = Path(tmpdir).glob("*.tar.gz")
39-
Path("dist").mkdir(exist_ok=True)
40-
wheel_path.rename(f"dist/{wheel_path.name}")
41-
sdist_path.rename(f"dist/{sdist_path.name}")
42-
built = wheel_path.name
43-
return built
32+
session.log(
33+
"The files produced locally by this job are not intended to be redistributable"
34+
)
35+
extra = ["--installer=uv"] if session.venv_backend == "uv" else []
36+
session.install("build")
37+
tmpdir = session.create_tmp()
38+
session.run("python", "-m", "build", "--outdir", tmpdir, *extra, env=BUILD_ENV)
39+
(wheel_path,) = Path(tmpdir).glob("*.whl")
40+
(sdist_path,) = Path(tmpdir).glob("*.tar.gz")
41+
Path("dist").mkdir(exist_ok=True)
42+
wheel_path.rename(f"dist/{wheel_path.name}")
43+
sdist_path.rename(f"dist/{sdist_path.name}")
44+
45+
global wheel # noqa: PLW0603
46+
wheel = f"dist/{wheel_path.name}"
4447

4548

4649
@nox.session
@@ -52,17 +55,18 @@ def lint(session: nox.Session) -> str:
5255
session.run("pre-commit", "run", "-a", *session.posargs)
5356

5457

55-
@nox.session
58+
@nox.session(requires=["build"])
5659
def tests(session: nox.Session) -> str:
5760
"""
5861
Run the tests.
5962
"""
60-
wheel = build(session)
61-
session.install(f"./dist/{wheel}[test]")
63+
pyproject = nox.project.load_toml("pyproject.toml")
64+
deps = nox.project.dependency_groups(pyproject, "test")
65+
session.install(wheel, *deps)
6266
session.run("pytest", *session.posargs)
6367

6468

65-
@nox.session
69+
@nox.session(default=False)
6670
def bump(session: nox.Session) -> None:
6771
"""
6872
Set to a new version, use -- <version>, otherwise will use the latest version.

pyproject.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ classifiers = [
3434
]
3535
requires-python = ">=3.7"
3636

37-
[project.optional-dependencies]
38-
test = [
39-
"importlib_metadata>=2.0",
40-
"pytest>=6.0",
41-
]
42-
4337
[project.urls]
4438
"Bug Tracker" = "https://github.com/scikit-build/ninja-python-distributions/issues"
4539
Documentation = "https://github.com/scikit-build/ninja-python-distributions#readme"
@@ -48,6 +42,13 @@ Homepage = "http://ninja-build.org/"
4842
"Mailing list" = "https://groups.google.com/forum/#!forum/scikit-build"
4943
"Source Code" = "https://github.com/scikit-build/ninja-python-distributions"
5044

45+
[dependency-groups]
46+
test = [
47+
"importlib_metadata>=2.0",
48+
"pytest>=6.0",
49+
]
50+
dev = [{ include-group="test" }]
51+
5152
[tool.scikit-build]
5253
minimum-version = "build-system.requires"
5354
cmake.version = "CMakeLists.txt" # Force parsing version from CMakeLists.txt and disable fallback to '>=3.15'
@@ -86,7 +87,7 @@ replacement = ""
8687
build = "cp39-*"
8788
build-frontend = "build[uv]"
8889
build-verbosity = 1
89-
test-extras = "test"
90+
test-groups = "test"
9091
test-command = "pytest {project}/tests"
9192
test-skip = ["*-win_arm64", "*-macosx_universal2:arm64"]
9293
environment = { NINJA_PYTHON_DIST_ALLOW_NINJA_DEP = "1" }

0 commit comments

Comments
 (0)