Fix: Support requirements.txt files which contain a remote constraint file #16287
+95
−0
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
Fixes handling of remote constraint files in requirements.txt.
uv would fail with "Network connectivity is disabled" when trying to recompile a requirements.txt that contains a remote
--constraint
directive. This is required for AWS MWAA workflows where the constraint must be in the output file.Cause
When reading the output file for preferences, uv operates in offline mode.
When it would encounter the remote --constraint directive in the output file and try to process it, because it was in offline mode, it would fail with "Network connectivity is disabled".
Fix
The fix is to skip the constraints file in this case because it is not needed for preferences.
This does not affect actual resolution because in true offline mode, the resolution will still fail.
Test Code
There is a new test case
compile_with_remote_constraint_in_output
.It sets up a mock server for the constraints file, a mock requirement, then compiles it.
It verifies a successful output which constains the constraint.
It adds the constraint to the output (as per MWAA), then compiles it again.
It verifies successful output again, which would have failed previously.