Skip to content

Bump minimal pyparsing to 2.0.1 #8754

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 2 commits into from
Jun 17, 2017
Merged
Show file tree
Hide file tree
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
73 changes: 27 additions & 46 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@
year = 2007
}"""

try:
import dateutil
except ImportError:
raise ImportError("matplotlib requires dateutil")

_python27 = (sys.version_info.major == 2 and sys.version_info.minor >= 7)
_python34 = (sys.version_info.major == 3 and sys.version_info.minor >= 4)
if not (_python27 or _python34):
raise ImportError("Matplotlib requires Python 2.7 or 3.4 or later")


def compare_versions(a, b):
Expand All @@ -173,59 +174,39 @@ def compare_versions(a, b):
else:
return False

if not compare_versions(six.__version__, '1.3'):

try:
import dateutil
except ImportError:
raise ImportError("Matplotlib requires dateutil")


if not compare_versions(six.__version__, '1.10'):
raise ImportError(
'six 1.3 or later is required; you have %s' % (
six.__version__))
"Matplotlib requires six>=1.10; you have %s" % six.__version__)


try:
import pyparsing
except ImportError:
raise ImportError("matplotlib requires pyparsing")
raise ImportError("Matplotlib requires pyparsing")
else:
if not compare_versions(pyparsing.__version__, '1.5.6'):
if not compare_versions(pyparsing.__version__, '2.0.1'):
raise ImportError(
"matplotlib requires pyparsing >= 1.5.6")
"Matplotlib requires pyparsing>=2.0.1; you have %s"
% pyparsing.__version__)

# pyparsing 2.0.0 bug, but it may be patched in distributions
try:
f = pyparsing.Forward()
f <<= pyparsing.Literal('a')
bad_pyparsing = f is None
except TypeError:
bad_pyparsing = True

# 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. 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 bad_pyparsing:
def _forward_ilshift(self, other):
self.__lshift__(other)
return self
pyparsing.Forward.__ilshift__ = _forward_ilshift
if not compare_versions(numpy.__version__, __version__numpy__):
raise ImportError(
"Matplotlib requires numpy>=%s; you have %s" % (
__version__numpy__, numpy.__version__))


if not hasattr(sys, 'argv'): # for modpython
sys.argv = [str('modpython')]


major, minor1, minor2, s, tmp = sys.version_info
_python27 = (major == 2 and minor1 >= 7)
_python34 = (major == 3 and minor1 >= 4)

if not (_python27 or _python34):
raise ImportError('matplotlib requires Python 2.7 or 3.4 or later')


if not compare_versions(numpy.__version__, __version__numpy__):
raise ImportError(
'numpy %s or later is required; you have %s' % (
__version__numpy__, numpy.__version__))


def _is_writable_dir(p):
"""
p is a string pointing to a putative writable dir -- return True p
Expand Down Expand Up @@ -1452,7 +1433,7 @@ def _init_tests():
if (ft2font.__freetype_version__ != LOCAL_FREETYPE_VERSION or
ft2font.__freetype_build_type__ != 'local'):
warnings.warn(
"matplotlib is not built with the correct FreeType version to run "
"Matplotlib is not built with the correct FreeType version to run "
"tests. Set local_freetype=True in setup.cfg and rebuild. "
"Expect many image comparison failures below. "
"Expected freetype version {0}. "
Expand Down Expand Up @@ -1480,7 +1461,7 @@ def test(verbosity=None, coverage=False, switch_backend_warn=True,
"""run the matplotlib test suite"""
_init_tests()
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
raise ImportError("matplotlib test data is not installed")
raise ImportError("Matplotlib test data is not installed")

old_backend = get_backend()
old_recursionlimit = sys.getrecursionlimit()
Expand Down Expand Up @@ -1594,8 +1575,8 @@ def foo(ax, *args, **kwargs)

def param(func):
new_sig = None
python_has_signature = major >= 3 and minor1 >= 3
python_has_wrapped = major >= 3 and minor1 >= 2
# signature is since 3.3 and wrapped since 3.2, but we support 3.4+.
python_has_signature = python_has_wrapped = six.PY3

# if in a legacy version of python and IPython is already imported
# try to use their back-ported signature
Expand Down
9 changes: 1 addition & 8 deletions lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@
ParseResults, Suppress, oneOf, StringEnd, ParseFatalException,
FollowedBy, Regex, ParserElement, QuotedString, ParseBaseException)

# Enable packrat parsing
if (six.PY3 and
[int(x) for x in pyparsing.__version__.split('.')] < [2, 0, 0]):
warn("Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing "
"has been disabled. Mathtext rendering will be much slower as a "
"result. Install pyparsing 2.0.0 or later to improve performance.")
else:
ParserElement.enablePackrat()
ParserElement.enablePackrat()

from matplotlib.afm import AFM
from matplotlib.cbook import Bunch, get_realpath_and_stat, maxdict
Expand Down
29 changes: 1 addition & 28 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,17 +1593,6 @@ def check(self):

class Pyparsing(SetupPackage):
name = "pyparsing"
# pyparsing 2.0.4 has broken python 3 support.
# pyparsing 2.1.2 is broken in python3.4/3.3.
def is_ok(self):
# pyparsing 2.0.0 bug, but it may be patched in distributions
try:
import pyparsing
f = pyparsing.Forward()
f <<= pyparsing.Literal('a')
return f is not None
except (ImportError, TypeError):
return False

def check(self):
try:
Expand All @@ -1614,26 +1603,10 @@ def check(self):
"support. pip/easy_install may attempt to install it "
"after matplotlib.")

required = [1, 5, 6]
if [int(x) for x in pyparsing.__version__.split('.')] < required:
return (
"matplotlib requires pyparsing >= {0}".format(
'.'.join(str(x) for x in required)))

if not self.is_ok():
return (
"Your pyparsing contains a bug that will be monkey-patched by "
"matplotlib. For best results, upgrade to pyparsing 2.0.1 or "
"later.")

return "using pyparsing version %s" % pyparsing.__version__

def get_install_requires(self):
versionstring = 'pyparsing>=1.5.6,!=2.0.4,!=2.1.2,!=2.1.6'
if self.is_ok():
return [versionstring]
else:
return [versionstring + ',!=2.0.0']
return ['pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6']


class BackendAgg(OptionalBackendPackage):
Expand Down