Make setup.cfg the runtime dependency source for tests and enforce runtime-dep placement in macros#4532
Draft
Copilot wants to merge 3 commits into
Draft
Make setup.cfg the runtime dependency source for tests and enforce runtime-dep placement in macros#4532Copilot wants to merge 3 commits into
setup.cfg the runtime dependency source for tests and enforce runtime-dep placement in macros#4532Copilot wants to merge 3 commits into
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/2c4bea7b-f6c0-4322-8f6e-b4f7e4d7190b Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update setup.cfg to be single source of truth for runtime dependencies
Make May 14, 2026
setup.cfg the runtime dependency source for tests and enforce runtime-dep placement in macros
Signed-off-by: Ryan Northey <ryan@synca.io>
dd564f5 to
b65b835
Compare
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.
This change removes the remaining dependency drift point between
setup.cfgandtests/BUILD: runtime deps now flow frominstall_requiresinto test targets automatically. It also adds a structural guard so runtime deps cannot be attached directly totoolshed_librarywhen they belong insetup.cfg.Macro semantics: runtime deps now come from
setup.cfg_runtime_req_canonical_name()and_runtime_req_deps(namespace)inpy/pants-toolshed/macros.py.toolshed_tests()now prepends runtime deps derived frompy/<namespace>/setup.cfg [options] install_requires.pytest-abstracts,pytest-asyncio,pytest-iters,pytest-patches) are unchanged.Structural guard in
toolshed_library()toolshed_library()now raisesValueErrorwhendependencies=includes runtime req targets that overlap with that package’sinstall_requiresmapping (//py/deps:reqs#<canonical>).py/<namespace>/setup.cfgto prevent lockfile pins from leaking into wheelRequires-Dist.Repo-wide
tests/BUILDcleanup//py/deps:reqs#...entries frompy/*/tests/BUILDwhere those deps are already declared insetup.cfg install_requires.toolshed_tests("<namespace>")where applicable.Targeted compatibility follow-ups
envoy.code.checkto tolerate older resolved package variants in sandboxed test contexts.mypy-abstractsplugin imports to keep typechecking stable under current resolve behavior.Original prompt
Context
This is the structural follow-up to PRs #4527 (aio.core fix), the CI wheel-METADATA verifier PR, and the 18-package BUILD-cleanup PR. With those in place, every
py/<pkg>/setup.cfginstall_requirescorrectly drives the wheel's runtimeRequires-Dist(via synthetic_publish__*targets generated by thetoolshed_publish_reqsplugin), and everypy/<pkg>/tests/BUILDre-declares the same runtime deps as//py/deps:reqs#*sopants testcan resolve imports.That duplication is the residual smell:
setup.cfg install_requiresandtests/BUILD dependencies=will inevitably drift, and the original bug class — pinned//py/deps:reqs#*attached to the library target leaking into the wheel — is still syntactically possible. This PR closes both gaps by making the macros derive runtime test deps fromsetup.cfgand refuse to accept runtime deps on the library target.Goal
setup.cfg install_requiresbecomes the single source of truth for runtime dependencies. It drives:Requires-Dist(already, viatoolshed_publish_reqssynthetic_publish__*targets on thepublishresolve — unchanged).toolshed_testsfromsetup.cfgand mapped to//py/deps:reqs#<canonical>on thedepsresolve).toolshed_libraryrefuses any//py/deps:reqs#*entry in itsdependencies=argument, with an error pointing the caller atsetup.cfg.Concrete changes
1. Add a helper in
py/pants-toolshed/macros.pyMirror the existing
_publish_req_dependencies(namespace)but resolve to the pinneddeps-resolve targets instead of the synthetic publish targets. Reuse the existing_setup_cfg_install_requires,_canonical_name, and the same name-extraction logic that_publish_req_target_namealready uses (split on<>=!~[;). Suggested implementation:2. Make
toolshed_libraryreject runtime depstoolshed_library'sdependencies=should no longer accept//py/deps:reqs#*entries. Those are runtime/test reqs and belong insetup.cfg. Raise aValueErrorwith a helpful message:3. Make
toolshed_testsauto-derive runtime deps fromsetup.cfgtoolshed_testsshould prepend_runtime_req_deps(namespace)to the dependency list it already builds, so test targets pick up everything ininstall_requiresautomatically. Callers continue to passdependencies=for test-only deps (mocks, fixtures, etc.), but no longer need to re-declare runtime reqs. Existingpytest-abstracts/pytest-asyncio/pytest-iters/pytest-patchesadditions stay as-is.