scikit-build-core icon indicating copy to clipboard operation
scikit-build-core copied to clipboard

Override `if` Option Around CMake Build Type?

Open srilman opened this issue 2 years ago • 3 comments

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.editable when 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 set cmake.build-type="Debug" by just using pip 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-type to 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 of wheel.exclude or wheel.include.

Thoughts? If you recommend a different approach for either situation, please let me know

srilman avatar Dec 31 '23 04:12 srilman

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.

henryiii avatar Jan 01 '24 15:01 henryiii

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.

henryiii avatar Jan 01 '24 16:01 henryiii

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.

srilman avatar Jan 01 '24 17:01 srilman