setuptools icon indicating copy to clipboard operation
setuptools copied to clipboard

[FR] Warn when metadata field is defined as dynamic, but not marked in project.dynamic

Open ReveStobinson opened this issue 7 months ago • 1 comments

What's the problem this feature will solve?

A miss-specified pyproject.toml file that leaves out a dynamic field from the [project.dynamic] list, but still specifies that metadata field in [tool.setuptools.dynamic] will not warn the user of the missing field.

Take the following pyproject.toml file:

[project]
name = "package"
dynamic = ['version']  # "dependencies" accidentally omitted

[tool.setuptools.dynamic]
version = {file = "VERSION"}
dependencies = {file = ["requirements.txt"]}

The user has forgotten to put "dependencies" in the project.dynamic list. But when running any setuptools building or installation commands (pip install, python -m build, python setup.py sdist), there is no indication that something is wrong until the user is unable to run their code due to missing dependencies.

Describe the solution you'd like

If a field is defined in [tool.setuptools.dynamic], but it is missing from the list in [project.dynamic], warn the user when attempting to build or install the package (from the local file structure, it will be mostly unhelpful when installing from pypi).

A similar thing is done elsewhere: When a field is defined in the setup.py file and not noted as dynamic in the pyproject.toml, a _MissingDynamic warning is sent to the console when attempting to build the package (though not when attempting to install it).

Alternative Solutions

An error/failure to build the package could also be acceptable, especially since a mistake like this might not get noticed if development is taking place in a local environment that already has the necessary dependencies installed.

Additional context

I am aware of #4183, however I don't believe that we are requesting the same thing. What this is requesting is a warning for projects that use pyproject.toml exclusively, and a mistake has simply been made when writing the file.

Code of Conduct

  • [X] I agree to follow the PSF Code of Conduct

ReveStobinson avatar Jul 29 '24 16:07 ReveStobinson