File tree Expand file tree Collapse file tree 2 files changed +26
-14
lines changed Expand file tree Collapse file tree 2 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -128,18 +128,21 @@ def compare_versions(a, b):
128
128
raise ImportError (
129
129
"matplotlib requires pyparsing >= 1.5.6" )
130
130
131
- if pyparsing .__version__ == '2.0.0' :
132
- raise ImportError (
133
- "pyparsing 2.0.0 has bugs that prevent its use with "
134
- "matplotlib" )
131
+ # pyparsing 2.0.0 bug, but it may be patched in distributions
132
+ try :
133
+ f = pyparsing .Forward ()
134
+ f <<= pyparsing .Literal ('a' )
135
+ bad_pyparsing = f is None
136
+ except :
137
+ bad_pyparsing = True
135
138
136
139
# pyparsing 1.5.6 does not have <<= on the Forward class, but
137
140
# pyparsing 2.0.0 and later will spew deprecation warnings if
138
141
# using << instead. Additionally, the <<= in pyparsing 1.5.7 is
139
142
# broken, since it doesn't return self. In order to support
140
143
# pyparsing 1.5.6 and above with a common code base, this small
141
144
# monkey patch is applied.
142
- if not compare_versions ( pyparsing . __version__ , '2.0.1' ) :
145
+ if bad_pyparsing :
143
146
def _forward_ilshift (self , other ):
144
147
self .__lshift__ (other )
145
148
return self
Original file line number Diff line number Diff line change @@ -949,6 +949,16 @@ def get_install_requires(self):
949
949
class Pyparsing (SetupPackage ):
950
950
name = "pyparsing"
951
951
952
+ def is_ok (self ):
953
+ # pyparsing 2.0.0 bug, but it may be patched in distributions
954
+ try :
955
+ import pyparsing
956
+ f = pyparsing .Forward ()
957
+ f <<= pyparsing .Literal ('a' )
958
+ return f is not None
959
+ except :
960
+ return False
961
+
952
962
def check (self ):
953
963
try :
954
964
import pyparsing
@@ -964,19 +974,18 @@ def check(self):
964
974
"matplotlib requires pyparsing >= {0}" .format (
965
975
'.' .join (str (x ) for x in required )))
966
976
967
- if pyparsing .__version__ == "2.0.0" :
968
- if sys .version_info [0 ] == 2 :
969
- return (
970
- "pyparsing 2.0.0 is not compatible with Python 2.x" )
971
- else :
972
- return (
973
- "pyparsing 2.0.0 has bugs that prevent its use with "
974
- "matplotlib" )
977
+ if not self .is_ok ():
978
+ return (
979
+ "pyparsing 2.0.0 has bugs that prevent its use with "
980
+ "matplotlib" )
975
981
976
982
return "using pyparsing version %s" % pyparsing .__version__
977
983
978
984
def get_install_requires (self ):
979
- return ['pyparsing>=1.5.6,!=2.0.0' ]
985
+ if self .is_ok ():
986
+ return ['pyparsing>=1.5.6' ]
987
+ else :
988
+ return ['pyparsing>=1.5.6,!=2.0.0' ]
980
989
981
990
982
991
class BackendAgg (OptionalBackendPackage ):
You can’t perform that action at this time.
0 commit comments