13

What is the correct format for supplying a name to a python package in a pyproject.toml?

pyproject.toml file

[project]
name = "foobar"
version = "0.0.1"

[build-system]
requires = ["setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"

A build called using python -m build results in the following error.

running check
warning: check: missing required meta-data: name, url
warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) should be supplied

Based on this reddit post question. I had the same issue.

polka
  • 1,383
  • 2
  • 25
  • 40
  • 2
    _setuptools_ does not accept the package info in `pyproject.toml`. Not yet. Either put this info in `setup.cfg`, or write a `setup.py`. -- Or switch to a different build back-end instead of setuptools, to one that reads package info in `pyproject.toml`, preferably one that is compatible with [PEP 621](https://peps.python.org/pep-0621/). – sinoroc Mar 17 '22 at 18:54
  • hey, so, thanks! But also, can you please answer the question by giving an example of how a setup.cfg would be structured with a pyproject.toml to work with setuptools? And/or list the build backends that would work? And or give a date/issue which might be when this functionality could work? – polka Mar 17 '22 at 19:41
  • 1
    you may refer to this answer https://stackoverflow.com/a/71237291/12368419 – cizario Mar 17 '22 at 20:10
  • Regarding PEP621 support in setuptools: https://discuss.python.org/t/help-testing-experimental-features-in-setuptools/13821 -- For the rest, including `setup.cfg` and a list of build back-ends that currently support PEP 621: https://stackoverflow.com/a/64151860 – sinoroc Mar 17 '22 at 21:32

2 Answers2

10

Update

At the time the question was asked, setuptools did not have support for writing its configuration in a pyproject.toml file (PEP 621). So it was not possible to answer the question.

Now and since its version 61.0.0, setuptools has support for PEP 621:


Original answer

It seems that you are trying to write a PEP 621-style pyproject.toml with the setuptools build back-end.

But, as of now, setuptools does not have support for PEP 621 yet. The work is ongoing:

Until PEP 621 support arrives in setuptools, one can:

sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • 1
    Currently exploring hatch and flit. Will update when I find a better alternative. – polka May 22 '22 at 21:13
  • 1
    @polka In the meantime, _setuptools_ (in version `61.0.0`) added experimental support for _PEP 621_. This means you can put the whole packaging configuration in `pyproject.toml`, while still keeping _setuptools_ as your build back-end. It is experimental, as mentioned, but you could give it a try. See here: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html – sinoroc May 22 '22 at 21:57
  • This is a great answer. My project has dependency on python3.6 which is not supported by `setuptools>=61.0.0`. My solution was to use Flit for PEP 621-compliant builds, but the `setup.cfg` + `pyproject.toml` + `setuptools` suggestion should also work. – Bill DeRose Jan 01 '23 at 23:20
0

If you are using Ubuntu, then according to this bug report

On Ubuntu 22.04 (Jammy) ensure the environment variable DEB_PYTHON_INSTALL_LAYOUT=deb_system before installing a PEP621 compliant project with pip and setuptools.

That is, do e.g.:

DEB_PYTHON_INSTALL_LAYOUT=deb_system pip install . 

instead of:

pip install .

Otherwise, the system may pick up the older version of setuptools (59.x) installed by apt even if you have upgraded setuptools in pip.

thor
  • 21,418
  • 31
  • 87
  • 173