Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ jobs:
uses: docker/[email protected]
if: runner.os == 'Linux' && runner.arch == 'X64'

- uses: yezz123/setup-uv@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: false

- name: Build wheels
uses: pypa/[email protected]
Expand Down Expand Up @@ -120,8 +122,19 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python ${{ matrix.python }}
id: python
with:
python-version: ${{ matrix.python }}
update-environment: false

- uses: astral-sh/setup-uv@v5
with:
enable-cache: false

- name: Setup environment
run: |
uv venv --python "${{ steps.python.outputs.python-path }}"
uv pip install pip --group test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I missed this was added in 0.6.7! I was following the PR but missed the merge.


- uses: actions/download-artifact@v4
with:
Expand All @@ -145,10 +158,10 @@ jobs:
done

- name: Install SDist
run: pip install --no-binary=ninja $(ls sdist/*.tar.gz)[test]
run: .venv/bin/pip install --no-binary=ninja $(ls sdist/*.tar.gz)

- name: Test installed SDist
run: pip check && pytest ./tests
run: .venv/bin/pip check && .venv/bin/pytest ./tests

check_dist:
name: Check dist
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
48 changes: 26 additions & 22 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["nox>=2025.2.9"]
# ///

from __future__ import annotations

import argparse
Expand All @@ -6,9 +10,8 @@

import nox

nox.needs_version = ">=2024.4.15"
nox.needs_version = ">=2025.2.9"
nox.options.default_venv_backend = "uv|virtualenv"
nox.options.sessions = ["lint", "build", "tests"]

if sys.platform.startswith("darwin"):
BUILD_ENV = {
Expand All @@ -18,29 +21,29 @@
else:
BUILD_ENV = {}

built = ""
wheel = ""


@nox.session
def build(session: nox.Session) -> str:
"""
Make an SDist and a wheel. Only runs once.
"""
global built # noqa: PLW0603
if not built:
session.log(
"The files produced locally by this job are not intended to be redistributable"
)
session.install("build")
tmpdir = session.create_tmp()
session.run("python", "-m", "build", "--outdir", tmpdir, env=BUILD_ENV)
(wheel_path,) = Path(tmpdir).glob("*.whl")
(sdist_path,) = Path(tmpdir).glob("*.tar.gz")
Path("dist").mkdir(exist_ok=True)
wheel_path.rename(f"dist/{wheel_path.name}")
sdist_path.rename(f"dist/{sdist_path.name}")
built = wheel_path.name
return built
session.log(
"The files produced locally by this job are not intended to be redistributable"
)
extra = ["--installer=uv"] if session.venv_backend == "uv" else []
session.install("build")
tmpdir = session.create_tmp()
session.run("python", "-m", "build", "--outdir", tmpdir, *extra, env=BUILD_ENV)
(wheel_path,) = Path(tmpdir).glob("*.whl")
(sdist_path,) = Path(tmpdir).glob("*.tar.gz")
Path("dist").mkdir(exist_ok=True)
wheel_path.rename(f"dist/{wheel_path.name}")
sdist_path.rename(f"dist/{sdist_path.name}")

global wheel # noqa: PLW0603
wheel = f"dist/{wheel_path.name}"


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


@nox.session
@nox.session(requires=["build"])
def tests(session: nox.Session) -> str:
"""
Run the tests.
"""
wheel = build(session)
session.install(f"./dist/{wheel}[test]")
pyproject = nox.project.load_toml("pyproject.toml")
deps = nox.project.dependency_groups(pyproject, "test")
session.install(wheel, *deps)
session.run("pytest", *session.posargs)


@nox.session
@nox.session(default=False)
def bump(session: nox.Session) -> None:
"""
Set to a new version, use -- <version>, otherwise will use the latest version.
Expand Down
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ classifiers = [
]
requires-python = ">=3.7"

[project.optional-dependencies]
test = [
"importlib_metadata>=2.0",
"pytest>=6.0",
]

[project.urls]
"Bug Tracker" = "https://github.com/scikit-build/ninja-python-distributions/issues"
Documentation = "https://github.com/scikit-build/ninja-python-distributions#readme"
Expand All @@ -48,6 +42,13 @@ Homepage = "http://ninja-build.org/"
"Mailing list" = "https://groups.google.com/forum/#!forum/scikit-build"
"Source Code" = "https://github.com/scikit-build/ninja-python-distributions"

[dependency-groups]
test = [
"importlib_metadata>=2.0",
"pytest>=6.0",
]
dev = [{ include-group="test" }]

[tool.scikit-build]
minimum-version = "build-system.requires"
cmake.version = "CMakeLists.txt" # Force parsing version from CMakeLists.txt and disable fallback to '>=3.15'
Expand Down Expand Up @@ -86,7 +87,7 @@ replacement = ""
build = "cp39-*"
build-frontend = "build[uv]"
build-verbosity = 1
test-extras = "test"
test-groups = "test"
test-command = "pytest {project}/tests"
test-skip = ["*-win_arm64", "*-macosx_universal2:arm64"]
environment = { NINJA_PYTHON_DIST_ALLOW_NINJA_DEP = "1" }
Expand Down
Loading