Dynamic metadata populated by entry-points

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).


  1. Remembering to add os.path.dirname(__file__) to sys.path if you need to do local imports. Since setup.py is not directly run with python setup.py, Python does not automatically add the directory containing the script to sys.path, as it does when you run scripts. ↩︎

1 Like