Fix constraints path to be relative to requirements file location #61
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 #22 and #25: Constraints file path in requirements-out is now correctly calculated as a relative path from the requirements file's directory.
Problem
When and are in different directories, the generated requirements file referenced constraints with the wrong path, causing pip to fail.
Example from #22:
Before (broken):
requirements/plone.txtcontained:Pip interprets
-cpaths relative to the requirements file's directory, so it looked for:After (fixed):
requirements/plone.txtnow contains:Because both files are in
requirements/, the relative path is justconstraints.txt.Solution
Added path calculation logic in src/mxdev/processing.py:
This works for all scenarios:
constraints.txt../constraints.txtsubdir/constraints.txt../other/constraints.txtChanges
os.path.relpath()Test Coverage
Both tests demonstrate the bug and verify the fix.
cc @davisagli @gforcada