Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
ReveStobinson opened this issue Jul 29, 2024 · 1 comment
Open
1 task done

Comments

@ReveStobinson
Copy link

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
@ReveStobinson ReveStobinson added enhancement Needs Triage Issues that need to be evaluated for severity and status. labels Jul 29, 2024
@abravalheri
Copy link
Contributor

abravalheri commented Aug 5, 2024

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

I think this would be doable. Would you like to provide a PR? The relevant code resides in https://github.com/pypa/setuptools/blob/main/setuptools/config/_apply_pyprojecttoml.py (if not, then https://github.com/pypa/setuptools/blob/main/setuptools/config/pyprojecttoml.py).

@abravalheri abravalheri added help wanted and removed Needs Triage Issues that need to be evaluated for severity and status. labels Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants