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

Skip to content

Commit 6ff34d4

Browse files
authored
Merge pull request #8754 from anntzer/pyparsing-version
BLD: Bump minimal pyparsing to 2.0.1
2 parents 6ed951e + 35ba63e commit 6ff34d4

3 files changed

Lines changed: 29 additions & 82 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@
153153
year = 2007
154154
}"""
155155

156-
try:
157-
import dateutil
158-
except ImportError:
159-
raise ImportError("matplotlib requires dateutil")
156+
157+
_python27 = (sys.version_info.major == 2 and sys.version_info.minor >= 7)
158+
_python34 = (sys.version_info.major == 3 and sys.version_info.minor >= 4)
159+
if not (_python27 or _python34):
160+
raise ImportError("Matplotlib requires Python 2.7 or 3.4 or later")
160161

161162

162163
def compare_versions(a, b):
@@ -173,59 +174,39 @@ def compare_versions(a, b):
173174
else:
174175
return False
175176

176-
if not compare_versions(six.__version__, '1.3'):
177+
178+
try:
179+
import dateutil
180+
except ImportError:
181+
raise ImportError("Matplotlib requires dateutil")
182+
183+
184+
if not compare_versions(six.__version__, '1.10'):
177185
raise ImportError(
178-
'six 1.3 or later is required; you have %s' % (
179-
six.__version__))
186+
"Matplotlib requires six>=1.10; you have %s" % six.__version__)
187+
180188

181189
try:
182190
import pyparsing
183191
except ImportError:
184-
raise ImportError("matplotlib requires pyparsing")
192+
raise ImportError("Matplotlib requires pyparsing")
185193
else:
186-
if not compare_versions(pyparsing.__version__, '1.5.6'):
194+
if not compare_versions(pyparsing.__version__, '2.0.1'):
187195
raise ImportError(
188-
"matplotlib requires pyparsing >= 1.5.6")
196+
"Matplotlib requires pyparsing>=2.0.1; you have %s"
197+
% pyparsing.__version__)
189198

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
197199

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
200+
if not compare_versions(numpy.__version__, __version__numpy__):
201+
raise ImportError(
202+
"Matplotlib requires numpy>=%s; you have %s" % (
203+
__version__numpy__, numpy.__version__))
209204

210205

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

214209

215-
major, minor1, minor2, s, tmp = sys.version_info
216-
_python27 = (major == 2 and minor1 >= 7)
217-
_python34 = (major == 3 and minor1 >= 4)
218-
219-
if not (_python27 or _python34):
220-
raise ImportError('matplotlib requires Python 2.7 or 3.4 or later')
221-
222-
223-
if not compare_versions(numpy.__version__, __version__numpy__):
224-
raise ImportError(
225-
'numpy %s or later is required; you have %s' % (
226-
__version__numpy__, numpy.__version__))
227-
228-
229210
def _is_writable_dir(p):
230211
"""
231212
p is a string pointing to a putative writable dir -- return True p
@@ -1452,7 +1433,7 @@ def _init_tests():
14521433
if (ft2font.__freetype_version__ != LOCAL_FREETYPE_VERSION or
14531434
ft2font.__freetype_build_type__ != 'local'):
14541435
warnings.warn(
1455-
"matplotlib is not built with the correct FreeType version to run "
1436+
"Matplotlib is not built with the correct FreeType version to run "
14561437
"tests. Set local_freetype=True in setup.cfg and rebuild. "
14571438
"Expect many image comparison failures below. "
14581439
"Expected freetype version {0}. "
@@ -1480,7 +1461,7 @@ def test(verbosity=None, coverage=False, switch_backend_warn=True,
14801461
"""run the matplotlib test suite"""
14811462
_init_tests()
14821463
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
1483-
raise ImportError("matplotlib test data is not installed")
1464+
raise ImportError("Matplotlib test data is not installed")
14841465

14851466
old_backend = get_backend()
14861467
old_recursionlimit = sys.getrecursionlimit()
@@ -1594,8 +1575,8 @@ def foo(ax, *args, **kwargs)
15941575

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

16001581
# if in a legacy version of python and IPython is already imported
16011582
# try to use their back-ported signature

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)