I recently uploaded my first Python package to PyPI. The relevant parts of pyproject.toml
are defined as follows (full file available here):
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "jutility"
version = "0.0.4"
license = {text = "MIT License"}
authors = [
{name = "Jake Levi", email = "jakelevi@hotmail.co.uk"},
]
# ...
[project.urls]
homepage = "https://github.com/jakelevi1996/jutility"
After installing this package with the command python3 -m pip install -U jutility
, I run the command python3 -m pip show jutility
, and get the following output:
Name: jutility
Version: 0.0.4
Summary: Collection of Python utilities intended to be useful for machine learning research and experiments
Home-page:
Author:
Author-email: Jake Levi <jakelevi@hotmail.co.uk>
License: MIT License
Location: /usr/local/lib/python3.10/dist-packages
Requires: matplotlib, numpy, Pillow
Required-by:
Notably, the Home-page
and Author
fields are empty in the output from pip show
, although they seem to be defined in pyproject.toml
.
How should I change pyproject.toml
to make these fields display properly in the pip show
output?
Version-wise, I built and uploaded these packages to PyPI on my Windows 10 PC with Python 3.7.6, but I also tried downloading and installing this package and displaying the pip show
output from a Google Colab notebook with Python 3.10.11. The package works completely as expected in the Colab notebook, but I get the same pip show
output with empty Home-page
and Author
fields. I'd just like to know what I need to change in order to get these fields to display properly.
There is a simple solution to populating the Author
field in pip show mypackage
, using only pyproject.toml
(IE without having to make a separate setup.cfg
file). The clue is in the full pyproject.toml
specification, specifically in the authors
/maintainers
section:
- If only name is provided, the value goes in Author or Maintainer as appropriate.
- If only email is provided, the value goes in Author-email or Maintainer-email 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}>.
- Multiple values should be separated by commas.
It follows that the the following pyproject.toml
configuration should populate Author
field with just the author-name, and populate the Author-email
field with just the email address:
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
...
authors = [
{name = "First McLast"},
{email = "firstymclast@example.com"},
]
...
IE name
and email
are in separate brackets.
Result (Python 3.10.12, setuptools=76.0.0
, pip==25.0.1
):
$ python -m pip install -e .; python -m pip show mypackage
...
Author: First McLast
Author-email: firstymclast@example.com
...
Also, the Home-page
field now also appears to be populated. Maybe this is just something that was fixed in a more recent version of Python 3.10.12/setuptools
/pip
/etc.