Skip to content

Commit 9093edd

Browse files
committed
Simplify setupext by using globs.
1 parent d2e68ff commit 9093edd

File tree

2 files changed

+30
-57
lines changed

2 files changed

+30
-57
lines changed

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ def run(self):
260260
author_email="matplotlib-users@python.org",
261261
url="http://matplotlib.org",
262262
long_description="""
263-
matplotlib strives to produce publication quality 2D graphics
263+
Matplotlib strives to produce publication quality 2D graphics
264264
for interactive graphing, scientific publishing, user interface
265265
development and web application servers targeting multiple user
266266
interfaces and hardcopy output formats. There is a 'pylab' mode
267-
which emulates matlab graphics.
267+
which emulates MATLAB graphics.
268268
""",
269269
license="BSD",
270270
packages=packages,

setupext.py

+28-55
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
from __future__ import print_function, absolute_import
2-
3-
from importlib import import_module
4-
5-
from distutils import sysconfig
6-
from distutils import version
1+
from distutils import sysconfig, version
72
from distutils.core import Extension
83
import distutils.command.build_ext
94
import glob
105
import multiprocessing
116
import os
7+
import pathlib
128
import platform
139
import re
1410
import shutil
@@ -17,6 +13,8 @@
1713
import sys
1814
import warnings
1915
from textwrap import fill
16+
17+
import setuptools
2018
import versioneer
2119

2220

@@ -660,9 +658,7 @@ class Python(SetupPackage):
660658
name = "python"
661659

662660
def check(self):
663-
major, minor1, minor2, s, tmp = sys.version_info
664-
665-
if major < 3 or minor1 < 5:
661+
if sys.version_info < (3, 5):
666662
error = """
667663
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
668664
Beginning with Matplotlib 3.0, Python 3.5 and above is required.
@@ -672,7 +668,6 @@ def check(self):
672668
Make sure you have pip >= 9.0.1.
673669
"""
674670
raise CheckFailed(error)
675-
676671
return sys.version
677672

678673

@@ -683,55 +678,29 @@ def check(self):
683678
return versioneer.get_version()
684679

685680
def get_packages(self):
686-
return [
687-
'matplotlib',
688-
'matplotlib.backends',
689-
'matplotlib.backends.qt_editor',
690-
'matplotlib.compat',
691-
'matplotlib.projections',
692-
'matplotlib.axes',
693-
'matplotlib.sphinxext',
694-
'matplotlib.style',
695-
'matplotlib.testing',
696-
'matplotlib.testing._nose',
697-
'matplotlib.testing._nose.plugins',
698-
'matplotlib.testing.jpl_units',
699-
'matplotlib.tri',
700-
'matplotlib.cbook'
701-
]
681+
return setuptools.find_packages(
682+
"lib",
683+
include=["matplotlib", "matplotlib.*"],
684+
exclude=["matplotlib.tests", "matplotlib.*.tests"])
702685

703686
def get_py_modules(self):
704687
return ['pylab']
705688

706689
def get_package_data(self):
690+
691+
def iter_dir(base):
692+
return [
693+
str(path.relative_to('lib/matplotlib'))
694+
for path in pathlib.Path('lib/matplotlib', base).rglob('*')]
695+
707696
return {
708697
'matplotlib':
709698
[
710-
'mpl-data/fonts/afm/*.afm',
711-
'mpl-data/fonts/pdfcorefonts/*.afm',
712-
'mpl-data/fonts/pdfcorefonts/*.txt',
713-
'mpl-data/fonts/ttf/*.ttf',
714-
'mpl-data/fonts/ttf/LICENSE_STIX',
715-
'mpl-data/fonts/ttf/COPYRIGHT.TXT',
716-
'mpl-data/fonts/ttf/README.TXT',
717-
'mpl-data/fonts/ttf/RELEASENOTES.TXT',
718-
'mpl-data/images/*.xpm',
719-
'mpl-data/images/*.svg',
720-
'mpl-data/images/*.gif',
721-
'mpl-data/images/*.pdf',
722-
'mpl-data/images/*.png',
723-
'mpl-data/images/*.ppm',
724-
'mpl-data/example/*.npy',
725-
'mpl-data/matplotlibrc',
726-
'backends/web_backend/*.*',
727-
'backends/web_backend/js/*.*',
728-
'backends/web_backend/jquery/js/*.min.js',
729-
'backends/web_backend/jquery/css/themes/base/*.min.css',
730-
'backends/web_backend/jquery/css/themes/base/images/*',
731-
'backends/web_backend/css/*.*',
732-
'backends/Matplotlib.nib/*',
733-
'mpl-data/stylelib/*.mplstyle',
734-
]}
699+
*iter_dir('mpl-data/fonts'),
700+
*iter_dir('mpl-data/images'),
701+
*iter_dir('mpl-data/stylelib'),
702+
*iter_dir('backends/web_backend'),
703+
]}
735704

736705

737706
class SampleData(OptionalPackage):
@@ -742,11 +711,16 @@ class SampleData(OptionalPackage):
742711
name = "sample_data"
743712

744713
def get_package_data(self):
714+
715+
def iter_dir(base):
716+
return [
717+
str(path.relative_to('lib/matplotlib'))
718+
for path in pathlib.Path('lib/matplotlib', base).rglob('*')]
719+
745720
return {
746721
'matplotlib':
747722
[
748-
'mpl-data/sample_data/*.*',
749-
'mpl-data/sample_data/axes_grid/*.*',
723+
*iter_dir('mpl-data/sample_data'),
750724
]}
751725

752726

@@ -1432,9 +1406,8 @@ def check(self):
14321406
def runtime_check(self):
14331407
""" Checks whether TkAgg runtime dependencies are met
14341408
"""
1435-
pkg_name = 'tkinter'
14361409
try:
1437-
import_module(pkg_name)
1410+
import tkinter
14381411
except ImportError:
14391412
return False
14401413
return True

0 commit comments

Comments
 (0)