Skip to content

Commit

Permalink
Fix markers evaluation for python_version with precision < 3
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Apr 9, 2019
1 parent 2515679 commit 46ad807
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions poetry/packages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re

from poetry.semver import Version
from poetry.version.requirements import Requirement

from .dependency import Dependency
Expand Down Expand Up @@ -105,6 +106,22 @@ def dependency_from_pep_508(name):
op = ""
elif op == "!=":
version += ".*"
elif op in ("<=", ">"):
parsed_version = Version.parse(version)
if parsed_version.precision == 1:
if op == "<=":
op = "<"
version = parsed_version.next_major.text
elif op == ">":
op = ">="
version = parsed_version.next_major.text
elif parsed_version.precision == 2:
if op == "<=":
op = "<"
version = parsed_version.next_minor.text
elif op == ">":
op = ">="
version = parsed_version.next_minor.text
elif op in ("in", "not in"):
versions = []
for v in re.split("[ ,]+", version):
Expand Down

0 comments on commit 46ad807

Please sign in to comment.