Open virtuald opened 2 weeks ago
Hm, maybe I spoke too soon, this appears to work from plugin initialize function:
build_config = self.build_config.build_config
if "exclude" in build_config:
build_config.append("CMakeLists.txt")
else:
build_config["exclude"] = ["CMakeLists.txt"]
... but this seems unintentional and it probably isn't something that should be relied on to work?
Ok, this works, but once again it seems pretty brittle:
build_config = self.build_config.build_config
wheel_config = build_config.get("targets", {}).get("wheel", {})
if "exclude" in wheel_config:
wheel_config["exclude"] += to_exclude
elif "exclude" in build_config:
build_config["exclude"] += to_exclude
else:
build_config["exclude"] = to_exclude
This probably comes up a lot when trying to write hatch plugins that compile native code. Let's say that you're writing a cmake plugin for hatch, you would want the build hook to be able to automatically exclude CMakeLists.txt (and probably the .cpp files too) from the built wheel without the user needing to manually add it to their
pyproject.toml
.