Add CLI flag for rendering non-VCS files as relative paths. #702
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 is another stab at solving #204.
Adds a new --files-relative-to flag that can be used to tell pip-compile to
render paths relative to the given directory. In the interest of backwards
compatibility, the current behavior (rendering absolute paths using
file:///
)remains unchanged by default.
The main idea here is the same as @orf's changes in #507. Given the current architecture of pip-tools' interactions with pip, it's difficult to maintain context of the original path that was provided in a
requirements.in
. What we can do relatively easily, however,is change the logic for rendering
file://
-dependencies to write them relative to a given directory.Current Behavior (Unchanged by Default)
Behavior with New Flag
Differences relative to #507:
file://
dependencies should be rendered relative toos.cwd()
. In Make editable requirements use relative paths where appropriate. #507 (comment), @davidovich expressed some concern that that might not be correct in all cases. In the spirit of refusing the temptation to guess, this PR makes relative path rendering an explicit opt-in choice via a new--files-relative-to
CLI flag (I'm not particularly attached to that name if others have ideas for it).file://
syntax. Most of the functions in urllib seem to really want to write absolute paths, so rather than implement my own url formatting, this currently just renders-e <path>
without any url scheme. This seems to work for me locally but I'm not sure what the implications are for, e.g., windows.Changelog-friendly one-liner: Added support for writing non-VCS directories using relative paths.
Contributor checklist