Skip to content

Commit b17c66f

Browse files
authored
Merge pull request matplotlib#10425 from tacaswell/API_py3_only
API: only support python 3.5+
2 parents 86514a2 + 60cc718 commit b17c66f

File tree

10 files changed

+57
-83
lines changed

10 files changed

+57
-83
lines changed

.appveyor.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ environment:
1919
# theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,
2020
# one for 64bit because we construct envs anyway. But using one for the
2121
# right python version is hopefully making it fast due to package caching.
22-
- PYTHON_VERSION: "2.7"
23-
CONDA_INSTALL_LOCN: "C:\\Miniconda-x64"
24-
TEST_ALL: "no"
2522
- PYTHON_VERSION: "3.5"
2623
CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"
2724
TEST_ALL: "no"

.circleci/config.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ doc-bundle-run: &doc-bundle
8282
#
8383

8484
jobs:
85-
docs-python35:
85+
docs-python36:
8686
docker:
87-
- image: circleci/python:3.5
87+
- image: circleci/python:3.6
8888
steps:
8989
- checkout
9090

@@ -115,9 +115,9 @@ jobs:
115115
name: "Deploy new docs"
116116
command: ./.circleci/deploy-docs.sh
117117

118-
docs-python27:
118+
docs-python35:
119119
docker:
120-
- image: circleci/python:2.7
120+
- image: circleci/python:3.5
121121
steps:
122122
- checkout
123123

@@ -128,23 +128,14 @@ jobs:
128128
- run:
129129
<<: *deps-install
130130
environment:
131-
NUMPY_VERSION: "==1.7.1"
132-
# Linkchecker only works with python 2.7 for the time being.
133-
# Linkchecker is currently broken with requests 2.10.0 so force an earlier version.
134-
- run: pip install --user $PRE requests==2.9.2 linkchecker
131+
NUMPY_VERSION: "==1.10.0"
135132
- run: *mpl-install
136133

137134
- run: *doc-build
138135

139136
# We don't build the LaTeX docs here, so linkchecker will complain
140137
- run: touch doc/build/html/Matplotlib.pdf
141138

142-
# Linkchecker only works with python 2.7 for the time being
143-
- run:
144-
name: linkchecker
145-
command: ~/.local/bin/linkchecker build/html/index.html
146-
working_directory: doc
147-
148139
- run: *doc-bundle
149140
- store_artifacts:
150141
path: doc/build/sphinx-gallery-files.tar.gz
@@ -166,4 +157,4 @@ workflows:
166157
build:
167158
jobs:
168159
- docs-python35
169-
- docs-python27
160+
- docs-python36

.travis.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,20 @@ env:
6565

6666
matrix:
6767
include:
68-
- python: 2.7
68+
- python: 3.5
6969
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124.
7070
env:
7171
- CYCLER=cycler==0.10
7272
- DATEUTIL=python-dateutil==2.1
7373
- MOCK=mock
7474
- NOSE=nose
75-
- NUMPY=numpy==1.7.1
75+
- NUMPY=numpy==1.10.0
7676
- PANDAS='pandas<0.21.0'
7777
- PYPARSING=pyparsing==2.0.1
7878
- PYTEST=pytest==3.1.0
7979
- PYTEST_COV=pytest-cov==2.3.1
8080
- SPHINX=sphinx==1.3
81-
- python: 3.4
81+
- python: 3.5
8282
env: PYTHON_ARGS=-OO
8383
- python: 3.6
8484
env: DELETE_FONT_CACHE=1 PANDAS='pandas<0.21.0' PYTEST_PEP8=pytest-pep8 RUN_PEP8=--pep8
@@ -110,8 +110,12 @@ before_install:
110110
export PATH=/usr/lib/ccache:$PATH
111111
else
112112
brew update
113-
brew tap homebrew/gui
114-
brew install python libpng ffmpeg imagemagick mplayer ccache
113+
brew install python3 libpng ffmpeg imagemagick mplayer ccache
114+
# make 'python' mean 'python3'
115+
ln -sf /usr/local/bin/python3 /usr/local/bin/python
116+
hash -r
117+
which python
118+
python --version
115119
# We could install ghostscript and inkscape here to test svg and pdf
116120
# but this makes the test time really long.
117121
# brew install ghostscript inkscape
@@ -126,10 +130,10 @@ install:
126130
ccache -s
127131
git describe
128132
# Upgrade pip and setuptools and wheel to get as clean an install as possible
129-
pip install --upgrade pip setuptools wheel
133+
python -mpip install --upgrade pip setuptools wheel
130134
- |
131135
# Install dependencies from PyPI
132-
pip install --upgrade $PRE \
136+
python -mpip install --upgrade $PRE \
133137
codecov \
134138
coverage \
135139
$CYCLER \
@@ -148,22 +152,22 @@ install:
148152
# install was successful by trying to import the toolkit (sometimes, the
149153
# install appears to be successful but shared libraries cannot be loaded at
150154
# runtime, so an actual import is a better check).
151-
pip install cairocffi pgi &&
155+
python -mpip install cairocffi pgi &&
152156
python -c 'import pgi as gi; gi.require_version("Gtk", "3.0"); from pgi.repository import Gtk' &&
153157
echo 'pgi is available' ||
154158
echo 'pgi is not available'
155-
pip install pyqt5==5.9 &&
159+
python -mpip install pyqt5==5.9 &&
156160
python -c 'import PyQt5.QtCore' &&
157161
echo 'PyQt5 is available' ||
158162
echo 'PyQt5 is not available'
159-
pip install -U --pre \
163+
python -mpip install -U --pre \
160164
--no-index -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \
161165
wxPython &&
162166
python -c 'import wx' &&
163167
echo 'wxPython is available' ||
164168
echo 'wxPython is not available'
165169
166-
pip install $PRE \
170+
python -mpip install $PRE \
167171
$PYTEST \
168172
$PYTEST_COV \
169173
pytest-faulthandler \
@@ -176,7 +180,7 @@ install:
176180
cp ci/travis/setup.cfg .
177181
- |
178182
# Install matplotlib
179-
pip install -ve .
183+
python -mpip install -ve .
180184
181185
before_script:
182186
- |

