Comparison made by distutils.version.LooseVersion

This commit is contained in:
Marco Buttu 2017-01-15 22:09:15 +01:00
parent e7166bbc08
commit df1c46974d
2 changed files with 6 additions and 4 deletions

View File

@ -80,7 +80,9 @@ a comma-separated list of group names.
.. doctest::
:pyversion: > 3.3
The supported operands are ``<``, ``<=``, ``==``, ``>=``, and ``>``.
The supported operands are ``<``, ``<=``, ``==``, ``>=``, ``>``, and
comparison is performed by `distutils.version.LooseVersion
<https://www.python.org/dev/peps/pep-0386/#distutils>`__.
.. versionadded:: 1.5

View File

@ -20,7 +20,7 @@ from os import path
import doctest
from six import itervalues, StringIO, binary_type, text_type, PY2
from distutils.version import StrictVersion
from distutils.version import LooseVersion
from docutils import nodes
from docutils.parsers.rst import Directive, directives
@ -70,8 +70,8 @@ def compare_version(ver1, ver2, operand):
"""
if operand not in ('<=', '<', '==', '>=', '>'):
raise ValueError("'%s' is not a valid operand.")
v1 = StrictVersion(ver1)
v2 = StrictVersion(ver2)
v1 = LooseVersion(ver1)
v2 = LooseVersion(ver2)
return ((operand == '<=' and (v1 <= v2)) or
(operand == '<' and (v1 < v2)) or
(operand == '==' and (v1 == v2)) or