Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a3f86c

Browse files
committed
Have a workaround if a Python 3 user has pyparsing <= 2.0.0
1 parent 091776d commit 7a3f86c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lib/matplotlib/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,11 @@
114114
except ImportError:
115115
raise ImportError("matplotlib requires pyparsing")
116116
else:
117-
if sys.version_info[0] >= 3:
118-
_required = [2, 0, 0]
119-
else:
120-
_required = [1, 5, 6]
117+
_required = [1, 5, 6]
121118
if [int(x) for x in pyparsing.__version__.split('.')] < _required:
122119
raise ImportError(
123-
"matplotlib requires pyparsing >= {0} on Python {1}".format(
124-
'.'.join(str(x) for x in _required),
125-
sys.version_info[0]))
120+
"matplotlib requires pyparsing >= {0}".format(
121+
'.'.join(str(x) for x in _required)))
126122

127123
import os, re, shutil, warnings
128124
import distutils.sysconfig

lib/matplotlib/mathtext.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@
3434
from numpy import inf, isinf
3535
import numpy as np
3636

37+
import pyparsing
3738
from pyparsing import Combine, Group, Optional, Forward, \
3839
Literal, OneOrMore, ZeroOrMore, ParseException, Empty, \
3940
ParseResults, Suppress, oneOf, StringEnd, ParseFatalException, \
4041
FollowedBy, Regex, ParserElement, QuotedString, ParseBaseException
4142

4243
# Enable packrat parsing
43-
ParserElement.enablePackrat()
44+
if (sys.version_info[0] >= 3 and
45+
[int(x) for x in pyparsing.__version__.split('.')] < [2, 0, 0]):
46+
warn("Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing "
47+
"has been disabled. Mathtext rendering will be much slower as a "
48+
"result. Install pyparsing 2.0.0 or later to improve performance.")
49+
else:
50+
ParserElement.enablePackrat()
4451

4552
from matplotlib.afm import AFM
4653
from matplotlib.cbook import Bunch, get_realpath_and_stat, \

setupext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ def check(self):
940940

941941
def get_install_requires(self):
942942
if sys.version_info[0] >= 3:
943-
return ['pyparsing>=2.0.0']
943+
return ['pyparsing>=1.5.6']
944944
else:
945945
# pyparsing >= 2.0.0 is not compatible with Python 2
946946
return ['pyparsing>=1.5.6,<2.0.0']

0 commit comments

Comments
 (0)