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 Oct 3, 2022
1 parent f46a2d5 commit 7e55700
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 @@ -302,11 +302,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 @@ -323,13 +324,13 @@ def _format_requirement(
required_by = set()
if hasattr(ireq, "_source_ireqs"):
required_by |= {
_comes_from_as_string(src_ireq.comes_from, from_dir=from_dir)
_comes_from_as_string(src_ireq.comes_from, from_dir=out_dir)
for src_ireq in ireq._source_ireqs
if src_ireq.comes_from
}

if ireq.comes_from:
required_by.add(_comes_from_as_string(ireq.comes_from, from_dir=from_dir))
required_by.add(_comes_from_as_string(ireq.comes_from, from_dir=out_dir))

required_by |= set(getattr(ireq, "_required_by", set()))

Expand Down

0 comments on commit 7e55700

Please sign in to comment.