Skip to content

Commit

Permalink
Revert "Fix nondeterminism with environment markers #5239 (#5286)" (#…
Browse files Browse the repository at this point in the history
…5306)

This reverts commit 4b9fc02.
  • Loading branch information
matteius authored Aug 29, 2022
1 parent bac7b68 commit 0d86629
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion news/5239.bugfix.rst

This file was deleted.

25 changes: 11 additions & 14 deletions pipenv/utils/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import warnings
from functools import lru_cache
from typing import Dict, List, Optional, Tuple, Union
from typing import Dict, List, Optional, Set, Tuple, Union

from pipenv import environments
from pipenv.exceptions import RequirementError, ResolutionFailure
Expand Down Expand Up @@ -86,6 +86,7 @@ def get_package_finder(


class HashCacheMixin:

"""Caches hashes of PyPI artifacts so we do not need to re-download them.
Hashes are only cached when the URL appears to contain a hash in it and the
Expand Down Expand Up @@ -188,14 +189,12 @@ def get_metadata(
pre: bool = False,
clear: bool = False,
) -> Tuple[
List[str],
Set[str],
Dict[str, Dict[str, Union[str, bool, List[str]]]],
Dict[str, str],
Dict[str, str],
]:
constraints: Dict[
str, None
] = {} # Used Dict instead of Set because Dict is ordered and is hence stable
constraints: Set[str] = set()
skipped: Dict[str, Dict[str, Union[str, bool, List[str]]]] = {}
if index_lookup is None:
index_lookup = {}
Expand Down Expand Up @@ -248,9 +247,9 @@ def get_metadata(
constraint_update, lockfile_update = self.get_deps_from_req(
req, resolver=transient_resolver, resolve_vcs=project.s.PIPENV_RESOLVE_VCS
)
constraints.update(constraint_update)
constraints |= constraint_update
skipped.update(lockfile_update)
return list(constraints.keys()), skipped, index_lookup, markers_lookup
return constraints, skipped, index_lookup, markers_lookup

def parse_line(
self,
Expand Down Expand Up @@ -310,17 +309,15 @@ def get_deps_from_req(
req: Requirement,
resolver: Optional["Resolver"] = None,
resolve_vcs: bool = True,
) -> Tuple[Dict[str, None], Dict[str, Dict[str, Union[str, bool, List[str]]]]]:
) -> Tuple[Set[str], Dict[str, Dict[str, Union[str, bool, List[str]]]]]:
from pipenv.vendor.requirementslib.models.requirements import Requirement
from pipenv.vendor.requirementslib.models.utils import (
_requirement_to_str_lowercase_name,
)
from pipenv.vendor.requirementslib.utils import is_installable_dir

# TODO: this is way too complex, refactor this
constraints: Dict[
str, None
] = {} # Used Dict instead of Set because Dict is ordered and is hence stable
constraints: Set[str] = set()
locked_deps: Dict[str, Dict[str, Union[str, bool, List[str]]]] = {}
editable_packages = self.project.get_editable_packages(dev=self.dev)
if (req.is_file_or_url or req.is_vcs) and not req.is_wheel:
Expand Down Expand Up @@ -368,12 +365,12 @@ def get_deps_from_req(
new_req, resolver
)
locked_deps.update(new_lock)
constraints.update(new_constraints)
constraints |= new_constraints
# if there is no marker or there is a valid marker, add the constraint line
elif r and (not r.marker or (r.marker and r.marker.evaluate())):
if r.name not in editable_packages:
line = _requirement_to_str_lowercase_name(r)
constraints[line] = None
constraints.add(line)
# ensure the top level entry remains as provided
# note that we shouldn't pin versions for editable vcs deps
if not req.is_vcs:
Expand Down Expand Up @@ -421,7 +418,7 @@ def get_deps_from_req(
err=True,
)
return constraints, locked_deps
constraints[req.constraint_line] = None
constraints.add(req.constraint_line)
return constraints, locked_deps
return constraints, locked_deps

Expand Down

0 comments on commit 0d86629

Please sign in to comment.