Skip to content

issues with pyparsing 1.5.7 and python 2.7 #2338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
from __future__ import print_function, absolute_import

import sys
import distutils.version

__version__ = '1.3.0'
__version__numpy__ = '1.5' # minimum required numpy version
Expand All @@ -109,16 +110,23 @@
except ImportError:
raise ImportError("matplotlib requires dateutil")

def compare_versions(a, b):
"return True if a is greater than or equal to b"
if a:
a = distutils.version.LooseVersion(a)
b = distutils.version.LooseVersion(b)
if a>=b: return True
else: return False
else: return False

try:
import pyparsing
except ImportError:
raise ImportError("matplotlib requires pyparsing")
else:
_required = [1, 5, 6]
if [int(x) for x in pyparsing.__version__.split('.')] < _required:
if not compare_versions(pyparsing.__version__, '1.5.6'):
raise ImportError(
"matplotlib requires pyparsing >= {0}".format(
'.'.join(str(x) for x in _required)))
"matplotlib requires pyparsing >= 1.5.6")

if pyparsing.__version__ == '2.0.0':
raise ImportError(
Expand All @@ -127,17 +135,18 @@

# pyparsing 1.5.6 does not have <<= on the Forward class, but
# pyparsing 2.0.0 and later will spew deprecation warnings if
# using << instead. In order to support pyparsing 1.5.6 and above
# with a common code base, this small monkey patch is applied.
if not hasattr(pyparsing.Forward, '__ilshift__'):
# using << instead. Additionally, the <<= in pyparsing 1.5.7 is
# broken, since it doesn't return self. In order to support
# pyparsing 1.5.6 and above with a common code base, this small
# monkey patch is applied.
if not compare_versions(pyparsing.__version__, '2.0.1'):
def _forward_ilshift(self, other):
self.__lshift__(other)
return self
pyparsing.Forward.__ilshift__ = _forward_ilshift

import os, re, shutil, warnings
import distutils.sysconfig
import distutils.version

# cbook must import matplotlib only within function
# definitions, so it is safe to import from it here.
Expand Down Expand Up @@ -195,14 +204,10 @@ def byte2str(b): return b


import numpy
from distutils import version
expected_version = version.LooseVersion(__version__numpy__)
found_version = version.LooseVersion(numpy.__version__)
if not found_version >= expected_version:
if not compare_versions(numpy.__version__, __version__numpy__):
raise ImportError(
'numpy %s or later is required; you have %s' % (
__version__numpy__, numpy.__version__))
del version


def _is_writable_dir(p):
Expand Down Expand Up @@ -402,15 +407,6 @@ def checkdep_xmllint():
except (IndexError, ValueError, UnboundLocalError, OSError):
return None

def compare_versions(a, b):
"return True if a is greater than or equal to b"
if a:
a = distutils.version.LooseVersion(a)
b = distutils.version.LooseVersion(b)
if a>=b: return True
else: return False
else: return False

def checkdep_ps_distiller(s):
if not s:
return False
Expand Down