8000 [PEP 771] Experimental implementation of supporting [] disabling default extras by astrofrog · Pull Request #1 · wheelnext/pip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[PEP 771] Experimental implementation of supporting [] disabling default extras #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: pep_771
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
from pip._internal.utils.urls import path_to_url
from pip._internal.vcs import is_url, vcs

EXPLICIT_EMPTY_EXTRAS = 'explicit-no-default-extras'

__all__ = [
"install_req_from_editable",
"install_req_from_line",
"parse_editable",
"EXPLICIT_EMPTY_EXTRAS"
]

logger = logging.getLogger(__name__)
Expand All @@ -48,7 +51,11 @@ def _strip_extras(path: str) -> Tuple[str, Optional[str]]:
path_no_extras = m.group(1)
extras = m.group(2)
else:
path_no_extras = path
if '[]' in path:
extras = f'[{EXPLICIT_EMPTY_EXTRAS}]'
path_no_extras = path.replace('[]', '')
else:
path_no_extras = path

return path_no_extras, extras

Expand Down
14 changes: 8 additions & 6 deletions src/pip/_internal/resolution/legacy/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
InstallRequirement,
check_invalid_constraint_type,
)
from pip._internal.req.constructors import EXPLICIT_EMPTY_EXTRAS
from pip._internal.req.req_set import RequirementSet
from pip._internal.resolution.base import BaseResolver, InstallRequirementProvider
from pip._internal.utils import compatibility_tags
Expand Down Expand Up @@ -552,12 +553,13 @@ def add_req(subreq: Requirement, extras_requested: Iterable[str]) -> None:
set(req_to_install.extras) - set(dist.iter_provided_extras())
)
for missing in missing_requested:
logger.warning(
"%s %s does not provide the extra '%s'",
dist.raw_name,
dist.version,
missing,
)
if missing != EXPLICIT_EMPTY_EXTRAS:
logger.warning(
"%s %s does not provide the extra '%s'",
dist.raw_name,
dist.version,
missing,
)

available_requested = sorted(
set(dist.iter_provided_extras()) & set(req_to_install.extras)
Expand Down
14 changes: 8 additions & 6 deletions src/pip/_internal/resolution/resolvelib/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
install_req_from_line,
)
from pip._internal.req.req_install import InstallRequirement
from pip._internal.req.constructors import EXPLICIT_EMPTY_EXTRAS
from pip._internal.utils.direct_url_helpers import direct_url_from_link
from pip._internal.utils.misc import normalize_version_info

Expand Down Expand Up @@ -515,12 +516,13 @@ def iter_dependencies(self, with_requires: bool) -> Iterable[Optional[Requiremen
valid_extras = self.extras.intersection(self.base.dist.iter_provided_extras())
invalid_extras = self.extras.difference(self.base.dist.iter_provided_extras())
for extra in sorted(invalid_extras):
logger.warning(
"%s %s does not provide the extra '%s'",
self.base.name,
self.version,
extra,
)
if extra != EXPLICIT_EMPTY_EXTRAS:
logger.warning(
"%s %s does not provide the extra '%s'",
self.base.name,
self.version,
extra,
)

for r in self.base.dist.iter_dependencies(valid_extras):
yield from factory.make_requirements_from_spec(
Expand Down
4 changes: 3 additions & 1 deletion src/pip/_internal/resolution/resolvelib/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name

from pip._internal.req.constructors import install_req_drop_extras
from pip._internal.req.constructors import install_req_drop_extras, EXPLICIT_EMPTY_EXTRAS
from pip._internal.req.req_install import InstallRequirement

from .base import Candidate, CandidateLookup, Requirement, format_name
Expand Down Expand Up @@ -128,6 +128,8 @@ class SpecifierWithoutExtrasRequirement(SpecifierRequirement):
def __init__(self, ireq: InstallRequirement) -> None:
assert ireq.link is None, "This is a link, not a specifier"
self._ireq = install_req_drop_extras(ireq)
if ireq.extras:
self._ireq.extras = {EXPLICIT_EMPTY_EXTRAS}
self._equal_cache: Optional[str] = None
self._hash: Optional[int] = None
self._extras = frozenset(canonicalize_name(e) for e in self._ireq.extras)
Expand Down
Loading
0