I don’t really make a distinction between “setuptools” and “bdist_wheel”, but either way what you are describing is worse than any of the alternatives I suggested, because it will only detect an issue if the sdist
build environment doesn’t match the wheel
build environment. That’s way too late in the process. It means end users (who can’t do anything about it) will start having pip install <x>
fail on them because the people who can make the change before a release don’t build an sdist then test building wheels from it on every other platform — they build and install all tests from source, and build wheels and sdists directly from source independent of one another (and on the same platform anyway), before uploading.
The only things we can do are:
- have
bdist_wheel
pull anything static fromPKG-INFO
first, ignoring any values that are generated bysetup.py
that might be in conflict with those inPKG-INFO
- Detect whether a value is static or dynamic at sdist build time and raise an exception. We can know that anything in
setup.cfg
is static, but without parsing the AST we won’t know if anything passed tosetup()
is. We’ll have to assume anything passed is dynamic, which will likely break a lot of builds.
Neither of these is especially desirable from a user experience or adoption point of view. If we go with the exception mode, we’d need to delay the roll-out of support for this until we have an AST-parser/reader that covers a sufficiently significant quantity of the setup.py
files out there that we won’t be breaking everyone’s builds on day one. And AST parsing is going to need upkeep, because AFAIK the AST is not stable.
On the other hand, if we allow basically all fields to be dynamic, we can roll out today, and everyone with setup.cfg
files will opt in immediately. We can gradually add some AST parsing heuristics without worrying about being perfect, because the metadata upgrades will happen silently as our heuristic processing gets better. We also don’t have to worry quite so much about the AST parsing getting out-of-date, because we can fall back on “if we don’t understand the AST, warn and emit a bunch of dynamic fields”.
I don’t really understand what you mean by “the metadata value in a sdist is tool-defined if it’s marked as Dynamic
”. My proposal is that:
- In an sdist, a field with a value and
Dynamic
set should treat the value as a hint as to what the true value will be, but the canonical value (as it is in the current version of the PEP) requires a build to determine, because it is supplied by the backend dynamically. - In a wheel,
Dynamic
refers to the provenance of the metadata. If a field is markedDynamic
in a wheel, the associated value is canonical for the platform / context you are using (as it is today), but you know that it was the result of a calculation at build-time, and may not apply to other wheels built from the same source distribution.
No one is clamoring for this information, but we definitely have it at build time and as I mentioned in my comments I can think of some situations where it would be useful.
My original objection to this was that this is not really presented for human consumption anyway, so it doesn’t matter that much what it looks like, but I’ve changed my mind and actually find this compelling. Even if it’s not a human-centric format, it will almost certainly be read by humans more often than people will write new libraries to parse it. So, +1 for Dynamic
rather than Static
.