diff --git a/.gitignore b/.gitignore index 552de032..b42fec58 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,6 @@ wheelhouse/ # Version _version.py + +CMakeCache.txt +CMakeFiles diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61155290..e826e131 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 57da64db..56833b07 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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 diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 315a8637..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -docutils -funcparserlib>=1.0.0 -furo -pygments -sphinx -sphinxcontrib-mermaid -tomli; python_version<"3.11" diff --git a/noxfile.py b/noxfile.py index 6f8f8f8c..bc1ee329 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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 @@ -47,24 +50,26 @@ 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)" ) @@ -72,7 +77,7 @@ def docs(session: nox.Session) -> None: 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": @@ -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 -- , otherwise will use the latest version. @@ -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 -- , otherwise will use the latest version. @@ -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. @@ -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. @@ -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. diff --git a/pyproject.toml b/pyproject.toml index 61a28517..e4e2431e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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}" @@ -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]"