Setuptools supports dynamic metadata for project properties in pyproject.toml
, and as a PEP517 backend, it also has the option to specify build requirements by implementing get_requires_for_build_wheel
. But I cannot figure out whether it uses the chance and does implement a way to specify build requirements based on configuration options, and if so, how to specify it in the pyproject.toml
.
I naively tried
[build-system]
requires = {file = "requirements-build.txt"}
but that understandably leads to pip complaining “This package has an invalid build-system.requires
key in pyproject.toml. It is not a list of strings.” And adding
[project]
dynamic = ["build-system.requires"]
also doesn't work, because the possible options of dynamic
are explicitly enumerated. I would be somewhat surprised if there wasn't an option for this, given that all the infrastructure elements are available, but how do I specify it?
After doing some of my own research this is not possible using setuptools, as the build-system requires specification states that these are the requirements to run setuptools. Implying that it will fail rather than starting to process dynamic values.
setuptools pyproject.toml documentation shows that it only supports the following dynamic data keys.
Additonally, PEP 518 specifies the following: