How to specify --python-tag
with Hatch?
#185
-
I assume this is something the build backend would support. I have a project that builds Unicode tables that match the Python version it is being installed on. So, when releasing, I build a python package for each supported Python version. They are all pure Python wheels, but each one contains a set of Unicode tables that matches the given Python distribution. With setup tools, all I did was: $ python3 setup.py bdist_wheel --python-tag py39 Using $ python3 -m build -w -C="--global-option=--python-tag" -C="--global-option=py310" It seems that if you try this with a project that uses a Hatch backend, this doesn't work. I imagine this is because the backend would need to support such input. Does Hatch support this already, and I just haven't found where yet? If not, is it something that could be added? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I got here when I was trying to figure out how to set The way to do this is to create a custom hook called from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomHook(BuildHookInterface):
def initialize(self, version, build_data):
build_data["infer_tag"] = True
build_data["pure_pyton"] = False And then in your [tool.hatch.build.targets.wheel.hooks.custom]
path = "hatch_build.py" This was extremely non-obvious but resulted in hatch building a platform specific wheel when run from Hopefully this helps a future traveller! |
Beta Was this translation helpful? Give feedback.
https://ofek.dev/hatch/dev/plugins/builder/#build-data