Boolean fields in `config_settings` cause traceback if passed booleans
mgorny opened this issue · 1 comments
mgorny commented
According to the documentation, cmake.verbose
and install.strip
are of boolean type. However, if I pass an actual boolean value rather than a string, I get a traceback:
$ pip install -q gpep517 'scikit-build-core[pyproject]'
$ python -m gpep517 build-wheel --config-json '{"install.strip": false}' --output-fd 1 --wheel-dir dist
2024-04-16 17:11:46,348 gpep517 INFO Building wheel via backend scikit_build_core.build
+ Exception Group Traceback (most recent call last):
| File "<frozen runpy>", line 198, in _run_module_as_main
| File "<frozen runpy>", line 88, in _run_code
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/gpep517/__main__.py", line 429, in <module>
| sys.exit(main())
| ^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/gpep517/__main__.py", line 425, in main
| return func(args)
| ^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/gpep517/__main__.py", line 215, in build_wheel
| print(build_wheel_impl(args, args.wheel_dir), file=out)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/gpep517/__main__.py", line 207, in build_wheel_impl
| wheel_name = backend.build_wheel(str(wheel_dir), args.config_json)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/build/__init__.py", line 31, in build_wheel
| return _build_wheel_impl(
| ^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/build/wheel.py", line 136, in _build_wheel_impl
| settings_reader = SettingsReader(pyproject, config_settings or {}, state=state)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/skbuild_read_settings.py", line 253, in __init__
| self.settings = self.sources.convert_target(ScikitBuildSettings)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/sources.py", line 581, in convert_target
| raise ExceptionGroup(msg, errors)
| ExceptionGroup: Failed converting tool.scikit-build (1 sub-exception)
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/sources.py", line 535, in convert_target
| prep[field.name] = self.convert_target(
| ^^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/sources.py", line 581, in convert_target
| raise ExceptionGroup(msg, errors)
| ExceptionGroup: Failed converting tool.scikit-build.install (1 sub-exception)
| Field: tool.scikit-build.install
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/sources.py", line 550, in convert_target
| tmp = source.convert(simple, field.type)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/sources.py", line 386, in convert
| return _process_bool(item)
| ^^^^^^^^^^^^^^^^^^^
| File "/tmp/pyzmq/.venv/lib/python3.11/site-packages/scikit_build_core/settings/sources.py", line 76, in _process_bool
| return value.strip().lower() not in {"0", "false", "off", "no", ""}
| ^^^^^^^^^^^
| AttributeError: 'bool' object has no attribute 'strip'
| Field tool.scikit-build.install.strip
+------------------------------------
henryiii commented
Interesting, I didn’t realize there was a tool that allowed you to pass anything other than strings and lists. That’s why handling for explicit types was never added. It would be easy to add, though.