Fix: Scope registry URL resolution to per-requirements file #13947
+114
−1
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.
What are you trying to accomplish?
Dependabot was resolving package versions globally across all requirements files, ignoring per-file
--extra-index-urldirectives. Whenrequirements_cpu.txtspecified PyTorch's CPU index andrequirements_gpu.txtspecified the CUDA index, Dependabot would query both indexes, pick the highest version (e.g.,2.9.1+cu126), and apply it to both files—breaking the CPU build.This change scopes registry URL collection to only the requirements files where each dependency actually appears.
Core change:
PackageRegistryFinder#requirements_filesnow filters based ondependency.requirementsinstead of returning all requirements files.Anything you want to highlight for special attention from reviewers?
Backward compatibility is maintained for subdependencies (no requirements) by falling back to all requirements files when
requirement_file_namesis empty.How will you know you've accomplished your goal?
Added test cases covering:
requirements_cpu.txtonly → uses CPU index exclusivelyrequirements_gpu.txtonly → uses GPU index exclusivelyChecklist
Original prompt
This section details on the original issue you should resolve
<issue_title>Dependabot computes and applies updates globally instead of per requirements.txt file</issue_title>
<issue_description>### Is there an existing issue for this?
Package ecosystem
pip
Package manager version
Not applicable, but pip 25.3
Language version
Python 3.10
Manifest location and content before the Dependabot update
/requirements_cpu.txt/requirements_gpu.txtdependabot.yml content
Updated dependency
/requirements_cpu.txt/requirements_gpu.txtWhat you expected to see, versus what you actually saw
I expect no change, these were the latest versions already.
/requirements_cpu.txt/requirements_gpu.txtIn particular, this breaks:
This index
https://download.pytorch.org/whl/cpudoes not contain2.9.1+cu126, it contains2.9.1+cpu.Native package manager behavior
The
--extra-index-urlaffects the whole requirements file, but each requirements file is separate.https://pip.pypa.io/en/stable/cli/pip_install/#install-extra-index-url
Images of the diff or a link to the PR, issue, or logs
Excerpt from the logs:
Actual PR: keras-team/keras#21983
Full log: https://github.com/keras-team/keras/actions/runs/20723600023/job/59493606324
The logs show that dependabot resolves the latest version of
torchglobally by looking at bothhttps://download.pytorch.org/whl/cpuandhttps://download.pytorch.org/whl/cu126and combining the versions found. Becausecu126>cpuis infers that2.9.1+cu126is the latest version and applies that to both requirement files.However, the correct behavior is:
requirements_cpu.txt, resolve the latesttorchversion fromhttps://download.pytorch.org/whl/cpu, which is2.9.1+cpu, and apply that torequirements_cpu.txtonlyrequirements_gpu.txt, resolve the latesttorchversion fromhttps://download.pytorch.org/whl/cu126, whi...💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.