Since I didn’t mention it earlier, I should note that I’m broadly in favour of this idea, but I share the concern raised by others that there are practical issues we need to work through to avoid encouraging the creation of artifact analysis tools that adopt an introspection approach that is simple, easy, and wrong.
I think the main way to tackle this would be for the PEP to explicitly allow build backends to mutate pyproject.toml when creating the sdist. I’m less worried about it for source directories, as there’s a simple self-selection process:
- for use within a project, established projects simply won’t adopt tools that don’t support the metadata input format that they use, while fans of a particular tool are likely to be willing to adapt their metadata input practices to conform to its limitations
- for broad analysis across multiple projects, tools already have to deal with all kinds of malformed input, so their authors aren’t likely to be tempted by attractive shortcuts when specs clearly spell out why the shortcut isn’t enough to cover the general case
In this initial iteration of the PEP, that could take the form of the following statement:
When build tools are constructing an sdist from a source directory they MUST delete the
[project]
table (if present) frompyproject.toml
. A future PEP will cover a standardised mechanism that allows inclusion of static project metadata in an sdist when that metadata will be identical across all wheels and local package installations derived from the sdist.
As my current expectation is that any such future PEP would allow sdists to include metadata in a format that looks more like wheel and installation DB metadata, requiring build tools to delete the [project]
table eliminates the potential for that table to become an attractive nuisance to authors of code that looks at sdists rather than source directories.
If we change our mind about that later, “build tools don’t need to delete the [project]
table from pyproject.toml any more” is a much more manageable policy change than “ouch, there are all these already published sdists with confusing [project]
tables that it’s now too late for us to do anything about”.