Repository navigation
Support PEP 808 (AKA "Including static values in dynamic metadata") - #2463
Draft
edgarrmondragon wants to merge 1 commit into
Draft
edgarrmondragon wants to merge 1 commit into
edgarrmondragon wants to merge 1 commit into
Conversation
edgarrmondragon
force-pushed
the
2443-pep-808
branch
2 times, most recently
from
October 7, 2026 01:12
6383c94 to
2b7a452
Compare
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
edgarrmondragon
force-pushed
the
2443-pep-808
branch
from
October 7, 2026 01:36
2b7a452 to
6ebdce6
Compare
edgarrmondragon
commented
Oct 7, 2026
Comment on lines
+65
to
+89
| ```toml tab="pyproject.toml" | ||
| [build-system] | ||
| requires = ["hatchling", "torch"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [project] | ||
| dependencies = ["torch", "packaging"] | ||
| dynamic = ["dependencies"] | ||
|
|
||
| [tool.hatch.metadata.hooks.custom] | ||
| pin-to-build-versions = ["torch=={exact}"] | ||
| ``` | ||
|
|
||
| ```python tab="hatch_build.py" | ||
| from importlib.metadata import version | ||
|
|
||
| from hatchling.metadata.plugin.interface import MetadataHookInterface | ||
|
|
||
|
|
||
| class PinHook(MetadataHookInterface): | ||
| def update(self, metadata): | ||
| for template in self.config["pin-to-build-versions"]: | ||
| name = template.split("==")[0] | ||
| metadata["dependencies"].append(template.format(exact=version(name))) | ||
| ``` |
Contributor
Author
There was a problem hiding this comment.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Links