Skip to content

Commit

Permalink
Fix nondeterminism with environment markers #5239
Browse files Browse the repository at this point in the history
  • Loading branch information
bakhtiary committed Aug 23, 2022
1 parent b6d9ad6 commit 4716b64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions news/5239.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix nondeterminism with environment markers #5239
18 changes: 9 additions & 9 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, Set, Tuple, Union
from typing import Dict, List, Optional, Tuple, Union

from pipenv import environments
from pipenv.exceptions import RequirementError, ResolutionFailure
Expand Down Expand Up @@ -189,12 +189,12 @@ def get_metadata(
pre: bool = False,
clear: bool = False,
) -> Tuple[
Set[str],
Dict[str, str],
Dict[str, Dict[str, Union[str, bool, List[str]]]],
Dict[str, str],
Dict[str, str],
]:
constraints: Set[str] = set()
constraints: Dict[str, str] = {}
skipped: Dict[str, Dict[str, Union[str, bool, List[str]]]] = {}
if index_lookup is None:
index_lookup = {}
Expand Down Expand Up @@ -247,7 +247,7 @@ def get_metadata(
constraint_update, lockfile_update = self.get_deps_from_req(
req, resolver=transient_resolver, resolve_vcs=project.s.PIPENV_RESOLVE_VCS
)
constraints |= constraint_update
constraints.update(constraint_update)
skipped.update(lockfile_update)
return constraints, skipped, index_lookup, markers_lookup

Expand Down Expand Up @@ -309,15 +309,15 @@ def get_deps_from_req(
req: Requirement,
resolver: Optional["Resolver"] = None,
resolve_vcs: bool = True,
) -> Tuple[Set[str], Dict[str, Dict[str, Union[str, bool, List[str]]]]]:
) -> Tuple[Dict[str, 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: Set[str] = set()
constraints: Dict[str, str] = {}
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 @@ -365,12 +365,12 @@ def get_deps_from_req(
new_req, resolver
)
locked_deps.update(new_lock)
constraints |= new_constraints
constraints.update(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.add(line)
constraints[line] = None
# 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 @@ -418,7 +418,7 @@ def get_deps_from_req(
err=True,
)
return constraints, locked_deps
constraints.add(req.constraint_line)
constraints[req.constraint_line] = None
return constraints, locked_deps
return constraints, locked_deps

Expand Down

0 comments on commit 4716b64

Please sign in to comment.