Repository navigation
Warn when a tool.setuptools.dynamic field is not listed in project.dynamic - #5372
Open
VamikaSinghal wants to merge 1 commit into
Open
VamikaSinghal wants to merge 1 commit into
VamikaSinghal wants to merge 1 commit into
Conversation
…namic
Entries in `tool.setuptools.dynamic` are only used for fields that are
also listed in `project.dynamic`. Until now the other entries were
silently ignored, so e.g. a `dependencies = {file = ["requirements.txt"]}`
entry whose `dependencies` was forgotten in `project.dynamic` produced a
wheel without any `Requires-Dist`, with no indication of the mistake.
`_ConfigExpander` now emits a `SetuptoolsWarning` (`_UnlistedDynamic`)
for every such entry before the dynamic fields are expanded. The
`entry-points` entry is considered used when `scripts` or `gui-scripts`
are dynamic, as it is also their source. The behaviour otherwise stays
the same: the unlisted entry is still ignored.
Closes pypa#4523
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Entries in
tool.setuptools.dynamicare only used for fields that are also listed inproject.dynamic. Until now any other entry was silently ignored, so apyproject.tomllike the one from #4523built a wheel without any
Requires-Dist, with no indication of the mistake (the_MissingDynamicwarning only covers values given insetup.py).This PR adds a
SetuptoolsWarningsubclass,_UnlistedDynamic, which_ConfigExpanderemits for everytool.setuptools.dynamicentry whose field is not listed inproject.dynamic, right before the dynamic fields are expanded (setuptools/config/pyprojecttoml.py, one of the two places @abravalheri pointed to in #4523). Theentry-pointsentry counts as used whenscriptsorgui-scriptsare dynamic, since_obtain_entry_pointsreads it for those too. The behaviour is otherwise unchanged: the unlisted entry is still ignored, so no existing build breaks; the user just gets told why their metadata is missing.Building the example above with this branch now prints:
(
python -m build --no-isolation --wheelwith this checkout onPYTHONPATH; the resultingMETADATAstill has noRequires-Dist, as before.)Also included:
TestUnlistedDynamicinsetuptools/tests/config/test_pyprojecttoml.py: warning raised throughread_configurationandapply_configuration(and the value still ignored), no warning when everything is listed, and no false positive forentry-pointswhen onlyscripts/gui-scriptsare dynamic.docs/userguide/pyproject_config.rst(the warning's_SEE_DOCSpoints there).newsfragments/4523.feature.rst.Testing (macOS, Python 3.12, with the
test/coreextras installed by name sincetoxis not available here):I also ran the other test modules that use
tool.setuptools.dynamicfixtures (test_build_meta.py,test_config_discovery.py,test_sdist.py,test_bdist_wheel.py,test_editable_install.py,test_core_metadata.py): 585 passed, 5 skipped, 4 xfailed, 1 failed. The failure,TestCustomBuildPy::test_safeguarded_from_errors, fails identically on an unmodifiedmaincheckout in this environment (theSetuptoolsDeprecationWarningtext does not appear in pip 26.3's output), so it is unrelated to this change.Closes #4523
Pull Request Checklist
newsfragments/.(See documentation for details)
I used Claude Code to help prepare this change; I reviewed the diff and ran the checks above.
🤖 Generated with Claude Code