Skip to content

Commit

Permalink
More intuitive metadata when not all authors/maintainers have email a…
Browse files Browse the repository at this point in the history
…ddresses
  • Loading branch information
takluyver committed Feb 14, 2025
1 parent e7c4239 commit 71cc0e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ def name_is_valid(name) -> bool:
def pep621_people(people, group_name='author') -> dict:
"""Convert authors/maintainers from PEP 621 to core metadata fields"""
names, emails = [], []
names_without_emails = False
for person in people:
if not isinstance(person, dict):
raise ConfigError("{} info must be list of dicts".format(group_name))
Expand All @@ -796,11 +797,15 @@ def pep621_people(people, group_name='author') -> dict:
if 'name' in person:
email = str(Address(person['name'], addr_spec=email))
emails.append(email)
elif 'name' in person:
if 'name' in person:
names.append(person['name'])
if 'email' not in person:
names_without_emails = True

res = {}
if names:
# The -Email fields include names (name <email>), so are preferred if
# everyone in the list provides an email address.
if names_without_emails:
res[group_name] = ", ".join(names)
if emails:
res[group_name + '_email'] = ", ".join(emails)
Expand Down
3 changes: 2 additions & 1 deletion flit_core/tests_core/samples/pep621/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ authors = [
{name = "Sir Röbin", email = "[email protected]"}
]
maintainers = [
{name = "Sir Galahad"}
{name = "Sir Galahad"},
{name = "Sir Bedevere", email = "[email protected]"}
]
readme = "README.rst"
license = {file = "LICENSE"}
Expand Down
3 changes: 3 additions & 0 deletions flit_core/tests_core/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def test_load_pep621():
'mock;extra=="test"and(python_version<\'3.6\')',
}
assert inf.metadata['author_email'] == "Sir Röbin <[email protected]>"
assert 'author' not in inf.metadata # Skipped in favour of author_email
assert inf.metadata['maintainer_email'] == "Sir Bedevere <[email protected]>"
assert inf.metadata['maintainer'] == "Sir Galahad, Sir Bedevere"
assert inf.entrypoints['flit_test_example']['foo'] == 'module1:main'
assert set(inf.dynamic_metadata) == {'version', 'description'}

Expand Down

0 comments on commit 71cc0e5

Please sign in to comment.