INSTALL.rst

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,14 @@ Although not required, we suggest also installing ``IPython`` for
3232
interactive use. To easily install a complete Scientific Python
3333
stack, see :ref:`install_scipy_dists` below.
3434

35-
.. _installing_windows:
36-
37-
Windows
38-
-------
39-
40-
In case Python 2.7 or 3.4 are not installed for all users,
41-
the Microsoft Visual C++ 2008
42-
(`64 bit <https://www.microsoft.com/en-us/download/details.aspx?id=15336>`__
43-
or
44-
`32 bit <https://www.microsoft.com/en-us/download/details.aspx?id=29>`__
45-
for Python 2.7) or Microsoft Visual C++ 2010
46-
(`64 bit <https://www.microsoft.com/en-us/download/details.aspx?id=14632>`__
47-
or
48-
`32 bit <https://www.microsoft.com/en-us/download/details.aspx?id=5555>`__
49-
for Python 3.4) redistributable packages need to be installed.
5035

5136
macOS
5237
-----
5338

54-
If you are using Python 2.7 on a Mac you may need to do::
55-
56-
xcode-select --install
57-
58-
so that *subprocess32*, a dependency, may be compiled.
59-
6039
To use the native OSX backend you will need :ref:`a framework build
6140
<osxframework-faq>` build of Python.
6241

6342

64-
Linux
65-
-----
66-
67-
On extremely old versions of Linux and Python 2.7 you may need to
68-
install the master version of *subprocess32* (`see comments
69-
<https://github.com/google/python-subprocess32/issues/12#issuecomment-304724113>`__).
70-
71-
7243
Test Data
7344
---------
7445

@@ -167,7 +138,7 @@ Dependencies
167138

168139
Matplotlib requires a large number of dependencies:
169140

170-
* `Python <https://www.python.org/downloads/>`_ (>= 2.7 or >= 3.4)
141+
* `Python <https://www.python.org/downloads/>`_ (>= 3.5)
171142
* `NumPy <http://www.numpy.org>`_ (>= |minimum_numpy_version|)
172143
* `setuptools <https://setuptools.readthedocs.io/en/latest/>`__
173144
* `dateutil <https://pypi.python.org/pypi/python-dateutil>`_ (>= 2.1)
@@ -177,10 +148,6 @@ Matplotlib requires a large number of dependencies:
177148
* FreeType (>= 2.3)
178149
* `cycler <http://matplotlib.org/cycler/>`__ (>= 0.10.0)
179150
* `six <https://pypi.python.org/pypi/six>`_
180-
* `backports.functools_lru_cache <https://pypi.python.org/pypi/backports.functools_lru_cache>`_
181-
(for Python 2.7 only)
182-
* `subprocess32 <https://pypi.python.org/pypi/subprocess32/>`_ (for Python
183-
2.7 only, on Linux and macOS only)
184151
* `kiwisolver <https://github.com/nucleic/kiwi>`__ (>= 1.0.0)
185152

186153
Optionally, you can also install a number of packages to enable better user
@@ -325,8 +292,6 @@ without fiddling with environment variables::
325292
conda install pyqt
326293
# this package is only available in the conda-forge channel
327294
conda install -c conda-forge msinttypes
328-
# for Python 2.7
329-
conda install -c conda-forge backports.functools_lru_cache
330295

331296
# copy the libs which have "wrong" names
332297
set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\Library\lib

ci/travis/test_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ fi
1717

1818
echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
1919

20-
pytest $PYTEST_ARGS $RUN_PEP8
20+
python -mpytest $PYTEST_ARGS $RUN_PEP8

doc/faq/installing_faq.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,6 @@ the disk image installer only works for Python.org Python, and will not get
216216
picked up by other Pythons. If all these fail, please :ref:`let us know
217217
<reporting-problems>`.
218218

219-
Windows Notes
220-
=============
221-
222-
See :ref:`installing_windows`.
223-
224219
.. _install-from-git:
225220

226221
Install from source

lib/matplotlib/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
to MATLAB&reg;, 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
@@ -142,7 +155,7 @@
142155

143156
_log = logging.getLogger(__name__)
144157

145-
__version__numpy__ = str('1.7.1') # minimum required numpy version
158+
__version__numpy__ = str('1.10.0') # minimum required numpy version
146159

147160
__bibtex__ = r"""@Article{Hunter:2007,
148161
Author = {Hunter, J. D.},

lib/matplotlib/dates.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def _dt64_to_ordinalf(d):
283283

284284
# the "extra" ensures that we at least allow the dynamic range out to
285285
# seconds. That should get out to +/-2e11 years.
286-
extra = d - d.astype('datetime64[s]')
286+
# NOTE: First cast truncates; second cast back is for NumPy 1.10.
287+
extra = d - d.astype('datetime64[s]').astype(d.dtype)
287288
extra = extra.astype('timedelta64[ns]')
288289
t0 = np.datetime64('0001-01-01T00:00:00').astype('datetime64[s]')
289290
dt = (d.astype('datetime64[s]') - t0).astype(np.float64)

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)