flit icon indicating copy to clipboard operation
flit copied to clipboard

Wrong/misleading metadata if multiple maintainers are set

Open stefan6419846 opened this issue 1 year ago • 10 comments

At pypdf, we recently added a second maintainer:

[project]
name = "pypdf"
authors = [{ name = "Mathieu Fenniak", email = "[email protected]" }]
maintainers = [{ name = "stefan6419846" }, { name = "Martin Thoma", email = "[email protected]" }]

This leads to some strange/misleading metadata files:

Metadata-Version: 2.3
Name: pypdf
Version: 5.3.0
Summary: A pure-python PDF library capable of splitting, merging, cropping, and transforming PDF files
Author-email: Mathieu Fenniak <[email protected]>
Maintainer: stefan6419846
Maintainer-email: Martin Thoma <[email protected]>

I would have expected something like this:

Metadata-Version: 2.3
Name: pypdf
Version: 5.3.0
Summary: A pure-python PDF library capable of splitting, merging, cropping, and transforming PDF files
Author-email: Mathieu Fenniak <[email protected]>
Maintainer: stefan6419846, Martin Thoma
Maintainer-email: [email protected]

stefan6419846 avatar Feb 10 '25 11:02 stefan6419846

I agree that's a bit confusing. It does seem to be what the spec for interpreting pyproject.toml metadata says:

If only name is provided, the value goes in Author or Maintainer as appropriate. ... If both email and name are provided, the value goes in Author-email or Maintainer-email as appropriate, with the format {name} <{email}>.

Old versions of the metadata spec have Author-Email as a required field, and that has a more defined structure, so filling that is preferred if possible. I think the metadata (output) format is barely designed for multiple authors/maintainers, though, let alone mixing names with & without email addresses.

Maybe there's enough wiggle room there to do something like this: 🤔

Maintainer: stefan6419846, Martin Thoma
Maintainer-email: Martin Thoma <[email protected]>

takluyver avatar Feb 10 '25 12:02 takluyver

Thanks for the answer.

I think the metadata (output) format is barely designed for multiple authors/maintainers, though, let alone mixing names with & without email addresses.

Strangely enough, the pyproject.toml spec apparently considers this valid, thus indicating that there should at least be some defined mapping.

For me as the maintainer, I do not have a strong opinion. On the other hand, I know that some popular tools like pip-licenses (of which I am using a forked version myself to partially automate stuff and where I stumbled upon this initially) retrieve the maintainer from the Maintainer field and fall back to Maintainer-email otherwise. Thus, at least having all the defined maintainer names on the Maintainer field sounds like something which would at least cover/improve this use case.

stefan6419846 avatar Feb 11 '25 16:02 stefan6419846

Apparently, this leads to some interesting side effects on PyPI as well, where my name is set as the maintainer, but linking to the e-mail address of Martin ...

stefan6419846 avatar Feb 12 '25 13:02 stefan6419846

I've opened #721 for this. It should ensure that if anyone in the list doesn't provide an email address, all the names go in the Author/Maintainer metadata.

takluyver avatar Feb 14 '25 15:02 takluyver

Thanks. Having a quick look at the proposed PR, this looks fine for me.

stefan6419846 avatar Feb 15 '25 11:02 stefan6419846

I'm not sure it should be changed in flit. This does look like an existing issue with PyPI, see https://github.com/pypi/warehouse/issues/9400#issuecomment-1369149125.

Most are in agreement that PyPI should simply concatenate the metadata from email and non-email fields. I.e. for the original example it would be stefan6419846, Martin Thoma <[email protected]>.

Another argument against changing it in flit is that the current output matches that of other backends like hatch and setuptools. So it would be surprising and might even complicate the resolution of the PyPI issue if flit were to change it now.

cdce8p avatar Feb 15 '25 17:02 cdce8p

Thanks for the heads up. It doesn't exactly look like that PyPI issue is going to be resolved any time soon, though. I might post on discuss.python.org to see if we can get this resolved.

takluyver avatar Feb 17 '25 09:02 takluyver

Here's the thread for that discussion: https://discuss.python.org/t/combining-author-maintainer-names-emails-in-core-metadata/81011

takluyver avatar Feb 17 '25 10:02 takluyver

Here's the thread for that discussion: https://discuss.python.org/t/combining-author-maintainer-names-emails-in-core-metadata/81011

Thanks for starting the discussing again! Let's see if it can reach a resolution this time. Anyway, as the current behavior matches that of other build backends, it might be worth deferring #721 for now.

Would be awesome to have a new release with PEP 639 support soon.

cdce8p avatar Feb 17 '25 10:02 cdce8p

Yup, I agree, I'll keep this as is for now and make a new release. I think #721 is probably more or less what we want to do, but I'd rather not release that and then change the logic again if the discussion goes in a different direction.

takluyver avatar Feb 17 '25 11:02 takluyver