Skip to content

Commit

Permalink
Merge pull request #1808 from pypa/bugfix/resolver-markers
Browse files Browse the repository at this point in the history
Simplify marker checks in patched resolver
  • Loading branch information
kennethreitz authored Mar 20, 2018
2 parents 2b84ab6 + e433ebb commit 1b071bb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pipenv/patched/piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,28 @@ def _iter_dependencies(self, ireq):
for dependency_string in dependency_strings:

try:
split_deps = dependency_string.split(';')
dependencies, markers = split_deps[0], '; '.join(list(set([marker.strip() for marker in split_deps[1:]])))
individual_dependencies = [dep.strip() for dep in dependencies.split(', ')]
markers = None
if ';' in dependency_string:
# split off markers and remove any duplicates by comparing against deps
dependencies, markers = dependency_string.rsplit(';', 1)
dependency_string = ';'.join([dep for dep in dependencies.split(';') if dep.strip() != markers.strip()])
individual_dependencies = [dep.strip() for dep in dependency_string.split(', ')]
cleaned_deps = []
for dep in individual_dependencies:
tokens = [token.strip() for token in dep.split(';')]
cleaned_tokens = []
markers = []
dep_markers = []
if len(tokens) == 1:
cleaned_deps.append(tokens[0])
continue
markers = list(set(tokens[1:]))
dep_markers = list(set(tokens[1:]))
cleaned_tokens.append(tokens[0])
if markers:
cleaned_tokens.extend(markers)
if dep_markers:
cleaned_tokens.extend(dep_markers)
cleaned_deps.append('; '.join(cleaned_tokens))
_dependency_string = ', '.join(set(cleaned_deps))
_dependency_string += '; {0}'.format(markers)
if markers:
_dependency_string += ';{0}'.format(markers)

yield InstallRequirement.from_line(_dependency_string, constraint=ireq.constraint)
except InvalidMarker:
Expand Down

0 comments on commit 1b071bb

Please sign in to comment.