Skip to content

Commit 93462de

Browse files
committed
Bump minimal pyparsing to 2.0.1.
pyparsing is a pure python package so anyone who can install matplotlib 2.1 can realistically also install a recent-ish pyparsing (in fact pip will just pick it up). This avoids having to carry around workarounds for a bunch of old broken versions.
1 parent 6ed951e commit 93462de

File tree

3 files changed

+4
-58
lines changed

3 files changed

+4
-58
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,29 +183,9 @@ def compare_versions(a, b):
183183
except ImportError:
184184
raise ImportError("matplotlib requires pyparsing")
185185
else:
186-
if not compare_versions(pyparsing.__version__, '1.5.6'):
186+
if not compare_versions(pyparsing.__version__, '2.0.1'):
187187
raise ImportError(
188-
"matplotlib requires pyparsing >= 1.5.6")
189-
190-
# pyparsing 2.0.0 bug, but it may be patched in distributions
191-
try:
192-
f = pyparsing.Forward()
193-
f <<= pyparsing.Literal('a')
194-
bad_pyparsing = f is None
195-
except TypeError:
196-
bad_pyparsing = True
197-
198-
# pyparsing 1.5.6 does not have <<= on the Forward class, but
199-
# pyparsing 2.0.0 and later will spew deprecation warnings if
200-
# using << instead. Additionally, the <<= in pyparsing 1.5.7 is
201-
# broken, since it doesn't return self. In order to support
202-
# pyparsing 1.5.6 and above with a common code base, this small
203-
# monkey patch is applied.
204-
if bad_pyparsing:
205-
def _forward_ilshift(self, other):
206-
self.__lshift__(other)
207-
return self
208-
pyparsing.Forward.__ilshift__ = _forward_ilshift
188+
"matplotlib requires pyparsing >= 2.0.1")
209189

210190

211191
if not hasattr(sys, 'argv'): # for modpython

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@
3434
ParseResults, Suppress, oneOf, StringEnd, ParseFatalException,
3535
FollowedBy, Regex, ParserElement, QuotedString, ParseBaseException)
3636

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

4639
from matplotlib.afm import AFM
4740
from matplotlib.cbook import Bunch, get_realpath_and_stat, maxdict

setupext.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,17 +1593,6 @@ def check(self):
15931593

15941594
class Pyparsing(SetupPackage):
15951595
name = "pyparsing"
1596-
# pyparsing 2.0.4 has broken python 3 support.
1597-
# pyparsing 2.1.2 is broken in python3.4/3.3.
1598-
def is_ok(self):
1599-
# pyparsing 2.0.0 bug, but it may be patched in distributions
1600-
try:
1601-
import pyparsing
1602-
f = pyparsing.Forward()
1603-
f <<= pyparsing.Literal('a')
1604-
return f is not None
1605-
except (ImportError, TypeError):
1606-
return False
16071596

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

1617-
required = [1, 5, 6]
1618-
if [int(x) for x in pyparsing.__version__.split('.')] < required:
1619-
return (
1620-
"matplotlib requires pyparsing >= {0}".format(
1621-
'.'.join(str(x) for x in required)))
1622-
1623-
if not self.is_ok():
1624-
return (
1625-
"Your pyparsing contains a bug that will be monkey-patched by "
1626-
"matplotlib. For best results, upgrade to pyparsing 2.0.1 or "
1627-
"later.")
1628-
16291606
return "using pyparsing version %s" % pyparsing.__version__
16301607

16311608
def get_install_requires(self):
1632-
versionstring = 'pyparsing>=1.5.6,!=2.0.4,!=2.1.2,!=2.1.6'
1633-
if self.is_ok():
1634-
return [versionstring]
1635-
else:
1636-
return [versionstring + ',!=2.0.0']
1609+
return ['pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6']
16371610

16381611

16391612
class BackendAgg(OptionalBackendPackage):

0 commit comments

Comments
 (0)