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

Skip to content

Commit c36902c

Browse files
QuLogictacaswell
authored andcommitted
Require Python 3 for installation.
This change is based on the work that IPython did for their transition to Python 3-only [1]. [1] https://www.youtube.com/watch?v=2DkfPzWWC2Q
1 parent e3442ae commit c36902c

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

lib/matplotlib/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
to MATLAB®, a registered trademark of The MathWorks, Inc.
100100
101101
"""
102+
# NOTE: This file must remain Python 2 compatible for the forseeable future,
103+
# to ensure that we error out properly for existing editable installs.
102104
from __future__ import absolute_import, division, print_function
103105

104106
import six
@@ -122,6 +124,17 @@
122124
import tempfile
123125
import warnings
124126

127+
if sys.version_info < (3, 5): # noqa: E402
128+
raise ImportError("""
129+
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
130+
Beginning with Matplotlib 3.0, Python 3.5 and above is required.
131+
132+
See Matplotlib `INSTALL.rst` file for more information:
133+
134+
https://github.com/matplotlib/matplotlib/blob/master/INSTALL.rst
135+
136+
""")
137+
125138
# cbook must import matplotlib only within function
126139
# definitions, so it is safe to import from it here.
127140
from . import cbook

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
setup.cfg.template for more information.
44
"""
55

6+
# NOTE: This file must remain Python 2 compatible for the forseeable future,
7+
# to ensure that we error out properly for people with outdated setuptools
8+
# and/or pip.
69
from __future__ import print_function, absolute_import
710
from string import Template
811
from setuptools import setup
@@ -265,6 +268,7 @@ def run(self):
265268
classifiers=classifiers,
266269
download_url="http://matplotlib.org/users/installing.html",
267270

271+
python_requires='>=3.5',
268272
# List third-party Python packages that we require
269273
install_requires=install_requires,
270274
setup_requires=setup_requires,

setupext.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# NOTE: This file must remain Python 2 compatible for the forseeable future,
2+
# to ensure that we error out properly for people with outdated setuptools
3+
# and/or pip.
14
from __future__ import print_function, absolute_import
25

36
from importlib import import_module
@@ -680,15 +683,16 @@ class Python(SetupPackage):
680683
def check(self):
681684
major, minor1, minor2, s, tmp = sys.version_info
682685

683-
if major < 2:
684-
raise CheckFailed(
685-
"Requires Python 2.7 or later")
686-
elif major == 2 and minor1 < 7:
687-
raise CheckFailed(
688-
"Requires Python 2.7 or later (in the 2.x series)")
689-
elif major == 3 and minor1 < 4:
690-
raise CheckFailed(
691-
"Requires Python 3.4 or later (in the 3.x series)")
686+
if major < 3 or minor1 < 5:
687+
error = """
688+
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
689+
Beginning with Matplotlib 3.0, Python 3.5 and above is required.
690+
691+
This may be due to an out of date pip.
692+
693+
Make sure you have pip >= 9.0.1.
694+
"""
695+
raise CheckFailed(error)
692696

693697
return sys.version
694698

0 commit comments

Comments
 (0)