diff --git a/lib/matplotlib/fontconfig_pattern.py b/lib/matplotlib/fontconfig_pattern.py index de32d84eafca..5f14add8bf47 100644 --- a/lib/matplotlib/fontconfig_pattern.py +++ b/lib/matplotlib/fontconfig_pattern.py @@ -21,12 +21,8 @@ from __future__ import print_function import re, sys -if sys.version_info[0] >= 3: - from matplotlib.pyparsing_py3 import Literal, ZeroOrMore, \ - Optional, Regex, StringEnd, ParseException, Suppress -else: - from matplotlib.pyparsing_py2 import Literal, ZeroOrMore, \ - Optional, Regex, StringEnd, ParseException, Suppress +from pyparsing import Literal, ZeroOrMore, Optional, Regex, StringEnd, \ + ParseException, Suppress family_punc = r'\\\-:,' family_unescape = re.compile(r'\\([%s])' % family_punc).sub diff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py index 3742aecf0e1e..72d4214ee5dc 100644 --- a/lib/matplotlib/mathtext.py +++ b/lib/matplotlib/mathtext.py @@ -34,16 +34,10 @@ from numpy import inf, isinf import numpy as np -if sys.version_info[0] >= 3: - from matplotlib.pyparsing_py3 import Combine, Group, Optional, Forward, \ - Literal, OneOrMore, ZeroOrMore, ParseException, Empty, \ - ParseResults, Suppress, oneOf, StringEnd, ParseFatalException, \ - FollowedBy, Regex, ParserElement, QuotedString, ParseBaseException -else: - from matplotlib.pyparsing_py2 import Combine, Group, Optional, Forward, \ - Literal, OneOrMore, ZeroOrMore, ParseException, Empty, \ - ParseResults, Suppress, oneOf, StringEnd, ParseFatalException, \ - FollowedBy, Regex, ParserElement, QuotedString, ParseBaseException +from pyparsing import Combine, Group, Optional, Forward, \ + Literal, OneOrMore, ZeroOrMore, ParseException, Empty, \ + ParseResults, Suppress, oneOf, StringEnd, ParseFatalException, \ + FollowedBy, Regex, ParserElement, QuotedString, ParseBaseException # Enable packrat parsing ParserElement.enablePackrat() diff --git a/lib/pyparsing_py2/__init__.py b/lib/pyparsing_py2/__init__.py new file mode 100644 index 000000000000..82c153139f35 --- /dev/null +++ b/lib/pyparsing_py2/__init__.py @@ -0,0 +1,85 @@ +# module pyparsing.py +# +# Copyright (c) 2003-2010 Paul T. McGuire +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +#from __future__ import generators + +__doc__ = \ +""" +pyparsing module - Classes and methods to define and execute parsing grammars + +The pyparsing module is an alternative approach to creating and executing simple grammars, +vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you +don't need to learn a new syntax for defining grammars or matching expressions - the parsing module +provides a library of classes that you use to construct the grammar directly in Python. + +Here is a program to parse "Hello, World!" (or any greeting of the form C{", !"}):: + + from pyparsing import Word, alphas + + # define grammar of a greeting + greet = Word( alphas ) + "," + Word( alphas ) + "!" + + hello = "Hello, World!" + print hello, "->", greet.parseString( hello ) + +The program outputs the following:: + + Hello, World! -> ['Hello', ',', 'World', '!'] + +The Python representation of the grammar is quite readable, owing to the self-explanatory +class names, and the use of '+', '|' and '^' operators. + +The parsed results returned from C{parseString()} can be accessed as a nested list, a dictionary, or an +object with named attributes. + +The pyparsing module handles some of the problems that are typically vexing when writing text parsers: + - extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.) + - quoted strings + - embedded comments +""" + +__version__ = "1.5.5" +__versionTime__ = "12 Aug 2010 03:56" +__author__ = "Paul McGuire " + +__all__ = [ +'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty', +'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal', +'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or', +'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException', +'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException', +'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter', 'Upcase', +'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore', +'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col', +'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString', +'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'getTokensEndLoc', 'hexnums', +'htmlComment', 'javaStyleComment', 'keepOriginalText', 'line', 'lineEnd', 'lineStart', 'lineno', +'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral', +'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables', +'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity', +'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd', +'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute', +'indentedBlock', 'originalTextFor', +] + +from .pyparsing import * diff --git a/lib/matplotlib/pyparsing_py2.py b/lib/pyparsing_py2/pyparsing.py similarity index 97% rename from lib/matplotlib/pyparsing_py2.py rename to lib/pyparsing_py2/pyparsing.py index ac94ff331fbd..1c7565f1a742 100644 --- a/lib/matplotlib/pyparsing_py2.py +++ b/lib/pyparsing_py2/pyparsing.py @@ -23,45 +23,6 @@ # #from __future__ import generators -__doc__ = \ -""" -pyparsing module - Classes and methods to define and execute parsing grammars - -The pyparsing module is an alternative approach to creating and executing simple grammars, -vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you -don't need to learn a new syntax for defining grammars or matching expressions - the parsing module -provides a library of classes that you use to construct the grammar directly in Python. - -Here is a program to parse "Hello, World!" (or any greeting of the form C{", !"}):: - - from pyparsing import Word, alphas - - # define grammar of a greeting - greet = Word( alphas ) + "," + Word( alphas ) + "!" - - hello = "Hello, World!" - print hello, "->", greet.parseString( hello ) - -The program outputs the following:: - - Hello, World! -> ['Hello', ',', 'World', '!'] - -The Python representation of the grammar is quite readable, owing to the self-explanatory -class names, and the use of '+', '|' and '^' operators. - -The parsed results returned from C{parseString()} can be accessed as a nested list, a dictionary, or an -object with named attributes. - -The pyparsing module handles some of the problems that are typically vexing when writing text parsers: - - extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.) - - quoted strings - - embedded comments -""" - -__version__ = "1.5.5" -__versionTime__ = "12 Aug 2010 03:56" -__author__ = "Paul McGuire " - import string from weakref import ref as wkref import copy @@ -71,25 +32,6 @@ class names, and the use of '+', '|' and '^' operators. import sre_constants #~ sys.stderr.write( "testing pyparsing module, version %s, %s\n" % (__version__,__versionTime__ ) ) -__all__ = [ -'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty', -'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal', -'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or', -'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException', -'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException', -'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter', 'Upcase', -'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore', -'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col', -'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString', -'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'getTokensEndLoc', 'hexnums', -'htmlComment', 'javaStyleComment', 'keepOriginalText', 'line', 'lineEnd', 'lineStart', 'lineno', -'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral', -'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables', -'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity', -'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd', -'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute', -'indentedBlock', 'originalTextFor', -] """ Detect if we are running version 3.X and make appropriate changes @@ -133,10 +75,10 @@ def _ustr(obj): # Replace unprintables with question marks? #return unicode(obj).encode(sys.getdefaultencoding(), 'replace') # ... - + def _str2dict(strg): return dict( [(c,0) for c in strg] ) - + alphas = string.lowercase + string.uppercase # build list of single arg builtins, tolerant of Python version, that can be used as parse actions @@ -433,7 +375,7 @@ def __iadd__( self, other ): self[k] = v if isinstance(v[0],ParseResults): v[0].__parent = wkref(self) - + self.__toklist += other.__toklist self.__accumNames.update( other.__accumNames ) return self @@ -441,7 +383,7 @@ def __iadd__( self, other ): def __radd__(self, other): if isinstance(other,int) and other == 0: return self.copy() - + def __repr__( self ): return "(%s, %s)" % ( repr( self.__toklist ), repr( self.__tokdict ) ) @@ -725,9 +667,9 @@ def setResultsName( self, name, listAllMatches=False ): NOTE: this returns a *copy* of the original C{ParserElement} object; this is so that the client can define a basic element, such as an integer, and reference it in multiple places with different names. - + You can also set results names using the abbreviated syntax, - C{expr("name")} in place of C{expr.setResultsName("name")} - + C{expr("name")} in place of C{expr.setResultsName("name")} - see L{I{__call__}<__call__>}. """ newself = self.copy() @@ -788,7 +730,7 @@ def _normalizeParseActionArgs( f ): call_im_func_code = f.__call__.im_func.func_code else: call_im_func_code = f.__code__ - + # not a function, must be a callable object, get info from the # im_func binding of its bound __call__ method if call_im_func_code.co_flags & STAR_ARGS: @@ -1814,10 +1756,10 @@ def __init__( self, pattern, flags=0): if len(pattern) == 0: warnings.warn("null string passed to Regex; use Empty() instead", SyntaxWarning, stacklevel=2) - + self.pattern = pattern self.flags = flags - + try: self.re = re.compile(self.pattern, self.flags) self.reString = self.pattern @@ -1831,7 +1773,7 @@ def __init__( self, pattern, flags=0): self.pattern = \ self.reString = str(pattern) self.flags = flags - + else: raise ValueError("Regex may only be constructed with a string or a compiled RE object") @@ -3347,12 +3289,12 @@ def originalTextFor(expr, asString=True): restore the parsed fields of an HTML start tag into the raw tag text itself, or to revert separate tokens with intervening whitespace back to the original matching input text. Simpler to use than the parse action C{keepOriginalText}, and does not - require the inspect module to chase up the call stack. By default, returns a - string containing the original parsed text. - - If the optional C{asString} argument is passed as False, then the return value is a - C{ParseResults} containing any results names that were originally matched, and a - single token containing the original matched text from the input string. So if + require the inspect module to chase up the call stack. By default, returns a + string containing the original parsed text. + + If the optional C{asString} argument is passed as False, then the return value is a + C{ParseResults} containing any results names that were originally matched, and a + single token containing the original matched text from the input string. So if the expression passed to C{originalTextFor} contains expressions with defined results names, you must set C{asString} to False if you want to preserve those results name values.""" @@ -3370,7 +3312,7 @@ def extractText(s,l,t): del t["_original_end"] matchExpr.setParseAction(extractText) return matchExpr - + # convenience constants for positional expressions empty = Empty().setName("empty") lineStart = LineStart().setName("lineStart") @@ -3652,7 +3594,7 @@ def nestedExpr(opener="(", closer=")", content=None, ignoreExpr=quotedString.cop ).setParseAction(lambda t:t[0].strip())) else: if ignoreExpr is not None: - content = (Combine(OneOrMore(~ignoreExpr + + content = (Combine(OneOrMore(~ignoreExpr + ~Literal(opener) + ~Literal(closer) + CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS,exact=1)) ).setParseAction(lambda t:t[0].strip())) diff --git a/lib/pyparsing_py3/__init__.py b/lib/pyparsing_py3/__init__.py new file mode 100644 index 000000000000..82c153139f35 --- /dev/null +++ b/lib/pyparsing_py3/__init__.py @@ -0,0 +1,85 @@ +# module pyparsing.py +# +# Copyright (c) 2003-2010 Paul T. McGuire +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +#from __future__ import generators + +__doc__ = \ +""" +pyparsing module - Classes and methods to define and execute parsing grammars + +The pyparsing module is an alternative approach to creating and executing simple grammars, +vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you +don't need to learn a new syntax for defining grammars or matching expressions - the parsing module +provides a library of classes that you use to construct the grammar directly in Python. + +Here is a program to parse "Hello, World!" (or any greeting of the form C{", !"}):: + + from pyparsing import Word, alphas + + # define grammar of a greeting + greet = Word( alphas ) + "," + Word( alphas ) + "!" + + hello = "Hello, World!" + print hello, "->", greet.parseString( hello ) + +The program outputs the following:: + + Hello, World! -> ['Hello', ',', 'World', '!'] + +The Python representation of the grammar is quite readable, owing to the self-explanatory +class names, and the use of '+', '|' and '^' operators. + +The parsed results returned from C{parseString()} can be accessed as a nested list, a dictionary, or an +object with named attributes. + +The pyparsing module handles some of the problems that are typically vexing when writing text parsers: + - extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.) + - quoted strings + - embedded comments +""" + +__version__ = "1.5.5" +__versionTime__ = "12 Aug 2010 03:56" +__author__ = "Paul McGuire " + +__all__ = [ +'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty', +'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal', +'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or', +'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException', +'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException', +'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter', 'Upcase', +'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore', +'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col', +'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString', +'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'getTokensEndLoc', 'hexnums', +'htmlComment', 'javaStyleComment', 'keepOriginalText', 'line', 'lineEnd', 'lineStart', 'lineno', +'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral', +'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables', +'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity', +'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd', +'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute', +'indentedBlock', 'originalTextFor', +] + +from .pyparsing import * diff --git a/lib/matplotlib/pyparsing_py3.py b/lib/pyparsing_py3/pyparsing.py similarity index 97% rename from lib/matplotlib/pyparsing_py3.py rename to lib/pyparsing_py3/pyparsing.py index c0e0af2e98bd..bc85f39c09d1 100644 --- a/lib/matplotlib/pyparsing_py3.py +++ b/lib/pyparsing_py3/pyparsing.py @@ -23,45 +23,6 @@ # #from __future__ import generators -__doc__ = \ -""" -pyparsing module - Classes and methods to define and execute parsing grammars - -The pyparsing module is an alternative approach to creating and executing simple grammars, -vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you -don't need to learn a new syntax for defining grammars or matching expressions - the parsing module -provides a library of classes that you use to construct the grammar directly in Python. - -Here is a program to parse "Hello, World!" (or any greeting of the form C{", !"}):: - - from pyparsing import Word, alphas - - # define grammar of a greeting - greet = Word( alphas ) + "," + Word( alphas ) + "!" - - hello = "Hello, World!" - print hello, "->", greet.parseString( hello ) - -The program outputs the following:: - - Hello, World! -> ['Hello', ',', 'World', '!'] - -The Python representation of the grammar is quite readable, owing to the self-explanatory -class names, and the use of '+', '|' and '^' operators. - -The parsed results returned from C{parseString()} can be accessed as a nested list, a dictionary, or an -object with named attributes. - -The pyparsing module handles some of the problems that are typically vexing when writing text parsers: - - extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.) - - quoted strings - - embedded comments -""" - -__version__ = "1.5.5" -__versionTime__ = "12 Aug 2010 03:56" -__author__ = "Paul McGuire " - import string from weakref import ref as wkref import copy @@ -72,26 +33,6 @@ class names, and the use of '+', '|' and '^' operators. import collections #~ sys.stderr.write( "testing pyparsing module, version %s, %s\n" % (__version__,__versionTime__ ) ) -__all__ = [ -'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty', -'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal', -'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or', -'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException', -'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException', -'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter', 'Upcase', -'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore', -'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col', -'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString', -'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'getTokensEndLoc', 'hexnums', -'htmlComment', 'javaStyleComment', 'keepOriginalText', 'line', 'lineEnd', 'lineStart', 'lineno', -'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral', -'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables', -'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity', -'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd', -'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute', -'indentedBlock', 'originalTextFor', -] - """ Detect if we are running version 3.X and make appropriate changes Robert A. Clark diff --git a/setup.cfg.template b/setup.cfg.template index 2cf7e53c6ad9..51411f34b1c2 100644 --- a/setup.cfg.template +++ b/setup.cfg.template @@ -28,6 +28,7 @@ ## Date/timezone support: #pytz = False #dateutil = False +#pyparsing = False #six = False [gui_support] diff --git a/setup.py b/setup.py index 08261b47616a..53379b3049d5 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \ check_for_tk, check_for_macosx, check_for_numpy, \ check_for_qt, check_for_qt4, check_for_pyside, check_for_cairo, \ - check_provide_pytz, check_provide_dateutil,\ + check_provide_pytz, check_provide_dateutil, check_provide_pyparsing, \ check_for_dvipng, check_for_ghostscript, check_for_latex, \ check_for_pdftops, options, build_png, build_tri, check_provide_six @@ -192,6 +192,7 @@ def chop_package(fname): provide_dateutil = check_provide_dateutil() provide_pytz = check_provide_pytz() +provide_pyparsing = check_provide_pyparsing() provide_six = check_provide_six() def add_pytz(): @@ -220,6 +221,13 @@ def add_dateutil(): else: package_dir['dateutil'] = 'lib/dateutil_py2' +def add_pyparsing(): + packages.append('pyparsing') + if sys.version_info[0] >= 3: + package_dir['pyparsing'] = 'lib/pyparsing_py3' + else: + package_dir['pyparsing'] = 'lib/pyparsing_py2' + def add_six(): py_modules.append('six') @@ -227,6 +235,7 @@ def add_six(): # always add these to the win32 installer add_pytz() add_dateutil() + add_pyparsing() add_six() else: # only add them if we need them @@ -235,6 +244,8 @@ def add_six(): print_raw("adding pytz") if provide_dateutil: add_dateutil() + if provide_pyparsing: + add_pyparsing() if provide_six: add_six() @@ -267,6 +278,7 @@ def should_2to3(file, root): if ('py3' in file or file.startswith('pytz') or file.startswith('dateutil') or + file.startswith('pyparsing') or file.startswith('six')): return False return True diff --git a/setupext.py b/setupext.py index e894be3274f2..127dca05a586 100644 --- a/setupext.py +++ b/setupext.py @@ -106,6 +106,7 @@ options = {'display_status': True, 'verbose': False, 'provide_pytz': 'auto', + 'provide_pyparsing': 'auto', 'provide_dateutil': 'auto', 'provide_six': 'auto', 'build_agg': True, @@ -140,6 +141,10 @@ try: options['provide_pytz'] = config.getboolean("provide_packages", "pytz") except: options['provide_pytz'] = 'auto' + try: options['provide_pyparsing'] = config.getboolean("provide_packages", + "pyparsing") + except: options['provide_pyparsing'] = 'auto' + try: options['provide_dateutil'] = config.getboolean("provide_packages", "dateutil") except: options['provide_dateutil'] = 'auto' @@ -457,6 +462,31 @@ def check_provide_pytz(): print_status("pytz", pytz.__version__) return False +def check_provide_pyparsing(): + if options['provide_pyparsing'] is True: + print_status("pyparsing", "matplotlib will provide") + return True + try: + import pyparsing + except ImportError: + if options['provide_pyparsing']: + print_status("pyparsing", "matplotlib will provide") + return True + else: + print_status("pyparsing", "no") + return False + else: + try: + if pyparsing.__version__.endswith('mpl'): + print_status("pyparsing", "matplotlib will provide") + return True + else: + print_status("pyparsing", pyparsing.__version__) + return False + except AttributeError: + print_status("pyparsing", "present, version unknown") + return False + def check_provide_dateutil(): if options['provide_dateutil'] is True: print_status("dateutil", "matplotlib will provide")