Consider the following:
# pyproject.toml
[build-system]
# ...
[project]
name = # ...
author = # ...
keywords = # ...
license = # ...
urls = # ...
classifiers = #...
requires-python = # ...
dynamic = ["version", "description", "readme"]
# setup.py
from setuptools import setup
def derive_version():
...
def derive_description():
...
def derive_readme():
...
setup(
version=derive_version(),
description=derive_description(),
long_description=derive_readme(), # unfortunately the nomenclature varies a bit,
# but PEP 621 text shows the equivalence.
)
After replacing the placeholders in the TOML with the actual data, this should give you a valid configuration[1].
It is not deprecated and it is a well-known/supported pattern.
(Also it if you have a build-system table in your pyproject.toml, adding a [project] table is optional, you can also keep using setup.py to configure your build - again not deprecated, supported and PEP 517-ready).
Remembering to add
os.path.dirname(__file__)tosys.pathif you need to do local imports. Sincesetup.pyis not directly run withpython setup.py, Python does not automatically add the directory containing the script tosys.path, as it does when you run scripts. ↩︎