python / importlib_metadata

Library to access metadata for Python packages
https://importlib-metadata.readthedocs.io
Apache License 2.0
123 stars 80 forks source link

pyproject.toml: Authors name is missing in meta data #424

Closed buhtz closed 1 year ago

buhtz commented 1 year ago

Hello,

my pyproject.toml looks like this

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "bitdemo"
version = '0.0.1alpha1'
requires-python = ">=3.8"
dependencies = [
    "PySimpleGUI"
]

authors = [
    {author = "Christian Buhtz", email = "c.buhtz@posteo.jp"}
]

I try to receive the authors name and email from package meta data via importlib.metadata.metadata().

>>> from importlib.metadata import metadata
>>> m = metadata('bitdemo')
>>> for i in m._headers:
...  print(i)
... 
('Metadata-Version', '2.1')
('Name', 'bitdemo')
('Version', '0.0.1a1')
('Author-email', 'c.buhtz@posteo.jp')
('Project-URL', 'homepage, https://codeberg.org/buhtz/bit_demo')
('Project-URL', 'documentation, https://somewhere')
('Project-URL', 'repository, https://codeberg.org/buhtz/bit_demo')
('Project-URL', 'changelog, https://codeberg.org/buhtz/bit_demo/CHANGELOG.md')
('Requires-Python', '>=3.8')
('Requires-Dist', 'PySimpleGUI')

As you can see the authors email is there but not his name.

I'm not sure anymore where I found that way of specifying the author:

authors = [
    {author = "Christian Buhtz", email = "c.buhtz@posteo.jp"}
]

Is there a better way?

buhtz commented 1 year ago

Got it myself. Always the same... Finding the answer while asking... :smile:

In the second line the word shouldn't be author but name.

authors = [
    {name = "Christian Buhtz", email = "c.buhtz@posteo.jp"}
     ^^^^
]

The result is

'Author-email': 'Christian Buhtz <c.buhtz@posteo.jp>'

It seems that name and email is combined.