-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove RequirementSet.require_hashes (#7068)
- Loading branch information
Showing
7 changed files
with
31 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,7 @@ def __init__( | |
force_reinstall, # type: bool | ||
upgrade_strategy, # type: str | ||
py_version_info=None, # type: Optional[Tuple[int, ...]] | ||
require_hashes=False, # type: bool | ||
): | ||
# type: (...) -> None | ||
super(Resolver, self).__init__() | ||
|
@@ -142,8 +143,7 @@ def __init__( | |
self.finder = finder | ||
self.session = session | ||
|
||
# This is set in resolve | ||
self.require_hashes = None # type: Optional[bool] | ||
self.require_hashes_option = require_hashes | ||
|
||
self.upgrade_strategy = upgrade_strategy | ||
self.force_reinstall = force_reinstall | ||
|
@@ -178,8 +178,9 @@ def resolve(self, requirement_set): | |
requirement_set.unnamed_requirements + | ||
list(requirement_set.requirements.values()) | ||
) | ||
self.require_hashes = ( | ||
requirement_set.require_hashes or | ||
|
||
require_hashes = ( | ||
self.require_hashes_option or | ||
any(req.has_hash_options for req in root_reqs) | ||
) | ||
|
||
|
@@ -198,7 +199,7 @@ def resolve(self, requirement_set): | |
for req in chain(root_reqs, discovered_reqs): | ||
try: | ||
discovered_reqs.extend( | ||
self._resolve_one(requirement_set, req) | ||
self._resolve_one(requirement_set, req, require_hashes) | ||
) | ||
except HashError as exc: | ||
exc.req = req | ||
|
@@ -281,18 +282,14 @@ def _check_skip_installed(self, req_to_install): | |
self._set_req_to_reinstall(req_to_install) | ||
return None | ||
|
||
def _get_abstract_dist_for(self, req): | ||
# type: (InstallRequirement) -> AbstractDistribution | ||
def _get_abstract_dist_for(self, req, require_hashes): | ||
# type: (InstallRequirement, bool) -> AbstractDistribution | ||
"""Takes a InstallRequirement and returns a single AbstractDist \ | ||
representing a prepared variant of the same. | ||
""" | ||
assert self.require_hashes is not None, ( | ||
"require_hashes should have been set in Resolver.resolve()" | ||
) | ||
|
||
if req.editable: | ||
return self.preparer.prepare_editable_requirement( | ||
req, self.require_hashes, self.use_user_site, self.finder, | ||
req, require_hashes, self.use_user_site, self.finder, | ||
) | ||
|
||
# satisfied_by is only evaluated by calling _check_skip_installed, | ||
|
@@ -302,15 +299,15 @@ def _get_abstract_dist_for(self, req): | |
|
||
if req.satisfied_by: | ||
return self.preparer.prepare_installed_requirement( | ||
req, self.require_hashes, skip_reason | ||
req, require_hashes, skip_reason | ||
) | ||
|
||
upgrade_allowed = self._is_upgrade_allowed(req) | ||
|
||
# We eagerly populate the link, since that's our "legacy" behavior. | ||
req.populate_link(self.finder, upgrade_allowed, self.require_hashes) | ||
req.populate_link(self.finder, upgrade_allowed, require_hashes) | ||
abstract_dist = self.preparer.prepare_linked_requirement( | ||
req, self.session, self.finder, self.require_hashes | ||
req, self.session, self.finder, require_hashes | ||
) | ||
|
||
# NOTE | ||
|
@@ -344,7 +341,8 @@ def _get_abstract_dist_for(self, req): | |
def _resolve_one( | ||
self, | ||
requirement_set, # type: RequirementSet | ||
req_to_install # type: InstallRequirement | ||
req_to_install, # type: InstallRequirement | ||
require_hashes, # type: bool | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
chrahunt
Member
|
||
): | ||
# type: (...) -> List[InstallRequirement] | ||
"""Prepare a single requirements file. | ||
|
@@ -362,7 +360,9 @@ def _resolve_one( | |
# register tmp src for cleanup in case something goes wrong | ||
requirement_set.reqs_to_cleanup.append(req_to_install) | ||
|
||
abstract_dist = self._get_abstract_dist_for(req_to_install) | ||
abstract_dist = self._get_abstract_dist_for( | ||
req_to_install, require_hashes | ||
) | ||
|
||
# Parse and return dependencies | ||
dist = abstract_dist.get_pkg_resources_distribution() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pradyunsg any reason this can't have a default value? It breaks compatibility (more) -- can this not rely on
self.require_hashes
?