Skip to content

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

@ReveStobinson

Description

@ReveStobinson

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

  • I agree to follow the PSF Code of Conduct

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions