Trace common finder info outside resolver

There's no reason for Resolver to trace this information about our
PackageFinder, we just need a common one-time function to trace useful
information.
This commit is contained in:
Chris Hunt 2019-11-04 20:45:37 -05:00
parent ef20309867
commit f305f66eb2
5 changed files with 24 additions and 6 deletions

View File

@ -8,6 +8,7 @@ PackageFinder machinery and all its vendored dependencies, etc.
# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False
import logging
import os
from functools import partial
@ -41,6 +42,8 @@ if MYPY_CHECK_RUNNING:
from pip._internal.req.req_tracker import RequirementTracker
from pip._internal.utils.temp_dir import TempDirectory
logger = logging.getLogger(__name__)
class SessionCommandMixin(CommandContextMixIn):
@ -272,6 +275,18 @@ class RequirementCommand(IndexGroupCommand):
'You must give at least one requirement to %(name)s '
'(see "pip help %(name)s")' % opts)
@staticmethod
def trace_basic_info(finder):
# type: (PackageFinder) -> None
"""
Trace basic information about the provided objects.
"""
# Display where finder is looking for packages
search_scope = finder.search_scope
locations = search_scope.get_formatted_locations()
if locations:
logger.info(locations)
def _build_package_finder(
self,
options, # type: Values

View File

@ -139,6 +139,9 @@ class DownloadCommand(RequirementCommand):
options=options,
py_version_info=options.python_version,
)
self.trace_basic_info(finder)
resolver.resolve(requirement_set)
downloaded = ' '.join([

View File

@ -373,6 +373,9 @@ class InstallCommand(RequirementCommand):
upgrade_strategy=upgrade_strategy,
use_pep517=options.use_pep517,
)
self.trace_basic_info(finder)
resolver.resolve(requirement_set)
try:

View File

@ -185,6 +185,9 @@ class WheelCommand(RequirementCommand):
ignore_requires_python=options.ignore_requires_python,
use_pep517=options.use_pep517,
)
self.trace_basic_info(finder)
resolver.resolve(requirement_set)
# build wheels

View File

@ -181,12 +181,6 @@ class Resolver(object):
any(req.has_hash_options for req in root_reqs)
)
# Display where finder is looking for packages
search_scope = self.finder.search_scope
locations = search_scope.get_formatted_locations()
if locations:
logger.info(locations)
# Actually prepare the files, and collect any exceptions. Most hash
# exceptions cannot be checked ahead of time, because
# req.populate_link() needs to be called before we can make decisions