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
162163def 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
181189try :
182190 import pyparsing
183191except ImportError :
184- raise ImportError ("matplotlib requires pyparsing" )
192+ raise ImportError ("Matplotlib requires pyparsing" )
185193else :
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
211206if 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-
229210def _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
0 commit comments