hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Hatchling strips self-referenced optional-dependencies from METADATA

Open LecrisUT opened this issue 5 months ago • 0 comments

In tmt we are using the following design

[project.optional-dependencies]
all = [
    "tmt[provision-virtual]",
    ... ,
    ]
provision-virtual = [
    "testcloud>=0.11.7",
    ]

And we are using the integration with the Fedora packaging to inject any additional dependencies in provision-virtual extra. The issue is that hatchling expands the dependencies of tmt[provision-virtual] in place instead of keeping it as-is, which creates a problem because on the Fedora packaging, the dependency tmt+all -> tmt+provision-virtual is no longer present, thus the additional dependencies that we are manually injecting are being lost.

I have checked on the scikit-build-core and we don't do that in-place expansion. So would like to know, is this behavior governed by a documented PEP or is it ill-defined right now? Also CC @henryiii if case you know about this.

https://github.com/pypa/hatch/blob/f16441ff03259a7c8f47eb6d03bd406213694f11/backend/src/hatchling/metadata/core.py#L1304-L1310

LecrisUT avatar Oct 01 '25 08:10 LecrisUT