Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More intuitive metadata when not all authors/maintainers have email addresses #721

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading