mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Flexibile argument specification when specifying multiple cateogires. (#5606)
* Flexibile argument specification when specifying multiple categories. * fix lint * add test and news fragment.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fix ``--categories`` argument inconsistency between requirements command and install/sync by allowing comma seperated values or spaces.
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pipenv import environments
|
||||
@@ -21,6 +22,7 @@ from pipenv.cli.options import (
|
||||
uninstall_options,
|
||||
verbose_option,
|
||||
)
|
||||
from pipenv.utils.dependencies import get_lockfile_section_using_pipfile_category
|
||||
from pipenv.utils.environment import load_dot_env
|
||||
from pipenv.utils.processes import subprocess_run
|
||||
from pipenv.vendor.click import (
|
||||
@@ -779,11 +781,11 @@ def requirements(
|
||||
echo(" ".join([prefix, package_index["url"]]))
|
||||
|
||||
deps = {}
|
||||
categories_list = categories.split(",") if categories else []
|
||||
categories_list = re.split(r", *| ", categories) if categories else []
|
||||
|
||||
if categories_list:
|
||||
for category in categories_list:
|
||||
category = category.strip()
|
||||
category = get_lockfile_section_using_pipfile_category(category.strip())
|
||||
deps.update(lockfile.get(category, {}))
|
||||
else:
|
||||
if dev or dev_only:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
from pipenv.project import Project
|
||||
from pipenv.utils.internet import is_valid_url
|
||||
@@ -235,7 +236,7 @@ def categories_option(f):
|
||||
def callback(ctx, param, value):
|
||||
state = ctx.ensure_object(State)
|
||||
if value:
|
||||
for opt in value.split(" "):
|
||||
for opt in re.split(r", *| ", value):
|
||||
state.installstate.categories.append(opt)
|
||||
return value
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ def test_basic_category_install(pipenv_instance_private_pypi):
|
||||
|
||||
@pytest.mark.categories
|
||||
@pytest.mark.install
|
||||
def test_multiple_category_install(pipenv_instance_private_pypi):
|
||||
@pytest.mark.parametrize('categories', ["prereq other", "prereq, other"])
|
||||
def test_multiple_category_install(pipenv_instance_private_pypi, categories):
|
||||
with pipenv_instance_private_pypi() as p:
|
||||
c = p.pipenv('install six --categories="prereq other"')
|
||||
assert c.returncode == 0
|
||||
|
||||
Reference in New Issue
Block a user