Skip to content

Commit

Permalink
Make annotation req file paths relative to the output file
Browse files Browse the repository at this point in the history
  • Loading branch information
AndydeCleyre committed Jun 16, 2022
1 parent e182c21 commit e496d34
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions piptools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,12 @@ def _format_requirement(
hashes: Optional[Dict[InstallRequirement, Set[str]]] = None,
) -> str:
ireq_hashes = (hashes if hashes is not None else {}).get(ireq)
from_dir = (
out_dir = (
os.getcwd()
if not self.write_relative_to_output or self.dst_file.name == "-"
if self.dst_file.name == "-"
else os.path.dirname(os.path.abspath(self.dst_file.name))
)
from_dir = out_dir if self.write_relative_to_output else os.getcwd()
line = format_requirement(
ireq,
marker=marker,
Expand All @@ -310,12 +311,12 @@ def _format_requirement(
required_by = set()
if hasattr(ireq, "_source_ireqs"):
required_by |= {
_comes_from_as_string(src_ireq, from_dir=from_dir)
_comes_from_as_string(src_ireq, from_dir=out_dir)
for src_ireq in ireq._source_ireqs
if src_ireq.comes_from
}
elif ireq.comes_from:
required_by.add(_comes_from_as_string(ireq, from_dir=from_dir))
required_by.add(_comes_from_as_string(ireq, from_dir=out_dir))

if required_by:
if self.annotation_style == "split":
Expand Down

0 comments on commit e496d34

Please sign in to comment.