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

Skip to content

Check dependencies at runtime as declared in setup.py. #9638

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

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 10 additions & 9 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,20 @@ e.g., if the header of some required library is in
Dependencies
------------

Matplotlib requires a large number of dependencies:
Matplotlib requires the following dependencies:

* `Python <https://www.python.org/downloads/>`_ (>= 3.5)
* `NumPy <http://www.numpy.org>`_ (>= |minimum_numpy_version|)
* `setuptools <https://setuptools.readthedocs.io/en/latest/>`__
* `setuptools <https://setuptools.readthedocs.io/en/latest/>`_
* `NumPy <http://www.numpy.org>`_ (>= 1.10.0)
* `cycler <http://matplotlib.org/cycler/>`_ (>= 0.10.0)
* `dateutil <https://pypi.python.org/pypi/python-dateutil>`_ (>= 2.1)
* `pyparsing <https://pyparsing.wikispaces.com/>`__
* `libpng <http://www.libpng.org>`__ (>= 1.2)
* `pytz <http://pytz.sourceforge.net/>`__
* FreeType (>= 2.3)
* `cycler <http://matplotlib.org/cycler/>`__ (>= 0.10.0)
* `six <https://pypi.python.org/pypi/six>`_
* `kiwisolver <https://github.com/nucleic/kiwi>`__ (>= 1.0.0)
* `pyparsing <https://pyparsing.wikispaces.com/>`_ (>= 2.1.7; some older
versions may work)
* `pytz <http://pytz.sourceforge.net/>`_
* `six <https://pypi.python.org/pypi/six>`_ (>= 1.10)
* `FreeType <https://www.freetype.org>`_ (>= 2.3)
* `libpng <http://www.libpng.org>`_ (>= 1.2)

Optionally, you can also install a number of packages to enable better user
interface toolkits. See :ref:`what-is-a-backend` for more details on the
Expand Down
4 changes: 0 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ def _check_deps():
# documentation
autoclass_content = 'both'

rst_epilog = """
.. |minimum_numpy_version| replace:: %s
""" % matplotlib.__version__numpy__

texinfo_documents = [
("contents", 'matplotlib', 'Matplotlib Documentation',
'John Hunter@*Darren Dale@*Eric Firing@*Michael Droettboom@*'
Expand Down
88 changes: 45 additions & 43 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,25 @@

matplotlib was initially written by John D. Hunter (1968-2012) and is now
developed and maintained by a host of others.

Occasionally the internal documentation (python docstrings) will refer
to MATLAB&reg;, a registered trademark of The MathWorks, Inc.

"""
# NOTE: This file must remain Python 2 compatible for the foreseeable future,
# to ensure that we error out properly for existing editable installs.
from __future__ import absolute_import, division, print_function

import pkg_resources

try:
pkg_resources.get_distribution("matplotlib")
except pkg_resources.DistributionNotFound:
# Running from source -- you're on your own.
pass
else:
try:
# Check that dependencies are correctly installed.
pkg_resources.require("matplotlib")
except pkg_resources.ResolutionError as e:
raise ImportError("Matplotlib requires {}".format(e.req))

import six

import sys
Expand All @@ -120,8 +130,7 @@
import atexit
from collections import MutableMapping
import contextlib
import distutils.version
import distutils.sysconfig
from distutils.version import LooseVersion
import functools
import io
import inspect
Expand All @@ -137,16 +146,39 @@
import tempfile
import warnings

if sys.version_info < (3, 5): # noqa: E402
raise ImportError("""
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
Beginning with Matplotlib 3.0, Python 3.5 and above is required.

See Matplotlib `INSTALL.rst` file for more information:

https://github.com/matplotlib/matplotlib/blob/master/INSTALL.rst

""")

if sys.version_info < (3, 5): # noqa: E402
raise ImportError("""
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
Beginning with Matplotlib 3.0, Python 3.5 and above is required.

See Matplotlib `INSTALL.rst` file for more information:

https://github.com/matplotlib/matplotlib/blob/master/INSTALL.rst

""")

from six.moves.urllib.request import urlopen
from six.moves import reload_module as reload

import numpy

# cbook must import matplotlib only within function
# definitions, so it is safe to import from it here.
from . import cbook
from matplotlib.cbook import (
from .cbook import (
_backports, mplDeprecation, dedent, get_label, sanitize_sequence)
from matplotlib.rcsetup import defaultParams, validate_backend, cycler

import numpy
from six.moves.urllib.request import urlopen
from six.moves import reload_module as reload
from .rcsetup import defaultParams, validate_backend, cycler

# Get the version from the _version.py versioneer file. For a git checkout,
# this is computed based on the number of commits since the last tag.
Expand Down Expand Up @@ -191,41 +223,11 @@ def compare_versions(a, b):
a = a.decode('ascii')
if isinstance(b, bytes):
b = b.decode('ascii')
a = distutils.version.LooseVersion(a)
b = distutils.version.LooseVersion(b)
return a >= b
return LooseVersion(a) >= LooseVersion(b)
else:
return False


try:
import dateutil
except ImportError:
raise ImportError("Matplotlib requires dateutil")


if not compare_versions(six.__version__, '1.10'):
raise ImportError(
"Matplotlib requires six>=1.10; you have %s" % six.__version__)


try:
import pyparsing
except ImportError:
raise ImportError("Matplotlib requires pyparsing")
else:
if not compare_versions(pyparsing.__version__, '2.0.1'):
raise ImportError(
"Matplotlib requires pyparsing>=2.0.1; you have %s"
% pyparsing.__version__)


if not compare_versions(numpy.__version__, __version__numpy__):
raise ImportError(
"Matplotlib requires numpy>=%s; you have %s" % (
__version__numpy__, numpy.__version__))


if not hasattr(sys, 'argv'): # for modpython
sys.argv = [str('modpython')]

Expand Down
16 changes: 3 additions & 13 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,6 @@ def get_win32_compiler():
win32_compiler = get_win32_compiler()


def extract_versions():
"""
Extracts version values from the main matplotlib __init__.py and
returns them as a dictionary.
"""
with open('lib/matplotlib/__init__.py') as fd:
for line in fd.readlines():
if (line.startswith('__version__numpy__')):
exec(line.strip())
return locals()


def has_include_file(include_dirs, filename):
"""
Returns `True` if `filename` can be found in one of the
Expand Down Expand Up @@ -925,7 +913,8 @@ def include_dirs_hook():
return [numpy.get_include()]

def check(self):
min_version = extract_versions()['__version__numpy__']
# Remember to keep the version in INSTALL.rst in sync.
min_version = "1.7.1"
try:
import numpy
except ImportError:
Expand Down Expand Up @@ -1391,6 +1380,7 @@ def check(self):
return "handled by setuptools"

def get_install_requires(self):
# Remember to keep the list in INSTALL.rst in sync.
install_requires = [
"cycler>=0.10",
"pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6",
Expand Down