Skip to content
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

Change when we warn about dependency conflicts during pip install #8590

Merged
merged 5 commits into from
Jul 17, 2020
Merged
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
31 changes: 22 additions & 9 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from typing import Iterable, List, Optional

from pip._internal.models.format_control import FormatControl
from pip._internal.operations.check import ConflictDetails
from pip._internal.req.req_install import InstallRequirement
from pip._internal.wheel_builder import BinaryAllowedPredicate

Expand Down Expand Up @@ -371,13 +372,14 @@ def run(self, options, args):
requirement_set
)

# Consistency Checking of the package set we're installing.
# Check for conflicts in the package set we're installing.
conflicts = None # type: Optional[ConflictDetails]
should_warn_about_conflicts = (
not options.ignore_dependencies and
options.warn_about_conflicts
)
if should_warn_about_conflicts:
self._warn_about_conflicts(to_install)
conflicts = self._determine_conflicts(to_install)

# Don't warn about script install locations if
# --target has been specified
Expand Down Expand Up @@ -419,6 +421,10 @@ def run(self, options, args):
except Exception:
pass
items.append(item)

if conflicts is not None:
self._warn_about_conflicts(conflicts)

installed_desc = ' '.join(items)
if installed_desc:
write_output(
Expand Down Expand Up @@ -498,16 +504,23 @@ def _handle_target_dir(self, target_dir, target_temp_dir, upgrade):
target_item_dir
)

def _warn_about_conflicts(self, to_install):
# type: (List[InstallRequirement]) -> None
def _determine_conflicts(self, to_install):
# type: (List[InstallRequirement]) -> Optional[ConflictDetails]
try:
package_set, _dep_info = check_install_conflicts(to_install)
return check_install_conflicts(to_install)
except Exception:
logger.error("Error checking for conflicts.", exc_info=True)
return
missing, conflicting = _dep_info
logger.error(
"Error while checking for conflicts. Please file an issue on "
"pip's issue tracker: https://github.com/pypa/pip/issues/new",
exc_info=True
)
return None

def _warn_about_conflicts(self, conflict_details):
# type: (ConflictDetails) -> None
package_set, (missing, conflicting) = conflict_details

# NOTE: There is some duplication here from pip check
# NOTE: There is some duplication here, with commands/check.py
for project_name in missing:
version = package_set[project_name][0]
for dependency in missing[project_name]:
Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/operations/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
MissingDict = Dict[str, List[Missing]]
ConflictingDict = Dict[str, List[Conflicting]]
CheckResult = Tuple[MissingDict, ConflictingDict]
ConflictDetails = Tuple[PackageSet, CheckResult]

PackageDetails = namedtuple('PackageDetails', ['version', 'requires'])

Expand Down Expand Up @@ -99,7 +100,7 @@ def check_package_set(package_set, should_ignore=None):


def check_install_conflicts(to_install):
# type: (List[InstallRequirement]) -> Tuple[PackageSet, CheckResult]
# type: (List[InstallRequirement]) -> ConflictDetails
"""For checking if the dependency graph would be consistent after \
installing given requirements
"""
Expand Down