Skip to content

chore: use dependency-groups #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ wheelhouse/

# Version
_version.py

CMakeCache.txt
CMakeFiles
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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
12 changes: 5 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-22.04
tools:
python: "3.12"

python:
install:
- requirements: docs/requirements.txt
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv run --only-group docs sphinx-build -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
7 changes: 0 additions & 7 deletions docs/requirements.txt

This file was deleted.

65 changes: 35 additions & 30 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
# /// script
# dependencies = ["nox>=2025.2.9"]
# ///

import argparse
import re
from pathlib import Path

import nox

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

BUILD_ENV = {
"MACOSX_DEPLOYMENT_TARGET": "10.10",
"ARCHFLAGS": "-arch x86_64 -arch arm64",
}

built = ""
wheel = ""


@nox.session
def build(session: nox.Session) -> str:
"""
Make an SDist and a wheel. Only runs once.
Make an SDist and a wheel.
"""
global built
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
wheel = f"dist/{wheel_path.name}"


@nox.session
Expand All @@ -47,32 +50,34 @@ def lint(session: nox.Session) -> str:
session.run("pre-commit", "run", "-a")


@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(reuse_venv=True)
@nox.session(reuse_venv=True, default=False)
def docs(session: nox.Session) -> None:
"""
Build the docs. Pass "--non-interactive" to avoid serve. Pass "-- -b linkcheck" to check links.
"""
pyproject = nox.project.load_toml("pyproject.toml")
deps = nox.project.dependency_groups(pyproject, "docs")

parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
parser.add_argument(
"-b", dest="builder", default="html", help="Build target (default: html)"
)
args, posargs = parser.parse_known_args(session.posargs)
serve = args.builder == "html" and session.interactive

extra_installs = ["sphinx-autobuild"] if serve else []
session.install("-r", "docs/requirements.txt", *extra_installs)
session.install(*deps, *extra_installs)
session.chdir("docs")

if args.builder == "linkcheck":
Expand Down Expand Up @@ -130,7 +135,7 @@ def _bump(session: nox.Session, name: str, repository: str, branch: str, script:
)


@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 All @@ -146,7 +151,7 @@ def bump(session: nox.Session) -> None:
_bump(session, "CMake", "kitware/cmake", "", "scripts/update_cmake_version.py", files)


@nox.session(name="bump-openssl")
@nox.session(name="bump-openssl", default=False)
def bump_openssl(session: nox.Session) -> None:
"""
Set openssl to a new version, use -- <version>, otherwise will use the latest version.
Expand All @@ -162,7 +167,7 @@ def _get_version() -> str:
return next(iter(re.finditer(r'^version = "([\d\.]+)"$', txt, flags=re.MULTILINE))).group(1)


@nox.session(venv_backend="none")
@nox.session(venv_backend="none", default=False)
def tag_release(session: nox.Session) -> None:
"""
Print instructions for tagging a release and pushing it to GitHub.
Expand All @@ -174,7 +179,7 @@ def tag_release(session: nox.Session) -> None:
print(f"git push origin {current_version}")


@nox.session(venv_backend="none")
@nox.session(venv_backend="none", default=False)
def cmake_version(session: nox.Session) -> None: # noqa: ARG001
"""
Print upstream cmake version.
Expand All @@ -184,7 +189,7 @@ def cmake_version(session: nox.Session) -> None: # noqa: ARG001
print(".".join(current_version.split(".")[:3]))


@nox.session(venv_backend="none")
@nox.session(venv_backend="none", default=False)
def openssl_version(session: nox.Session) -> None: # noqa: ARG001
"""
Print upstream OpenSSL version.
Expand Down
33 changes: 25 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,31 @@ Source = "https://github.com/scikit-build/cmake-python-distributions"
"Mailing list" = "https://groups.google.com/forum/#!forum/scikit-build"
"Bug Tracker" = "https://github.com/scikit-build/cmake-python-distributions/issues"

[project.optional-dependencies]
test = [
"coverage>=4.2",
"pytest>=3.0.3",
"pytest-cov>=2.4.0",
]

[project.scripts]
ccmake = "cmake:ccmake"
cmake = "cmake:cmake"
cpack = "cmake:cpack"
ctest = "cmake:ctest"


[dependency-groups]
test = [
"coverage>=4.2",
"pytest>=6",
"pytest-cov>=2.4.0",
]
docs = [
"docutils",
"funcparserlib>=1.0.0",
"furo",
"pygments",
"sphinx",
"sphinxcontrib-mermaid",
"tomli; python_version<'3.11'",
]
dev = [{ include-group="test" }]


[tool.scikit-build]
minimum-version = "build-system.requires"
build-dir = "build/{wheel_tag}"
Expand All @@ -76,9 +88,14 @@ wheel.cmake = false
wheel.platlib = true


[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]


[tool.cibuildwheel]
build = "cp39-*"
test-extras = "test"
test-groups = ["test"]
test-command = "pytest {project}/tests"
build-verbosity = 1
build-frontend = "build[uv]"
Expand Down
Loading