Skip to content

feat: package-declared config-settings - #1489

Open
henryiii wants to merge 7 commits into
mainfrom
config-setting-declarations
Open

feat: package-declared config-settings#1489
henryiii wants to merge 7 commits into
mainfrom
config-setting-declarations

Conversation

@henryiii

@henryiii henryiii commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Design choices:

  • User config-settings require a . (namespaced)
  • Explicit strings required (keeps schema simple and avoids TOML dict collisions)

🤖 AI text below 🤖

Implements the design discussed in #1468 (targeting 1.1, not 1.0): packages can declare their own config-settings in a tool.scikit-build.config-setting table, giving users a documented, package-level interface instead of raw CMake defines.

[tool.scikit-build.config-setting."zmq.prefix"]
help = "Prefix to search for libzmq"
env = "ZMQ_PREFIX"          # env > -C > default

[tool.scikit-build.config-setting."zmq.libzmq"]
default = "system"

[tool.scikit-build.cmake.define]
ZMQ_PREFIX = {config-setting = "zmq.prefix"}   # forwarded to CMake; dropped when unset

[[tool.scikit-build.overrides]]
if.config-setting."zmq.libzmq" = "bundled"     # matches the resolved value
cmake.define.ZMQ_LIBZMQ = "ON"

Notes:

  • The declaration table is popped from the raw TOML like overrides (not a settings field, not an override target); values resolve before override processing so if.config-setting sees them.
  • Declared keys are whitelisted in ConfSource (new extra_keys) and get "did you mean" suggestions; skbuild.-prefixed custom keys stay rejected, and unknown-key strict-config behavior is otherwise unchanged.
  • Declarations are pyproject-only (rejected in overrides, extra settings, and entry-point config) and gated on minimum-version >= 1.1.
  • Types: str and bool (strtobool semantics); repeated -C values error. A choices key for enumerated values was cut to keep the initial surface minimal (a code comment notes how to re-add it).
  • The CMake binding is the cmake.define = {config-setting = "..."} reference form only; an earlier inline cmake = declaration alias was dropped as redundant.
  • Also fixes a pre-existing crash where a malformed non-table cmake value raised AttributeError (in the force_auto_cmake lookup) instead of the normal conversion error; the new resolution helpers are guarded the same way.

Beyond CI: verified end-to-end through the real build_wheel hook that the env var and -C spellings land in CMake identically and the override fires.

@henryiii

Copy link
Copy Markdown
Collaborator Author

Dropping a review point from the simplification work.

🤖 AI text below 🤖

Unifying {config-setting = ...} with the {env = ...} annotation resolver (altitude's top finding) — a real architectural point, but it means threading resolved values into the generic source-conversion layer; too large a redesign for this pass

@henryiii
henryiii force-pushed the config-setting-declarations branch from 8ccfee3 to ee3a812 Compare July 22, 2026 19:37
@henryiii
henryiii marked this pull request as ready for review July 27, 2026 14:47
henryiii added 7 commits July 30, 2026 15:55
Add a tool.scikit-build.config-setting table letting packages declare
their own config-settings, passed via -C name=value or a bound
environment variable (env > -C > default). Values reach CMake through an
inline cmake alias or a cmake.define {config-setting = ...} reference
(dropped when unset), and drive overrides via if.config-setting, which
matches the resolved value. Declared keys are exempt from strict-config
validation with typo suggestions; the feature is gated on
minimum-version >= 1.1.

Also guard the raw cmake-table lookups so a malformed non-table value
reaches the normal conversion error instead of an AttributeError.

Closes #1468

Assisted-by: ClaudeCode:claude-fable-5
CI shallow clones resolve __version__ to 0.1.dev1, so the backend-too-old
check fired before the config-setting gate. Pin the version like the
gate-ok test and assert the gate's message.

Assisted-by: ClaudeCode:claude-fable-5
The cmake.define = {config-setting = "..."} reference form covers the
same need with one obvious spelling and no extra precedence rule.

Assisted-by: ClaudeCode:claude-fable-5
Keeps the initial 1.1 surface to help/type/default/env; a comment in
config_settings.py records what re-adding it entails.

Assisted-by: ClaudeCode:claude-fable-5
Generate the declaration entry schema from the dataclass, fold the
triplicated post-override handling into one helper, and drop a
duplicated test constant.

Assisted-by: ClaudeCode:claude-fable-5
Assisted-by: ClaudeCode:claude-opus-4.8
No `from __future__ import annotations` here, but bare `dict`/`list`
are fine at runtime on 3.9+, matching skbuild_model.py.

Assisted-by: ClaudeCode:claude-opus-4.8
@henryiii
henryiii force-pushed the config-setting-declarations branch from ee3a812 to ca92800 Compare July 30, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant