-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support optional builds #112
Comments
So this would mean, that on installation failure a hook is called, which would allow me to handle the error? This would be awesome. I currently handle this using try/except inside my |
Yes, this is exactly what this refers to. |
One thing that could lead to problems is the |
Good point. I have the information about platforms (in https://github.com/scikit-build/scikit-build-core/blob/main/src/scikit_build_core/resources/known_wheels.toml ) so could do that, at least as an option. |
An alternative I thought of when I was working on this for |
I think we do the following to make this mostly possible with the new
pip install -e -Copt.compile="true" Would match [[tool.scikit-build.overrides]]
opt.compile = ".+" (API might need a little work there, maybe would be an inline table with options or something) We could also add |
Hm so if I understand you correctly:
A user would be able to override the behavior while installing using something like The only other thing I would require is the ability to enforce the compile based on environment variables. In my case I do enforce the build when I am in a known packaging environment: packaging = "1" in {
os.environ.get("CIBUILDWHEEL", "0"),
os.environ.get("CONDA_BUILD", "0"),
os.environ.get("PIWHEELS_BUILD", "0"),
os.environ.get("RAPIDFUZZ_BUILD_EXTENSION", "0"),
}
if packaging:
run_setup(True)
else:
try:
run_setup(True)
except BaseException:
show_message(
"WARNING: The C extension could not be compiled, speedups are not enabled.",
"Failure information, if any, is above.",
"Retrying the build without the C extension now.",
)
run_setup(False)
show_message(
"WARNING: The C extension could not be compiled, speedups are not enabled.",
"Plain-Python build succeeded.",
) |
No, I think it's the exact opposite part of the solution. This would give you the ability to enforce the compile based on environment variables. It doesn't handle the try/fail case. Basically this would solve the if/else part above, but not the try/except. But I think the try/except part solution might be easy to get to from this. For example, maybe you could set one to be a fallback on failure or similar... So if you had this: packaging = "1" in {
os.environ.get("CIBUILDWHEEL", "0"),
os.environ.get("CONDA_BUILD", "0"),
os.environ.get("PIWHEELS_BUILD", "0"),
os.environ.get("RAPIDFUZZ_BUILD_EXTENSION", "0"),
}
if packaging:
run_setup(True)
else:
run_setup(False) You could write this: [tool.scikit-build]
wheel.cmake = false
[[tool.scikit-build.overrides]]
if.env.CIBUILDWHEEL = "1"
wheel.cmake = true
[[tool.scikit-build.overrides]]
if.env.CONDA_BUILD = "1"
wheel.cmake = true
[[tool.scikit-build.overrides]]
if.env.PIWHEELS_BUILD = "1"
wheel.cmake = true
[[tool.scikit-build.overrides]]
if.env.RAPIDFUZZ_BUILD_EXTENSION = "1"
wheel.cmake = true (Probably should come up with a way to do OR...) |
Thanks for the clarification. Yes I completely misunderstood which part this was going to solve. |
This supports skipping the CMake build. This can be used with overrides to make packages that have a pure Python implementation (#112). Signed-off-by: Henry Schreiner <[email protected]>
See discussion at rapidfuzz/Levenshtein#65 for use case. I think this is what it would look like: [tool.scikit-build]
wheel.cmake = true
[[tool.scikit-build.overrides]]
if.any.no-system-cmake = "known-wheel"
if.any.failed = true
wheel.cmake = false
[[tool.scikit-build.overrides]]
if.any.env.CIBUILDWHEEL = "1"
if.any.env.CONDA_BUILD = "1"
if.any.env.PIWHEELS_BUILD = "1"
if.any.env.RAPIDFUZZ_BUILD_EXTENSION = "1"
wheel.cmake = true
error-message = "failed to build C++ Extension in a packaged build" |
Hi there! |
We already support a pure fallback via environment variables. And if you upload a pure Python wheel, that will always be used if a native wheel is not available, no backend involvement needed. This proposal was to have a way to allow a failed build to turn into a pure Python install, as well as a way to select behavior based on if a compiled cmake/ninja wheel is available for the platform. |
Thank you, @henryiii! To clarify further: yes, trying to compile a wheel but then receiving a pure one upon failure on the unavailability of compilers or package managers, etc., say, if MSVC or vcpkg are not installed on Windows, is sort of what we are trying to look out for local development purposes, but if it's possible not to attempt the compilation altogether, that's great to hear as well – we can very well try that for CI, as @cringeyburger mentions.
Is there somewhere where this environment variable you mentioned is documented, though? I couldn't find it anywhere (side note: maybe a dedicated section/page on "building packages with optional extension modules" as such would be nice), and then I looked at the CHANGELOG entries and found P.S. We considered uploading a pure Python wheel in the past in addition to compiled ones, but we didn't want to offer users a higher tier of support for unsupported platforms because of some dependencies we know are not present/broken on, say, manylinux arm64 yet, or are tricky to compile from their sdist (or in some cases impossible to compile if they ship a broken sdist) |
We probably need a whole page on overrides rather than just a section; you'd do it with overrides. For example: [tool.scikit-build]
wheel.cmake = false
[[tool.scikit-build.overrides]]
if.any.env.CIBUILDWHEEL = true
if.any.env.CONDA_BUILD = true
if.any.env.PIWHEELS_BUILD = true
if.any.env.MY_CUSTOM_BUILD_EXTENSION = true
wheel.cmake = true For opt-in binary builds.
All configuration is available via envvar too, so that actually would work too. The tasks at the top are what need to happen to allow control over failed builds. Each one will likely look a bit like #812. |
One of the steps for #112. --------- Signed-off-by: Henry Schreiner <[email protected]>
Adding a `fail = true` setting. One possible use: ```toml [[tool.scikit-build.overrides]] if.python-version = ">=3.13" fail = true ``` This will be nicer once we allow customizing the error message. See #112. Signed-off-by: Henry Schreiner <[email protected]>
See #112. Signed-off-by: Henry Schreiner <[email protected]>
See #112. This includes `.format()` so that items can be added here later in a backward-compatible way. --------- Signed-off-by: Henry Schreiner <[email protected]>
I think this can be supported with a few more override settings. We could provide:
if.failed
: If the build fails, the config settings gets rerun, and if any match this, the new configuration is used. This only happens once.if.system-cmake
andif.cmake-wheel
.message.after-failure
: This will display if the build fails.fail = true
: This will fail the build. Might be only allowed in overrides.Should we allow
failed
to take the condition of failure? I think the conditions would be"configure"
,"build"
, and"install"
. Though maybe it's better to just wait until someone asks for the ability to differentiate?The cmake one would trigger if you were not on a platform with a known cmake wheel and there's no sufficient CMake present, or always if there's no system CMake. If this matches,
then it affects if cmake is requested, as well.
This is what pure-python on non-supported CMake system would look like:
Or if the build fails:
Custom message on failure:
I think this would add a lot of flexibility; for an unrelated example, you could fail on unsupported Pythons:
I'm looking at a way to allow the cmake wheel to trigger the bootstrapping feature, and I think this would be a step in that direction too.
This is a very rough draft of what I'm thinking.
The text was updated successfully, but these errors were encountered: