Skip to content

Commit

Permalink
Parse each comma-separated --extra argument to pip-compile as multipl…
Browse files Browse the repository at this point in the history
…e entries (#1493)
  • Loading branch information
AndydeCleyre committed Sep 28, 2021
1 parent 388589b commit 83406cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import os
import shlex
import sys
Expand Down Expand Up @@ -422,6 +423,8 @@ def cli(
)
)

extras = tuple(itertools.chain.from_iterable(ex.split(",") for ex in extras))

if extras and not setup_file_found:
msg = "--extra has effect only with setup.py and PEP-517 input formats"
raise click.BadParameter(msg)
Expand Down
14 changes: 9 additions & 5 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1933,9 +1933,16 @@ def test_one_extra(fake_dists, runner, make_module, fname, content):


@pytest.mark.network
@pytest.mark.parametrize(
"extra_opts",
(
pytest.param(("--extra", "dev", "--extra", "test"), id="singular"),
pytest.param(("--extra", "dev,test"), id="comma-separated"),
),
)
@pytest.mark.parametrize(("fname", "content"), METADATA_TEST_CASES)
@pytest.mark.xfail(is_pypy, reason="https://github.com/jazzband/pip-tools/issues/1375")
def test_multiple_extras(fake_dists, runner, make_module, fname, content):
def test_multiple_extras(fake_dists, runner, make_module, fname, content, extra_opts):
"""
Test passing multiple `--extra` params.
"""
Expand All @@ -1944,10 +1951,7 @@ def test_multiple_extras(fake_dists, runner, make_module, fname, content):
cli,
[
"-n",
"--extra",
"dev",
"--extra",
"test",
*extra_opts,
"--find-links",
fake_dists,
meta_path,
Expand Down

0 comments on commit 83406cb

Please sign in to comment.