Convert setup.py metadata to pyproject.toml#
pyproject.toml’s [project] metadata is the standard place to find a project metadata.
Historically this was on setup.py, but it had plenty of problems.
Now, you can write all of a project’s metadata in pyproject.toml,
see the specification.
All plone and collective python distributions are using setup.py to keep each project’s metadata.
zope.meta created a script to move the metadata from setup.py to pyproject.toml.
In plone.meta this script from zope.meta has been adapted to suit the needs of the Plone ecosystem.
Conversion#
To convert the metadata do the following:
cd $REPOSITORY
uvx --from plone.meta setup-to-pyproject .
i.e. go to your repository and run the setup-to-pyproject script from plone.meta.
This will automatically create a commit on your repository with the changes.
Note
Please review them carefully to ensure that the conversion was done properly.
Ideally setup.py should look like this:
from setuptools import setup
# See pyproject.toml for package metadata
setup()
Issues link#
setup-to-pyproject accepts an optional argument: --issues.
This option is to customize the issues link displayed on PyPI related to the project.
It accepts the following options:
own: use the repository itself as the issue trackerURL: provide a custom URL that will be used verbatim
None: if no value is provided
Products.CMFPloneissue tracker is used
Clean up#
Run some tooling tox run -e test to ensure that the conversion worked.
Note
It might be that the license field in project.license within pyproject.toml is broken.
Please have a look at valid license expressions to solve it.
Re-configure the repository with plone.meta to ensure that the project metadata is kept:
cd $REPOSITORY
uvx --from plone.meta config-package branch=current .
Make sure to review the commit generated by config-package.