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

Skip to content

Workaround for Python 3 with pyparsing <= 2.0.0 #1927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,11 @@
except ImportError:
raise ImportError("matplotlib requires pyparsing")
else:
if sys.version_info[0] >= 3:
_required = [2, 0, 0]
else:
_required = [1, 5, 6]
_required = [1, 5, 6]
if [int(x) for x in pyparsing.__version__.split('.')] < _required:
raise ImportError(
"matplotlib requires pyparsing >= {0} on Python {1}".format(
'.'.join(str(x) for x in _required),
sys.version_info[0]))
"matplotlib requires pyparsing >= {0}".format(
'.'.join(str(x) for x in _required)))

import os, re, shutil, warnings
import distutils.sysconfig
Expand Down
9 changes: 8 additions & 1 deletion lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@
from numpy import inf, isinf
import numpy as np

import pyparsing
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()
if (sys.version_info[0] >= 3 and
[int(x) for x in pyparsing.__version__.split('.')] < [2, 0, 0]):
warn("Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing "
"has been disabled. Mathtext rendering will be much slower as a "
"result. Install pyparsing 2.0.0 or later to improve performance.")
else:
ParserElement.enablePackrat()

from matplotlib.afm import AFM
from matplotlib.cbook import Bunch, get_realpath_and_stat, \
Expand Down
2 changes: 1 addition & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def check(self):

def get_install_requires(self):
if sys.version_info[0] >= 3:
return ['pyparsing>=2.0.0']
return ['pyparsing>=1.5.6']
else:
# pyparsing >= 2.0.0 is not compatible with Python 2
return ['pyparsing>=1.5.6,<2.0.0']
Expand Down