Skip to content

Commit

Permalink
Include extras when formatting a url direct reference
Browse files Browse the repository at this point in the history
  • Loading branch information
richafrank committed Jun 5, 2022
1 parent b9e38f4 commit 804395f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion piptools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def _build_direct_reference_best_efforts(ireq: InstallRequirement) -> str:

# If we get here then we have a requirement that supports direct reference.
# We need to remove the egg if it exists and keep the rest of the fragments.
direct_reference = f"{ireq.name.lower()} @ {ireq.link.url_without_fragment}"
formatted_extras = f"[{','.join(sorted(ireq.extras))}]" if ireq.extras else ""
direct_reference = (
f"{ireq.name.lower()}{formatted_extras} @ {ireq.link.url_without_fragment}"
)
fragments = []

# Check if there is any fragment to add to the URI.
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ def test_direct_reference_with_extras(runner):
)
out = runner.invoke(cli, ["-n", "--rebuild"])
assert out.exit_code == 0
assert "pip-tools @ git+https://github.com/jazzband/pip-tools@6.2.0" in out.stderr
assert (
"pip-tools[coverage,testing] @ git+https://github.com/jazzband/pip-tools@6.2.0"
in out.stderr
)
assert "pytest==" in out.stderr
assert "pytest-cov==" in out.stderr

Expand Down

0 comments on commit 804395f

Please sign in to comment.