#@ofek I'm not sure you saw my above
1 messages · Page 1 of 1 (latest)
my bad, missed that
metadata hooks come before everything else and the type of build in progress has no effect, metadata comes first and is treated specially because it's used for other stuff
you can however add dependencies with a custom build hook https://hatch.pypa.io/latest/plugins/build-hook/custom/
this method https://hatch.pypa.io/latest/plugins/build-hook/reference/#hatchling.builders.hooks.plugin.interface.BuildHookInterface.initialize can modify the options here for wheels https://hatch.pypa.io/latest/plugins/builder/wheel/#build-data
the version argument of the initialize method corresponds to https://hatch.pypa.io/latest/plugins/builder/wheel/#versions
Thanks @solid sierra . When you say metadata hooks come before anything else, it makes me think maybe there's a bug or missing use case that I'm running into. I have a metadata hook defined in my [tool.hatch.metadata.hook.custom] section. That hook has an update() method that that's where I modify my dependencies to be PyPI version pinned dependencies, to unpinned package_name @ internal dependencies. It mostly works.
However, if in a clean clone, I run hatch run test where my test script cd's into the directory where that pyproject.toml has the hook set, I see something like the following:
Creating environment: mynamespacepkg
Checking dependencies
Creating environment: test
Installing project in development mode
ERROR: Ignored the following versions that require a different python version: 0.3.0 Requires-Python <3.11,>=3.8
ERROR: Could not find a version that satisifies the requirement mypackage-foo==0.8.0 (from mynamespacepkg) ...
ERROR: No matching distribution found ...
It is definitely not calling my metadata hook.
However, if I now run hatch run test again, I see the very first thing that happens is my metadata hook's update() method gets called, followed by Checking dependencies and Syncing dependencies and everything works. I can see my hook rewriting the dependencies.
So it's only the first call where hatch is initializing everything that fails. It seems like a code path where the metadata hook isn't getting called.
is there a way for me to reproduce or is this private?