The "Dynamic" Properties in PyProject

Fri 30 December 2022 by Moshe Zadka

When writing a pyproject.toml file, the project section is optional. However, if it does exist, two of its properties are required:

  • name
  • version

If these two properties are not there, the section will be ignored.

This is a lie. But it is not a big lie: it is almost true.

In general, if either of these two properties are not there, the section will be ignored. However, there is a way to indicate that either, or both, of these properties will be filled in by the build system later on.

This is done with dynamic.

For example

[project]
name = "my-package"
dynamic = ["version"]

This is the most common setting. However, it is possible to set dynamic to ["name", "version"] and avoid both parameters.