Closed orbisvicis closed 1 month ago
I've been learning more about how metadata works, and I now have a chance to review this with a better understanding.
In https://github.com/jaraco/jaraco.packaging/issues/17, I learned about how the switch from setup.py
/setup.cfg
style in Setuptools projects to pyproject.toml causes the metadata to be rendered differently. On setup.cfg
, the "author" and "email" are solicited separately and stored in the metadata separately. Consider the author fields in cheroot 10.0.0, for example.
These fields produce the following metadata:
~ @ pip-run cheroot==10 git+https://github.com/python/importlib_metadata@refs/pull/471/head -- -q
>>> import importlib_metadata as im
>>> md = im.metadata('cheroot')
>>> md['Author']
'CherryPy Team'
>>> md['author-email']
'team@cherrypy.dev'
And unfortunately, this patch renders that declaration as two separate individuals:
>>> md.authors
[Ident(name='CherryPy Team', email=None), Ident(name=None, email='team@cherrypy.dev')]
Similarly, have a look at pytest-ignore-flaky
, which declares two people.
~ @ pip-run pytest-ignore-flaky==2.2 git+https://github.com/python/importlib_metadata@refs/pull/471/head -- -q
WARNING: Did not find branch or tag 'refs/pull/471/head', assuming revision or ref.
>>> import importlib_metadata as im
>>> im.metadata('pytest-ignore-flaky').authors
[Ident(name='Eduardo Naufel Schettino', email=None), Ident(name='Marcos Alfredo Camargo Leal Pinto', email=None), Ident(name=None, email='schettino72@gmail.com'), Ident(name=None, email='marcos.alfredo@gmail.com')]
When I migrate these projects to pyproject.toml, they get the new format, with the name and email being stored in the *-Email
field, but until then, .authors
and .maintainers
is not producing what I'd expect (matching up names with emails and combining them).
Another issue I encountered was that my name, presumably because it contains a period, gets quoted:
~ @ pip-run git+https://github.com/jaraco/calendra git+https://github.com/python/importlib_metadata@refs/pull/471/head -- -q
WARNING: Did not find branch or tag 'refs/pull/471/head', assuming revision or ref.
>>> import importlib_metadata as im
>>> im.metadata('calendra').authors
[Ident(name='"Jason R. Coombs"', email='jaraco@jaraco.com')]
Notice the excess quoting of the name. The solution here should remove those quotes as they're not part of the declared metadata.
If we can address the above two concerns, I'd like to get this merged and available for use.
@orbisvicis Do you have plans to address the aforementioned issues?
In the jaraco.packaging.metadata module, I've implemented a quick and dirty routine to extract authors and emails from metadata, and that's what I've been using in my projects. I'd rather prefer we have something robust and tested in importlib metadata itself, but the current approach isn't acceptable. I'm going to close this for now, but I welcome a revival of the effort in the future. Just say the word and we can re-open this pull request, or feel free to file a new one, addressing the aforementioned concerns.
Backport of https://github.com/python/cpython/pull/108585. The first commit parameterizes the test example with
parameterized
rather thanhypothesis
, and omits the Hypothesis strategy. The second commit switches back to Hypothesis and includes the identity strategy. With this commit both PRs are equivalent.