|
1 | | -# AI Instructions |
2 | | - |
3 | | -## Overview |
4 | | - |
5 | | -**scikit-build-core**: Python 3.8+ adaptor for CMake 3.15+ to be used with |
6 | | -Python package builds. |
7 | | - |
8 | | ---- |
9 | | - |
10 | | -## Core Commands |
11 | | - |
12 | | -### Setup |
13 | | - |
14 | | -If `uv`, `nox`, and `prek` commands are not available, they can be installed |
15 | | -from PyPI: |
16 | | - |
17 | | -```bash |
18 | | -pip install uv prek nox |
19 | | -``` |
20 | | - |
21 | | -### Test & Lint |
22 | | - |
23 | | -```bash |
24 | | -uv run pytest # run tests |
25 | | -prek -a # run all lint/format hooks |
26 | | -``` |
27 | | - |
28 | | -### Build |
29 | | - |
30 | | -```bash |
31 | | -uv build |
32 | | -``` |
33 | | - |
34 | | -### Docs (only if needed) |
35 | | - |
36 | | -```bash |
37 | | -nox -s docs |
38 | | -``` |
39 | | - |
40 | | -### Other things |
41 | | - |
42 | | -```bash |
43 | | -nox -s pylint # A bit slower than the normal lints |
44 | | -nox -t gen # Several generation steps, like parts of the README |
45 | | -nox -s tests -- --cov # A way to run coverage |
46 | | -``` |
47 | | - |
48 | | ---- |
49 | | - |
50 | | ---- |
51 | | - |
52 | | -## Development Workflow |
53 | | - |
54 | | -1. Run baseline if needed: |
55 | | - |
56 | | - ```bash |
57 | | - uv run pytest |
58 | | - prek -a |
59 | | - ``` |
60 | | - |
61 | | -2. Make changes |
62 | | - |
63 | | -3. Validate: |
64 | | - |
65 | | - ```bash |
66 | | - prek -a |
67 | | - uv run pytest |
68 | | - ``` |
69 | | - |
70 | | -4. If API/docs changed: |
71 | | - |
72 | | - ```bash |
73 | | - nox -s docs |
74 | | - ``` |
75 | | - |
76 | | ---- |
77 | | - |
78 | | -## PR Requirements |
79 | | - |
80 | | -- Tests pass: `uv run pytest` |
81 | | -- Lint passes: `prek -a` |
82 | | - |
83 | | ---- |
84 | | - |
85 | | -## Key Notes |
86 | | - |
87 | | -- Python ≥3.8 (uses modern syntax) |
88 | | -- Pre-commit handles formatting, linting, typing |
89 | | -- Tests are a bit slow |
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Project |
| 4 | + |
| 5 | +`scikit-build-core` is a PEP 517 build backend for CMake-based Python packages. |
| 6 | +It is built with **hatchling** and stored under `src/scikit_build_core/`. |
| 7 | + |
| 8 | +## Running things |
| 9 | + |
| 10 | +- Prefer `uv run` over bare Python invocations. There is a `uv.lock` checked in. |
| 11 | +- Use `uv sync` for a local dev install. `uv run` does this for you. |
| 12 | +- `nox` is the task runner. |
| 13 | + - `nox -s tests` — run tests with xdist (`-n auto`). |
| 14 | + - `nox -s tests -- -k test_foo` — single test runner. |
| 15 | + - `nox -s docs` — build Sphinx docs (serve with `nox -s docs -- serve`; |
| 16 | + non-interactive with `nox -s docs -- --non-interactive`). |
| 17 | + - `nox -t gen` — run all code generators (cog for README + schema + config |
| 18 | + reference + API docs). |
| 19 | + - `nox -s minimums` — lowest-direct dependency tests. |
| 20 | +- For linting, `prek -a --quiet` is preferred. |
| 21 | + |
| 22 | +## Testing |
| 23 | + |
| 24 | +- Tests live in `tests/`. Sample packages are in `tests/packages/` but **must |
| 25 | + not be recursed into** by pytest (`norecursedirs = ["tests/packages/**"]`). |
| 26 | +- `tests/utils` is on `pythonpath` for test utilities. |
| 27 | +- Many tests need a virtualenv (fixtures: `isolated`, `virtualenv`). These are |
| 28 | + auto-marked as `virtualenv` and `isolated` by `conftest.py`. |
| 29 | +- Important pytest markers: `compile`, `configure`, `fortran`, `integration`, |
| 30 | + `isolated`, `network`, `setuptools`, `upstream`, `virtualenv`. |
| 31 | +- `pytest -n auto` is the default parallelism. Some platforms retry on PyPy. |
| 32 | + |
| 33 | +## Code quality |
| 34 | + |
| 35 | +- **Ruff** handles linting and formatting. Do not import banned modules directly |
| 36 | + (e.g. use `scikit_build_core._compat.tomllib` instead of `tomli`/`tomllib`, |
| 37 | + `scikit_build_core._compat.typing.Self` instead of `typing.Self`). See |
| 38 | + `pyproject.toml` `tool.ruff.lint.flake8-tidy-imports.banned-api`. |
| 39 | +- **mypy** is strict for `scikit_build_core.*`, less strict for tests. Config in |
| 40 | + `pyproject.toml`. |
| 41 | +- **pylint** is sometimes run separately in CI (`nox -s pylint`). |
| 42 | +- pre-commit includes `check-sdist`, `validate-pyproject`, JSON schema checks, |
| 43 | + typos, shellcheck, and `sp-repo-review`. |
| 44 | + |
| 45 | +## Generated files |
| 46 | + |
| 47 | +- `README.md` and `docs/reference/configs.md` contain cog-generated sections. |
| 48 | +- `src/scikit_build_core/resources/scikit-build.schema.json` is generated from |
| 49 | + the Pydantic-style model. |
| 50 | +- Run `nox -t gen` after changing any of these sources, then verify |
| 51 | + `git diff --exit-code` in CI. |
| 52 | + |
| 53 | +## Architecture notes |
| 54 | + |
| 55 | +- `src/scikit_build_core/build/` — PEP 517 entry points. |
| 56 | +- `src/scikit_build_core/settings/` — configuration system, |
| 57 | + TOML/env/config-settings reading. |
| 58 | +- `src/scikit_build_core/cmake.py` / `src/scikit_build_core/builder/` — CMake |
| 59 | + invocation and builders. |
| 60 | +- `src/scikit_build_core/file_api/` — CMake File API reader. |
| 61 | +- `src/scikit_build_core/_compat/` — backports (typing, tomllib, importlib). |
| 62 | + Ruff enforces their use. |
| 63 | +- `src/scikit_build_core/_vendor/` — vendored `pyproject_metadata`. Do not lint. |
| 64 | +- Experimental interfaces (setuptools, hatchling) will likely be split into |
| 65 | + separate packages. |
0 commit comments