mirror of https://github.com/pypa/pip
Merge b4f1883e96
into a15dd75d98
This commit is contained in:
commit
5480fbbc19
|
@ -475,22 +475,14 @@ def _handle_no_binary(
|
|||
option: Option, opt_str: str, value: str, parser: OptionParser
|
||||
) -> None:
|
||||
existing = _get_format_control(parser.values, option)
|
||||
FormatControl.handle_mutual_excludes(
|
||||
value,
|
||||
existing.no_binary,
|
||||
existing.only_binary,
|
||||
)
|
||||
FormatControl.handle_no_binary(value, existing)
|
||||
|
||||
|
||||
def _handle_only_binary(
|
||||
option: Option, opt_str: str, value: str, parser: OptionParser
|
||||
) -> None:
|
||||
existing = _get_format_control(parser.values, option)
|
||||
FormatControl.handle_mutual_excludes(
|
||||
value,
|
||||
existing.only_binary,
|
||||
existing.no_binary,
|
||||
)
|
||||
FormatControl.handle_only_binary(value, existing)
|
||||
|
||||
|
||||
def no_binary() -> Option:
|
||||
|
@ -507,7 +499,12 @@ def no_binary() -> Option:
|
|||
'disable all binary packages, ":none:" to empty the set (notice '
|
||||
"the colons), or one or more package names with commas between "
|
||||
"them (no colons). Note that some packages are tricky to compile "
|
||||
"and may fail to install when this option is used on them.",
|
||||
"and may fail to install when this option is used on them. "
|
||||
'When using ":all:", packages can be excluded from ":all:" by prefixing '
|
||||
'their name with tilde "~", for example --no-binary=:all:~numpy '
|
||||
"indicate to pip to install all packages using source dist with the "
|
||||
"exception of numpy which can be installed using either a whl or tar.gz "
|
||||
"file.",
|
||||
)
|
||||
|
||||
|
||||
|
@ -525,7 +522,12 @@ def only_binary() -> Option:
|
|||
'disable all source packages, ":none:" to empty the set, or one '
|
||||
"or more package names with commas between them. Packages "
|
||||
"without binary distributions will fail to install when this "
|
||||
"option is used on them.",
|
||||
"option is used on them. "
|
||||
'When using ":all:", packages can be excluded from ":all:" by prefixing '
|
||||
'their name with tilde "~", for example --only-binary=:all:~asciitree '
|
||||
"indicate to pip to install all packages using wheels with the "
|
||||
"exception of asciitree which can be installed using either a whl or "
|
||||
"tar.gz file.",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,22 @@ class FormatControl:
|
|||
def __repr__(self) -> str:
|
||||
return f"{self.__class__.__name__}({self.no_binary}, {self.only_binary})"
|
||||
|
||||
@classmethod
|
||||
def handle_no_binary(cls, value: str, existing: "FormatControl") -> None:
|
||||
cls.handle_mutual_excludes(
|
||||
value,
|
||||
existing.no_binary,
|
||||
existing.only_binary,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def handle_only_binary(cls, value: str, existing: "FormatControl") -> None:
|
||||
cls.handle_mutual_excludes(
|
||||
value,
|
||||
existing.only_binary,
|
||||
existing.no_binary,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def handle_mutual_excludes(value: str, target: Set[str], other: Set[str]) -> None:
|
||||
if value.startswith("-"):
|
||||
|
@ -47,9 +63,6 @@ class FormatControl:
|
|||
target.clear()
|
||||
target.add(":all:")
|
||||
del new[: new.index(":all:") + 1]
|
||||
# Without a none, we want to discard everything as :all: covers it
|
||||
if ":none:" not in new:
|
||||
return
|
||||
for name in new:
|
||||
if name == ":none:":
|
||||
target.clear()
|
||||
|
@ -64,9 +77,12 @@ class FormatControl:
|
|||
result.discard("source")
|
||||
elif canonical_name in self.no_binary:
|
||||
result.discard("binary")
|
||||
elif ":all:" in self.only_binary:
|
||||
elif (
|
||||
":all:" in self.only_binary
|
||||
and ("~" + canonical_name) not in self.only_binary
|
||||
):
|
||||
result.discard("source")
|
||||
elif ":all:" in self.no_binary:
|
||||
elif ":all:" in self.no_binary and ("~" + canonical_name) not in self.no_binary:
|
||||
result.discard("binary")
|
||||
return frozenset(result)
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@ def test_comma_separated_values() -> None:
|
|||
({"fred"}, {":all:"}, "fred", frozenset(["source"])),
|
||||
(set(), {"fred"}, "fred", frozenset(["binary"])),
|
||||
({":all:"}, {"fred"}, "fred", frozenset(["binary"])),
|
||||
# nothing in binary except foo as binary or source
|
||||
({":all:", "~foo"}, set(), "bar", frozenset(["binary"])),
|
||||
({":all:", "~foo"}, set(), "foo", frozenset(["binary", "source"])),
|
||||
],
|
||||
)
|
||||
def test_fmt_ctl_matches(
|
||||
|
|
Loading…
Reference in New Issue