Skip to content

Commit fb52b96

Browse files
committed
Put the minimum required version of Numpy in one place.
1 parent bf73b90 commit fb52b96

File tree

5 files changed

+32
-19
lines changed

5 files changed

+32
-19
lines changed

INSTALL

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ progress::
4545
>>> import numpy
4646
>>> print numpy.__version__
4747

48-
matplotlib requires numpy version 1.4 or later. Although it is not a
49-
requirement to use matplotlib, we strongly encourage you to install
50-
`ipython <http://ipython.org>`_, which is an interactive
51-
shell for python that is matplotlib-aware.
48+
matplotlib requires numpy version |minimum_numpy_version| or later.
49+
Although it is not a requirement to use matplotlib, we strongly
50+
encourage you to install `ipython <http://ipython.org>`_, which is an
51+
interactive shell for python that is matplotlib-aware.
5252

5353
Next, we need to get matplotlib installed. We provide prebuilt
5454
binaries for OS X and Windows on the matplotlib `download
@@ -182,7 +182,7 @@ libraries themselves.
182182
:term:`python` 2.4 (or later but not python3)
183183
matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__)
184184

185-
:term:`numpy` 1.4 (or later)
185+
:term:`numpy` |minimum_numpy_version| (or later)
186186
array support for python (`download
187187
<http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__)
188188

doc/conf.py

+4
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,7 @@
182182
# Show both class-level docstring and __init__ docstring in class
183183
# documentation
184184
autoclass_content = 'both'
185+
186+
rst_epilog = """
187+
.. |minimum_numpy_version| replace:: %s
188+
""" % matplotlib.__version__numpy__

lib/matplotlib/__init__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
from __future__ import generators
101101

102102
__version__ = '1.1.0'
103+
__version__numpy__ = '1.4' # minimum required numpy version
103104

104105
import os, re, shutil, subprocess, sys, warnings
105106
import distutils.sysconfig
@@ -150,11 +151,17 @@
150151
if not _python24:
151152
raise ImportError('matplotlib requires Python 2.4 or later')
152153

154+
153155
import numpy
154-
nmajor, nminor = [int(n) for n in numpy.__version__.split('.')[:2]]
155-
if not (nmajor > 1 or (nmajor == 1 and nminor >= 4)):
156+
from distutils import version
157+
expected_version = version.StrictVersion(__version__numpy__)
158+
found_version = version.StrictVersion(numpy.__version__)
159+
if not found_version >= expected_version:
156160
raise ImportError(
157-
'numpy 1.4 or later is required; you have %s' % numpy.__version__)
161+
'numpy %s or later is required; you have %s' % (
162+
__version__numpy__, numpy.__version__))
163+
del version
164+
158165

159166
def is_string_like(obj):
160167
if hasattr(obj, 'shape'): return 0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def chop_package(fname):
113113
baseline_images = [chop_package(f) for f in baseline_images]
114114
package_data['matplotlib'].extend(baseline_images)
115115

116-
if not check_for_numpy():
116+
if not check_for_numpy(__version__numpy__):
117117
sys.exit(1)
118118

119119
if not check_for_freetype():

setupext.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import os
4747
import re
4848
import subprocess
49-
from distutils import sysconfig
49+
from distutils import sysconfig, version
5050

5151
basedir = {
5252
'win32' : ['win32_static',],
@@ -541,20 +541,22 @@ def check_for_pdftops():
541541
print_status("pdftops", "no")
542542
return False
543543

544-
def check_for_numpy():
544+
def check_for_numpy(min_version):
545545
try:
546546
import numpy
547547
except ImportError:
548548
print_status("numpy", "no")
549-
print_message("You must install numpy 1.4 or later to build matplotlib.")
549+
print_message("You must install numpy %s or later to build matplotlib." %
550+
min_version)
551+
return False
552+
553+
expected_version = version.StrictVersion(min_version)
554+
found_version = version.StrictVersion(numpy.__version__)
555+
if not found_version >= expected_version:
556+
print_message(
557+
'numpy %s or later is required; you have %s' %
558+
(min_version, numpy.__version__))
550559
return False
551-
nn = numpy.__version__.split('.')
552-
if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
553-
if not (int(nn[0]) >= 4):
554-
print_message(
555-
'numpy 1.4 or later is required; you have %s' %
556-
numpy.__version__)
557-
return False
558560
module = Extension('test', [])
559561
add_numpy_flags(module)
560562
add_base_flags(module)

0 commit comments

Comments
 (0)