Or will we say to a user who gets an order that doesn’t work for them that they have to switch backends?
different backends will produce different requirements
Dynamic metadata is not something that is transferable between backends. You can’t move a project with a dynamic field between backends today, and you won’t be able to after this PEP. I’m working on a way to allow users to implement dynamic metadata that works on multiple backends, but that is not in this PEP.
I think it’s important to note the backend can be the user, not just “some tool” we have to control. Hatchling, scikit-build-core, and setuptools (I think PDM too) all allow users to implement dynamic metadata themselves. If we take functionality away from the users, we should have good reason to. PEP 517 makes it clear that the limitations are there to benefit static tooling, not to apply arbitrary constraints on backends to try to control them.
The most extreme version would be to simply allow anything if dynamic was specified. This gives users full power, but this makes static analysis useless. The goal of the PEP is to balance static analysis and user control.
The version a) is that the static portion is guaranteed to be present. If you see "torch"
in the static dependencies, you can be sure that it is in the dependencies. This allows static analysis to gain the ability to detect it, and allows flexibility for the dynamic portion (which literally can be Python code implemented by the package author!) in determining how to present this in METADATA.
The version c) takes an arbitrary choice of appending only, which means that if you actually can’t use ["torch", "torch>=1.12"]
, you are now forced to abandon adding "torch"
as static so that tooling can tell you depend on torch and go full dynamic, as you have to today. A user or tool will not be allowed to do something different even if this fixes a bug. I fail to see why a static tool would significantly benefit from knowing that "torch"
comes first but can be followed by anything at all.
My preferred mechanism would be this:
- List items must be present and in the original static order. Static items cannot be removed.
- Backends are allowed to insert items (at any position)
- As a special case for dependencies, backends are allowed to tighten constraints on an existing item.
That would best support one of the main use cases (constraining an existing dependency), and be general enough that special rules aren’t needed per field. (the dependency one is two fields, dependencies and optional-dependencies). It also doesn’t add a requirement that static fields come first, which I don’t see any benefit for.
Deduplication is not allowed for static metadata, and is up to the backend within the limits above. You can’t remove an existing static item, but you can always choose to not add a duplicate item (that’s true even in the most strict version of the proposal, c) ).
Though if we really think c) is needed, I’m fine with that too (though the folks requesting pinning might need to verify they’d be okay with that - due to the concerns above, it looks like you could introduce unfixable bugs in resolution if you don’t give the backend (== user) any flexibility in fixing them).
which I have a PR to fix
I’ll try to review that soon! If the main problem is bugs and specification issues, maybe we should fix those.