-
Notifications
You must be signed in to change notification settings - Fork 149
Description
I'd like to propose adding a feature from gpep517: --config-json. This is a replacement for --config-setting/-C that allows specification of the configure settings as a JSON object in a string. This is more flexible than the -C version, both allowing advanced use cases that are allowed by the PEP but not by most tools, as well as being ideal for piping through from tools. PEP 517 allows any dict here, but pip/build/uv have not taken advantage of that (expect for build's API, which does). cibuildwheel could likely use this, mapping its TOML config settings into this option. It also would be useful for testing, as currently backends like scikit-build-core either have to use the Python API or a gpep517 to test things that are beyond a simple string mapping. (I know about this tool because someone noticed that bools weren't working in config-settings, so I asked how they managed that and they said they were using gpep517).
Design:
- I think using JSON is a simple, cross-language string format. Another option would be Python via literal_eval, but I think JSON is more universal across languages.
- I'm fine with the name
--config-jsonfromgpep517, but I don't really have opinions here, happy with whatever. - I think taking a string is simpler than taking a filename, especially for scripting (which I assume is the main use case).
- What happens when you specify both needs to be specified. It could be an error, or we could merge, with one overriding the other. Not sure which should override which; I'd be fine with an error if both specified TBH.
I'd like some feedback from pip/uv maintainers, since if we add this here, it is conceivable that other frontends might eventually be expected to add it too, especially if backends start expecting nested structures or bool/ints. As well as pip is also a frontend choice for cibuildwheel, and I'm adding native uv soon too.
Example using cibuildwheel:
[tool.cibuildwheel.config-settings]
build.targets = ["ext1", "ext2"]could transform to
python -m build --config-json '{"build": {"targets": ["ext1", "ext2"}}'While today it has to be:
[tool.cibuildwheel.config-settings]
"build.targets" = ["ext1", "ext2"]which is expanded as
python -m build --config-setting=build.targets=ext1 --config-setting=build.targets=ext2(scikit-build-core has to expand dots manually to mimic the full nested structure of the TOML config, as anything you can pass in TOML you can pass as --config-setting except top-level arrays)