hatch-mypyc icon indicating copy to clipboard operation
hatch-mypyc copied to clipboard

feature request: conditional building

Open NiklasRosenstein opened this issue 10 months ago • 3 comments

I'm not exactly sure how this would be best implemented, but it would be neat if there would be an option to enable/disable this plugin based on some external condition (maybe an env var being set?). This is because when using uv sync, it will build the wheel with the plugin enabled, and that takes a significant amount of time.

NiklasRosenstein avatar Feb 06 '25 00:02 NiklasRosenstein

https://hatch.pypa.io/latest/config/build/#conditional-execution

ofek avatar Feb 06 '25 00:02 ofek

Ah, indeed this looks like exactly what I was looking for. But I'm missing something:

[tool.hatch.build.targets.wheel.hooks.mypyc]
dependencies = ["hatch-mypyc"]
enable-by-default = false
require-runtime-dependencies = true
require-runtime-features = ["dev"]

Using HATCH_BUILD_HOOK_ENABLE_MYPYC=true uv build doesn't enable the hook.

And using this configuration instead (which is closer to the example in the documentation), it's used always.

[tool.hatch.build.targets.wheel.hooks.mypyc]
dependencies = ["hatch-mypyc"]
require-runtime-dependencies = true
require-runtime-features = ["dev"]

[tool.hatch.build.hooks.mypyc]
enable-by-default = false

I'd appreciate another hint

NiklasRosenstein avatar Feb 06 '25 12:02 NiklasRosenstein

Same problem here. I did not manage to disable the mypyc hook from the environment either.

ddaanet avatar Oct 23 '25 10:10 ddaanet