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

Remove Resolver.session #7290

Merged
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
4 changes: 2 additions & 2 deletions src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def make_requirement_preparer(
temp_build_dir, # type: TempDirectory
options, # type: Values
req_tracker, # type: RequirementTracker
session, # type: PipSession
download_dir=None, # type: str
wheel_download_dir=None, # type: str
):
Expand All @@ -166,12 +167,12 @@ def make_requirement_preparer(
progress_bar=options.progress_bar,
build_isolation=options.build_isolation,
req_tracker=req_tracker,
session=session,
)

@staticmethod
def make_resolver(
preparer, # type: RequirementPreparer
session, # type: PipSession
finder, # type: PackageFinder
options, # type: Values
wheel_cache=None, # type: Optional[WheelCache]
Expand All @@ -195,7 +196,6 @@ def make_resolver(
)
return Resolver(
preparer=preparer,
session=session,
finder=finder,
make_install_req=make_install_req,
use_user_site=use_user_site,
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ def run(self, options, args):
temp_build_dir=directory,
options=options,
req_tracker=req_tracker,
session=session,
download_dir=options.download_dir,
)

resolver = self.make_resolver(
preparer=preparer,
finder=finder,
session=session,
options=options,
py_version_info=options.python_version,
)
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ def run(self, options, args):
temp_build_dir=directory,
options=options,
req_tracker=req_tracker,
session=session,
)
resolver = self.make_resolver(
preparer=preparer,
finder=finder,
session=session,
options=options,
wheel_cache=wheel_cache,
use_user_site=options.use_user_site,
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ def run(self, options, args):
temp_build_dir=directory,
options=options,
req_tracker=req_tracker,
session=session,
wheel_download_dir=options.wheel_dir,
)

resolver = self.make_resolver(
preparer=preparer,
finder=finder,
session=session,
options=options,
wheel_cache=wheel_cache,
ignore_requires_python=options.ignore_requires_python,
Expand Down
5 changes: 1 addition & 4 deletions src/pip/_internal/legacy_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from pip._vendor import pkg_resources

from pip._internal.distributions import AbstractDistribution
from pip._internal.network.session import PipSession
from pip._internal.index.package_finder import PackageFinder
from pip._internal.operations.prepare import RequirementPreparer
from pip._internal.req.req_install import InstallRequirement
Expand Down Expand Up @@ -116,7 +115,6 @@ class Resolver(object):
def __init__(
self,
preparer, # type: RequirementPreparer
session, # type: PipSession
finder, # type: PackageFinder
make_install_req, # type: InstallRequirementProvider
use_user_site, # type: bool
Expand All @@ -141,7 +139,6 @@ def __init__(

self.preparer = preparer
self.finder = finder
self.session = session

self.require_hashes_option = require_hashes

Expand Down Expand Up @@ -307,7 +304,7 @@ def _get_abstract_dist_for(self, req, require_hashes):
# We eagerly populate the link, since that's our "legacy" behavior.
req.populate_link(self.finder, upgrade_allowed, require_hashes)
abstract_dist = self.preparer.prepare_linked_requirement(
req, self.session, self.finder, require_hashes
req, self.finder, require_hashes
)

# NOTE
Expand Down
7 changes: 4 additions & 3 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,16 @@ def __init__(
wheel_download_dir, # type: Optional[str]
progress_bar, # type: str
build_isolation, # type: bool
req_tracker # type: RequirementTracker
req_tracker, # type: RequirementTracker
session, # type: PipSession
):
# type: (...) -> None
super(RequirementPreparer, self).__init__()

self.src_dir = src_dir
self.build_dir = build_dir
self.req_tracker = req_tracker
self.session = session

# Where still-packed archives should be written to. If None, they are
# not saved, and are deleted immediately after unpacking.
Expand Down Expand Up @@ -593,7 +595,6 @@ def _download_should_save(self):
def prepare_linked_requirement(
self,
req, # type: InstallRequirement
session, # type: PipSession
finder, # type: PackageFinder
require_hashes, # type: bool
):
Expand Down Expand Up @@ -672,7 +673,7 @@ def prepare_linked_requirement(
try:
unpack_url(
link, req.source_dir, download_dir,
session=session, hashes=hashes,
session=self.session, hashes=hashes,
progress_bar=self.progress_bar
)
except requests.HTTPError as exc:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def _basic_resolver(self, finder, require_hashes=False):
progress_bar="on",
build_isolation=True,
req_tracker=RequirementTracker(),
session=PipSession(),
)
make_install_req = partial(
install_req_from_req_string,
Expand All @@ -85,7 +86,7 @@ def _basic_resolver(self, finder, require_hashes=False):
return Resolver(
preparer=preparer,
make_install_req=make_install_req,
session=PipSession(), finder=finder,
finder=finder,
use_user_site=False, upgrade_strategy="to-satisfy-only",
ignore_dependencies=False, ignore_installed=False,
ignore_requires_python=False, force_reinstall=False,
Expand Down