You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make declared config-settings available as template keys in path settings #1607
With 1.1's declared config-settings a project can define a typed, env-bound knob (torch.variant, env PYTORCH_VARIANT) and switch settings on it through if.config-setting overrides. What it cannot do is substitute the value: there is no {torch.variant} key for build-dir or editable.rebuild-dir, so keying the build tree on the knob means one override block per value.
For PyTorch that could be seven blocks (cpu, cu126, cu130, cu132, rocm7.1, rocm7.2, xpu) that each repeat the same two lines with the value spliced in, and the list has to be edited every time a toolkit is added or retired. The overrides still have a job (selecting a preset, a build type), but the directory keying wants one line: build-dir = "build/{torch.variant}".
Proposal: add the resolved declared settings to the formatting namespace of the templated path settings, under their declared name (dotted names are fine as format keys when passed via a mapping, or they could be exposed as {config-setting.torch.variant} / a sanitized form). An unset setting with no default should format as empty or error, whichever matches current practice for the other keys. The values are already resolved before build-dir is formatted, so this looks like a pure plumbing change in the same pyproject_format call.
Related: #1606 asks for a {build_dir} key in the same namespace.
Drafted with an AI assistant from our measurements against 1.1.1, reviewed and edited by me.
Okay, assuming #1637 goes in (I like that one), the three requests together look like this:
🤖 AI text below 🤖
All three requests (#1606, #1607, #1608) work for PyTorch on this branch. I tested at the settings and metadata level only. I did not do a full CMake build.
Changes to PyTorch (in ~/git/scikit-build-projects/pytorch, new branch skbc-format-keys from current upstream main, not committed):
The dependencies provider now takes a variant setting. If PYTORCH_EXTRA_INSTALL_REQUIREMENTS is not set, it reads the requirements for that CUDA variant from the table in .github/scripts/generate_binary_build_matrix.py.
Results, from calling the real get_build_dir, get_editable_rebuild_dir and prepare_metadata_for_build_wheel:
Input
build-dir
rebuild-dir
Requires-Dist
nothing
build/cpu
build/cpu/install/<tag>
base only
-C torch.variant=cu132
build/cu132
build/cu132/install/<tag>
CUDA 13.2 set
PYTORCH_VARIANT=cu134
build/cu134
build/cu134/install/<tag>
CUDA 13.4 set
SKBUILD_BUILD_DIR=/tmp/elsewhere
/tmp/elsewhere
/tmp/elsewhere/install/<tag>
follows variant
PYTORCH_VARIANT=a/b
clear error: must be one path component
So -C and the environment variable now give the same build tree and the same dependencies, which was the split described in #1608. If both are set, the environment variable wins, as documented.
They work together in one direction only. A declared knob can select the variant label, but the label cannot drive anything else. I tested this with SettingsReader on a small pyproject:
variant-label is a built-in setting that can only be set from config-settings or an override. It is not a declared config-setting, so the new plumbing cannot see it.
What this means for PyTorch:
torch.variant must stay the main knob. Users should not pass -Cvariant-label directly, because then build-dir and the dependencies do not follow it.
{wheel_tag} does not contain the variant label. A build or rebuild directory keyed on the tag alone puts all variants in the same directory, so key it on {variant} too, as my adaptation does.
Dynamic-metadata providers get the knob, but not the label or the [variant.variants.<label>] properties. Under PEP 817, the dependencies are exactly what changes between variants, so this is the next gap.
Possible follow-ups, in order of value:
Let variant-label take { config-setting = "torch.variant" }, the same form as cmake.define. This removes the per-variant override blocks.
Add a built-in {variant_label} format key, empty when no label is set. Then build-dir = "build/{variant_label}" works with no declared setting.
Activity
feat: add config_setting format key for declared config-settings
feat: add config_setting format key for declared config-settings
feat: add config_setting format key for declared config-settings
henryiii commentedon Nov 25, 2026
Okay, assuming #1637 goes in (I like that one), the three requests together look like this:
🤖 AI text below 🤖
All three requests (#1606, #1607, #1608) work for PyTorch on this branch. I tested at the settings and metadata level only. I did not do a full CMake build.
Changes to PyTorch (in
~/git/scikit-build-projects/pytorch, new branchskbc-format-keysfrom current upstream main, not committed):The
dependenciesprovider now takes avariantsetting. IfPYTORCH_EXTRA_INSTALL_REQUIREMENTSis not set, it reads the requirements for that CUDA variant from the table in.github/scripts/generate_binary_build_matrix.py.Results, from calling the real
get_build_dir,get_editable_rebuild_dirandprepare_metadata_for_build_wheel:build/cpubuild/cpu/install/<tag>-C torch.variant=cu132build/cu132build/cu132/install/<tag>PYTORCH_VARIANT=cu134build/cu134build/cu134/install/<tag>SKBUILD_BUILD_DIR=/tmp/elsewhere/tmp/elsewhere/tmp/elsewhere/install/<tag>PYTORCH_VARIANT=a/bSo
-Cand the environment variable now give the same build tree and the same dependencies, which was the split described in #1608. If both are set, the environment variable wins, as documented.henryiii commentedon Nov 25, 2026
And, a followup for using
variant-label:🤖 AI text below 🤖
They work together in one direction only. A declared knob can select the variant label, but the label cannot drive anything else. I tested this with
SettingsReaderon a small pyproject:torch.variant→ override setsvariant-label = "cu132"format-keysboth resolve.format-keys.variant = { config-setting = "variant-label" }references undeclared config-setting 'variant-label'if.config-setting."variant-label" = "cu132"'variant-label' is not declaredvariant-labelis a built-in setting that can only be set from config-settings or an override. It is not a declared config-setting, so the new plumbing cannot see it.What this means for PyTorch:
torch.variantmust stay the main knob. Users should not pass-Cvariant-labeldirectly, because thenbuild-dirand the dependencies do not follow it.{wheel_tag}does not contain the variant label. A build or rebuild directory keyed on the tag alone puts all variants in the same directory, so key it on{variant}too, as my adaptation does.[variant.variants.<label>]properties. Under PEP 817, the dependencies are exactly what changes between variants, so this is the next gap.Possible follow-ups, in order of value:
variant-labeltake{ config-setting = "torch.variant" }, the same form ascmake.define. This removes the per-variant override blocks.{variant_label}format key, empty when no label is set. Thenbuild-dir = "build/{variant_label}"works with no declared setting.if.variant-labeloverride condition. This is less important once items 1 and 2 exist.Item 1 plus item 2 would let the label alone, or a knob mapped to it, drive the whole build. Tell me if you want me to start on any of these.