Override `if` Option Around CMake Build Type?
Is it possible to add some additional if key overrides that are not defined in PEP 508? I'm hoping to see 2 new build types:
if.editablewhen the package is installed in editable mode. I mainly want this because I like to set up my CMake config to use the Debug release type in development, so it would be helpful to have a method to setcmake.build-type="Debug"by just usingpip install -e .... We can also use it to make the recommended editable install command shorter:
pip install --no-build-isolation --config-settings=editable.rebuild=true -ve.
to
pip install --no-build-isolation -ve.
if.cmake-build-typeto set different options for different build modes. There are situations where I would like to use Cython or MyPyC to "compile" Python files in certain build modes like Release, but not in others like Debug or RelWithDebInfo. In those situations, I need the ability to include or exclude the compiled Python files in the final wheel by changing the value ofwheel.excludeorwheel.include.
Thoughts? If you recommend a different approach for either situation, please let me know
I think this is a good idea, though the second example of the first one isn't necessary, you can set editable.rebuild without overrides and it will only affect editable builds.
We aren't limited to PEP 508, probably could reword that portion of the docs a bit. We already have environment variable support there.
We might be able to use the skbuild stage (https://scikit-build-core.readthedocs.io/en/latest/cmakelists.html#accessing-information) instead of just editable true/false. Would have to think about it a bit more, but I think it would be possible.
Is the second idea, if.cmake-build-type, possible as well? I ask because it seems kind of circular. We can currently set the build type via cmake.build-type in pyproject.toml. Furthermore, we can modify it to another value depending on the environment. So how would it work if we had a situation like this:
[tool.scikit-build]
cmake.build-type = "Debug"
[[tool.scikit-build.overrides]]
if.env.BUILD_RELEASE = 1
cmake.build-type = "Release"
[[tool.scikit-build.overrides]]
if.any.cmake-build-type = "Debug"
if.any.cmake-build-type = "RelWithDebInfo"
wheel.include = ["*.h"]
I don't know how the evaluation of settings works, but it seems like we would have to perform 1 pass for the environment settings, and then another pass for the build type. It seems like it would be difficult to explain and get the semantics correct.