Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Migrate from setup.py to pyproject.toml

How to migrate a package repository

  • Replace setup.py by pyproject.toml

  • Say pip uninstall lino followed by pip install -e lino

  • Check whether you need a __version__ variable.

How to get the version

Old:

from .setup_info import SETUP_INFO
__version__ = SETUP_INFO["version"]

New:

from xyz import __version__

For other metadata than the version, see usage example in synodal/make_code.py:

from importlib import metadata
description = metadata.metadata("xyz")['Summary']

How to release a new version after migrating from setup to pyproject

Instead of saying inv sdist release, say:

# repo should be clean:
git st
# see current version:
hatch version
# increase either micro or minor part of version number:
hatch version micro
# or (if month has chnaged since last version)
hatch version minor
# remove old dist files:
rm dist/*
python -m build
twine check dist/*
twine upload dist/*
git diff
git ci -am "release to pypi"; git push

How to get other metadata than the version

For example lino.core.site.Site.get_used_libs() wants the “url”, which is now in the [project.urls] table, under “Homepage” or “Repository” key