forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupext.py
1764 lines (1437 loc) · 53.9 KB
/
setupext.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import print_function, absolute_import
from distutils import sysconfig
from distutils import version
from distutils.core import Extension
import glob
import io
import multiprocessing
import os
import re
import subprocess
import sys
from textwrap import fill
try:
from subprocess import check_output
except ImportError:
# check_output is not available in Python 2.6
def check_output(*popenargs, **kwargs):
"""
Run command with arguments and return its output as a byte
string.
Backported from Python 2.7 as it's implemented as pure python
on stdlib.
"""
process = subprocess.Popen(
stdout=subprocess.PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
error = subprocess.CalledProcessError(retcode, cmd)
error.output = output
raise error
return output
if sys.platform != 'win32':
if sys.version_info[0] < 3:
from commands import getstatusoutput
else:
from subprocess import getstatusoutput
if sys.version_info[0] < 3:
import ConfigParser as configparser
else:
import configparser
# matplotlib build options, which can be altered using setup.cfg
options = {
'display_status': True,
'verbose': False,
'backend': None,
'basedirlist': None
}
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
if os.path.exists(setup_cfg):
config = configparser.SafeConfigParser()
config.read(setup_cfg)
try:
options['display_status'] = not config.getboolean("status", "suppress")
except:
pass
try:
options['backend'] = config.get("rc_options", "backend")
except:
pass
try:
options['basedirlist'] = [
x.strip() for x in
config.get("directories", "basedirlist").split(',')]
except:
pass
else:
config = None
def get_win32_compiler():
"""
Determine the compiler being used on win32.
"""
# Used to determine mingw32 or msvc
# This is pretty bad logic, someone know a better way?
for v in sys.argv:
if 'mingw32' in v:
return 'mingw32'
return 'msvc'
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__')):
exec(line.strip())
return locals()
def has_include_file(include_dirs, filename):
"""
Returns `True` if `filename` can be found in one of the
directories in `include_dirs`.
"""
for dir in include_dirs:
if os.path.exists(os.path.join(dir, filename)):
return True
return False
def check_include_file(include_dirs, filename, package):
"""
Raises an exception if the given include file can not be found.
"""
if sys.platform == 'win32':
include_dirs.extend(os.getenv('INCLUDE', '.').split(';'))
if not has_include_file(include_dirs, filename):
raise CheckFailed(
"The C/C++ header for %s (%s) could not be found. You "
"may need to install the development package." %
(package, filename))
def get_base_dirs():
"""
Returns a list of standard base directories on this platform.
"""
if options['basedirlist']:
return options['basedirlist']
basedir_map = {
'win32': ['win32_static',],
'darwin': ['/usr/local/', '/usr', '/usr/X11', '/opt/local'],
'sunos5': [os.getenv('MPLIB_BASE') or '/usr/local',],
'gnu0': ['/usr'],
'aix5': ['/usr/local'],
}
return basedir_map.get(sys.platform, ['/usr/local', '/usr'])
def run_child_process(cmd):
"""
Run a subprocess as a sanity check.
"""
p = subprocess.Popen(cmd, shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=(sys.platform != 'win32'))
return p.stdin, p.stdout
def is_min_version(found, minversion):
"""
Returns `True` if `found` is at least as high a version as
`minversion`.
"""
expected_version = version.LooseVersion(minversion)
found_version = version.LooseVersion(found)
return found_version >= expected_version
# Define the display functions only if display_status is True.
if options['display_status']:
def print_line(char='='):
print(char * 76)
def print_status(package, status):
initial_indent = "%22s: " % package
indent = ' ' * 24
print(fill(str(status), width=76,
initial_indent=initial_indent,
subsequent_indent=indent))
def print_message(message):
indent = ' ' * 24 + "* "
print(fill(str(message), width=76,
initial_indent=indent,
subsequent_indent=indent))
def print_raw(section):
print(section)
else:
def print_line(*args, **kwargs):
pass
print_status = print_message = print_raw = print_line
# Remove the -Wstrict-prototypesoption, is it's not valid for C++
customize_compiler = sysconfig.customize_compiler
def my_customize_compiler(compiler):
retval = customize_compiler(compiler)
try:
compiler.compiler_so.remove('-Wstrict-prototypes')
except (ValueError, AttributeError):
pass
return retval
sysconfig.customize_compiler = my_customize_compiler
def make_extension(name, files, *args, **kwargs):
"""
Make a new extension. Automatically sets include_dirs and
library_dirs to the base directories appropriate for this
platform.
`name` is the name of the extension.
`files` is a list of source files.
Any additional arguments are passed to the
`distutils.core.Extension` constructor.
"""
ext = Extension(name, files, *args, **kwargs)
for dir in get_base_dirs():
include_dir = os.path.join(dir, 'include')
if os.path.exists(include_dir):
ext.include_dirs.append(include_dir)
for lib in ('lib', 'lib64'):
lib_dir = os.path.join(dir, lib)
if os.path.exists(lib_dir):
ext.library_dirs.append(lib_dir)
ext.include_dirs.append('.')
return ext
class PkgConfig(object):
"""
This is a class for communicating with pkg-config.
"""
def __init__(self):
"""
Determines whether pkg-config exists on this machine.
"""
if sys.platform == 'win32':
self.has_pkgconfig = False
else:
self.set_pkgconfig_path()
status, output = getstatusoutput("pkg-config --help")
self.has_pkgconfig = (status == 0)
def set_pkgconfig_path(self):
pkgconfig_path = sysconfig.get_config_var('LIBDIR')
if pkgconfig_path is None:
return
pkgconfig_path = os.path.join(pkgconfig_path, 'pkgconfig')
if not os.path.isdir(pkgconfig_path):
return
try:
os.environ['PKG_CONFIG_PATH'] += ':' + pkgconfig_path
except KeyError:
os.environ['PKG_CONFIG_PATH'] = pkgconfig_path
def setup_extension(self, ext, package, default_include_dirs=[],
default_library_dirs=[], default_libraries=[],
alt_exec=None):
"""
Add parameters to the given `ext` for the given `package`.
"""
flag_map = {
'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
executable = alt_exec
if self.has_pkgconfig:
executable = 'pkg-config {0}'.format(package)
use_defaults = True
if executable is not None:
command = "{0} --libs --cflags ".format(executable)
try:
output = check_output(command, shell=True,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
pass
else:
output = output.decode(sys.getfilesystemencoding())
use_defaults = False
for token in output.split():
attr = flag_map.get(token[:2])
if attr is not None:
getattr(ext, attr).append(token[2:])
if use_defaults:
basedirs = get_base_dirs()
for base in basedirs:
for include in default_include_dirs:
dir = os.path.join(base, include)
if os.path.exists(dir):
ext.include_dirs.append(dir)
for lib in default_library_dirs:
dir = os.path.join(base, lib)
if os.path.exists(dir):
ext.library_dirs.append(dir)
ext.libraries.extend(default_libraries)
return True
return False
def get_version(self, package):
"""
Get the version of the package from pkg-config.
"""
if not self.has_pkgconfig:
return None
status, output = getstatusoutput(
"pkg-config %s --modversion" % (package))
if status == 0:
return output
return None
# The PkgConfig class should be used through this singleton
pkg_config = PkgConfig()
class CheckFailed(Exception):
"""
Exception thrown when a `SetupPackage.check` method fails.
"""
pass
class SetupPackage(object):
optional = False
def check(self):
"""
Checks whether the dependencies are met. Should raise a
`CheckFailed` exception if the dependency could not be met,
otherwise return a string indicating a version number or some
other message indicating what was found.
"""
pass
def get_packages(self):
"""
Get a list of package names to add to the configuration.
These are added to the `packages` list passed to
`distutils.setup`.
"""
return []
def get_namespace_packages(self):
"""
Get a list of namespace package names to add to the configuration.
These are added to the `namespace_packages` list passed to
`distutils.setup`.
"""
return []
def get_py_modules(self):
"""
Get a list of top-level modules to add to the configuration.
These are added to the `py_modules` list passed to
`distutils.setup`.
"""
return []
def get_package_data(self):
"""
Get a package data dictionary to add to the configuration.
These are merged into to the `package_data` list passed to
`distutils.setup`.
"""
return {}
def get_extension(self):
"""
Get a list of C extensions (`distutils.core.Extension`
objects) to add to the configuration. These are added to the
`extensions` list passed to `distutils.setup`.
"""
return None
def get_install_requires(self):
"""
Get a list of Python packages that we require.
pip/easy_install will attempt to download and install this
package if it is not installed.
"""
return []
def _check_for_pkg_config(self, package, include_file, min_version=None,
version=None):
"""
A convenience function for writing checks for a
pkg_config-defined dependency.
`package` is the pkg_config package name.
`include_file` is a top-level include file we expect to find.
`min_version` is the minimum version required.
`version` will override the found version if this package
requires an alternate method for that.
"""
if version is None:
version = pkg_config.get_version(package)
if version is None:
raise CheckFailed(
"pkg-config information for '%s' could not be found." %
package)
if min_version == 'PATCH':
raise CheckFailed(
"Requires patches that have not been merged upstream.")
if min_version:
if (not is_min_version(version, min_version)):
raise CheckFailed(
"Requires %s %s or later. Found %s." %
(package, min_version, version))
ext = self.get_extension()
if ext is None:
ext = make_extension('test', [])
pkg_config.setup_extension(ext, package)
check_include_file(ext.include_dirs, include_file, package)
return 'version %s' % version
class OptionalPackage(SetupPackage):
optional = True
def get_config(self):
install = True
if config is not None:
try:
install = config.getboolean(
'packages', self.name)
except:
pass
return install
def check(self):
self.install = self.get_config()
if not self.install:
raise CheckFailed("skipping due to configuration")
return "installing"
class OptionalBackendPackage(SetupPackage):
optional = True
def get_config(self):
install = 'auto'
if config is not None:
try:
install = config.getboolean(
'gui_support', self.name)
except:
install = 'auto'
if install is True:
self.optional = False
return install
class Platform(SetupPackage):
name = "platform"
def check(self):
return sys.platform
class Python(SetupPackage):
name = "python"
def check(self):
major, minor1, minor2, s, tmp = sys.version_info
if major < 2:
raise CheckFailed(
"Requires Python 2.6 or later")
elif major == 2 and minor1 < 6:
raise CheckFailed(
"Requires Python 2.6 or later (in the 2.x series)")
elif major == 3 and minor1 < 1:
raise CheckFailed(
"Requires Python 3.1 or later (in the 3.x series)")
return sys.version
class Matplotlib(SetupPackage):
name = "matplotlib"
def check(self):
return extract_versions()['__version__']
def get_packages(self):
return [
'matplotlib',
'matplotlib.backends',
'matplotlib.backends.qt4_editor',
'matplotlib.compat',
'matplotlib.projections',
'matplotlib.axes',
'matplotlib.sphinxext',
'matplotlib.testing',
'matplotlib.testing.jpl_units',
'matplotlib.tri',
]
def get_py_modules(self):
return ['pylab']
def get_package_data(self):
return {
'matplotlib':
[
'mpl-data/fonts/afm/*.afm',
'mpl-data/fonts/pdfcorefonts/*.afm',
'mpl-data/fonts/pdfcorefonts/*.txt',
'mpl-data/fonts/ttf/*.ttf',
'mpl-data/fonts/ttf/LICENSE_STIX',
'mpl-data/fonts/ttf/COPYRIGHT.TXT',
'mpl-data/fonts/ttf/README.TXT',
'mpl-data/fonts/ttf/RELEASENOTES.TXT',
'mpl-data/images/*.xpm',
'mpl-data/images/*.svg',
'mpl-data/images/*.gif',
'mpl-data/images/*.png',
'mpl-data/images/*.ppm',
'mpl-data/example/*.npy',
'mpl-data/matplotlibrc',
'backends/web_backend/*.*',
'backends/web_backend/jquery/js/*',
'backends/web_backend/jquery/css/themes/base/*.*',
'backends/web_backend/jquery/css/themes/base/images/*',
'backends/web_backend/css/*.*',
'backends/Matplotlib.nib/*'
]}
class SampleData(OptionalPackage):
"""
This handles the sample data that ships with matplotlib. It is
technically optional, though most often will be desired.
"""
name = "sample_data"
def get_package_data(self):
return {
'matplotlib':
[
'mpl-data/sample_data/*.*',
'mpl-data/sample_data/axes_grid/*.*',
]}
class Toolkits(OptionalPackage):
name = "toolkits"
def get_packages(self):
return [
'mpl_toolkits',
'mpl_toolkits.mplot3d',
'mpl_toolkits.axes_grid',
'mpl_toolkits.axes_grid1',
'mpl_toolkits.axisartist',
]
def get_namespace_packages(self):
return ['mpl_toolkits']
class Tests(OptionalPackage):
name = "tests"
def check(self):
super(Tests, self).check()
try:
import nose
except ImportError:
return (
"nose 0.11.1 or later is required to run the "
"matplotlib test suite")
if nose.__versioninfo__ < (0, 11, 1):
return (
"nose 0.11.1 or later is required to run the "
"matplotlib test suite")
return 'using nose version %s' % nose.__version__
def get_packages(self):
return [
'matplotlib.tests',
]
def get_package_data(self):
baseline_images = [
'tests/baseline_images/%s/*' % x
for x in os.listdir('lib/matplotlib/tests/baseline_images')]
return {
'matplotlib':
baseline_images +
[
'tests/mpltest.ttf',
'tests/test_rcparams.rc'
]}
def get_install_requires(self):
return ['nose']
class Numpy(SetupPackage):
name = "numpy"
def check(self):
min_version = extract_versions()['__version__numpy__']
try:
import numpy
except ImportError:
raise SystemExit(
"Requires numpy %s or later to build. (Numpy not found)" %
min_version)
if not is_min_version(numpy.__version__, min_version):
raise SystemExit(
"Requires numpy %s or later to build. (Found %s)" %
(min_version, numpy.__version__))
ext = make_extension('test', [])
ext.include_dirs.append(numpy.get_include())
if not has_include_file(
ext.include_dirs, os.path.join("numpy", "arrayobject.h")):
raise CheckFailed(
"The C headers for numpy could not be found. You"
"may need to install the development package.")
return 'version %s' % numpy.__version__
def add_flags(self, ext):
import numpy
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for
# each extension
array_api_name = 'MPL_' + ext.name.replace('.', '_') + '_ARRAY_API'
ext.include_dirs.append(numpy.get_include())
ext.define_macros.append(('PY_ARRAY_UNIQUE_SYMBOL', array_api_name))
class CXX(SetupPackage):
name = 'pycxx'
def check(self):
if sys.version_info[0] >= 3:
# There is no version of PyCXX in the wild that will work
# with Python 3.x
self.__class__.found_external = False
return ("Official versions of PyCXX are not compatible with "
"Python 3.x. Using local copy")
self.__class__.found_external = True
old_stdout = sys.stdout
sys.stdout = io.BytesIO()
try:
import CXX
except ImportError:
self.__class__.found_external = False
return "Couldn't import. Using local copy."
finally:
sys.stdout = old_stdout
try:
return self._check_for_pkg_config(
'PyCXX', 'CXX/Extensions.hxx', min_version='6.2.4')
except CheckFailed as e:
# Since there is no .pc file for PyCXX upstream, many
# distros don't package it either. We don't necessarily
# need to fall back to a local build in that scenario if
# the header files can be found.
base_include_dirs = [
os.path.join(x, 'include') for x in get_base_dirs()]
if has_include_file(base_include_dirs, 'CXX/Extensions.hxx'):
return 'Using system CXX (version unknown, no pkg-config info)'
else:
self.__class__.found_external = False
return str(e) + ' Using local copy.'
def add_flags(self, ext):
if self.found_external and not 'sdist' in sys.argv:
support_dir = os.path.normpath(
os.path.join(
sys.prefix,
'share',
'python%d.%d' % (
sys.version_info[0], sys.version_info[1]),
'CXX'))
if not os.path.exists(support_dir):
# On Fedora 17, these files are installed in /usr/share/CXX
support_dir = '/usr/src/CXX'
ext.sources.extend([
os.path.join(support_dir, x) for x in
['cxxsupport.cxx', 'cxx_extensions.cxx',
'IndirectPythonInterface.cxx',
'cxxextensions.c']])
pkg_config.setup_extension(ext, 'PyCXX')
else:
ext.sources.extend(glob.glob('CXX/*.cxx'))
ext.sources.extend(glob.glob('CXX/*.c'))
ext.define_macros.append(('PYCXX_ISO_CPP_LIB', '1'))
if sys.version_info[0] >= 3:
ext.define_macros.append(('PYCXX_PYTHON_2TO3', '1'))
if not (sys.platform == 'win32' and win32_compiler == 'msvc'):
ext.libraries.append('stdc++')
ext.libraries.append('m')
class LibAgg(SetupPackage):
name = 'libagg'
def check(self):
self.__class__.found_external = True
try:
return self._check_for_pkg_config(
'libagg', 'agg2/agg_basics.h', min_version='PATCH')
except CheckFailed as e:
self.__class__.found_external = False
return str(e) + ' Using local copy.'
def add_flags(self, ext):
if self.found_external:
pkg_config.setup_extension(ext, 'libagg')
else:
ext.include_dirs.append('agg24/include')
agg_sources = [
'agg_bezier_arc.cpp',
'agg_curves.cpp',
'agg_image_filters.cpp',
'agg_trans_affine.cpp',
'agg_vcgen_contour.cpp',
'agg_vcgen_dash.cpp',
'agg_vcgen_stroke.cpp',
'agg_vpgen_segmentator.cpp'
]
ext.sources.extend(
os.path.join('agg24', 'src', x) for x in agg_sources)
class FreeType(SetupPackage):
name = "freetype"
def check(self):
if sys.platform == 'win32':
return "Unknown version"
status, output = getstatusoutput("freetype-config --version")
if status == 0:
version = output
else:
version = None
return self._check_for_pkg_config(
'freetype2', 'ft2build.h',
min_version='2.4', version=version)
def add_flags(self, ext):
pkg_config.setup_extension(
ext, 'freetype2',
default_include_dirs=[
'freetype2', 'lib/freetype2/include',
'lib/freetype2/include/freetype2'],
default_library_dirs=[
'freetype2/lib'],
default_libraries=['freetype', 'z'],
alt_exec='freetype-config')
class FT2Font(SetupPackage):
name = 'ft2font'
def get_extension(self):
sources = [
'src/ft2font.cpp',
'src/mplutils.cpp'
]
ext = make_extension('matplotlib.ft2font', sources)
FreeType().add_flags(ext)
Numpy().add_flags(ext)
CXX().add_flags(ext)
return ext
class Png(SetupPackage):
name = "png"
def check(self):
try:
return self._check_for_pkg_config(
'libpng', 'png.h',
min_version='1.2')
except CheckFailed as e:
self.__class__.found_external = False
return str(e) + ' Using unknown version.'
def get_extension(self):
sources = [
'src/_png.cpp', 'src/mplutils.cpp'
]
ext = make_extension('matplotlib._png', sources)
pkg_config.setup_extension(
ext, 'libpng', default_libraries=['png', 'z'])
Numpy().add_flags(ext)
CXX().add_flags(ext)
return ext
class TTConv(SetupPackage):
name = "ttconv"
def get_extension(self):
sources = [
'src/_ttconv.cpp',
'ttconv/pprdrv_tt.cpp',
'ttconv/pprdrv_tt2.cpp',
'ttconv/ttutil.cpp'
]
ext = make_extension('matplotlib.ttconv', sources)
Numpy().add_flags(ext)
CXX().add_flags(ext)
return ext
class Path(SetupPackage):
name = "path"
def get_extension(self):
sources = [
'src/_path.cpp',
'src/path_cleanup.cpp',
'src/agg_py_transforms.cpp'
]
ext = make_extension('matplotlib._path', sources)
Numpy().add_flags(ext)
LibAgg().add_flags(ext)
CXX().add_flags(ext)
return ext
class Image(SetupPackage):
name = "image"
def get_extension(self):
sources = [
'src/_image.cpp', 'src/mplutils.cpp'
]
ext = make_extension('matplotlib._image', sources)
Numpy().add_flags(ext)
LibAgg().add_flags(ext)
CXX().add_flags(ext)
return ext
class Contour(SetupPackage):
name = "contour"
def get_extension(self):
sources = [
"src/cntr.c"
]
ext = make_extension('matplotlib._cntr', sources)
Numpy().add_flags(ext)
return ext
class Delaunay(SetupPackage):
name = "delaunay"
def get_packages(self):
return ['matplotlib.delaunay']
def get_extension(self):
sources = ["_delaunay.cpp", "VoronoiDiagramGenerator.cpp",
"delaunay_utils.cpp", "natneighbors.cpp"]
sources = [os.path.join('lib/matplotlib/delaunay', s) for s in sources]
ext = make_extension('matplotlib._delaunay', sources)
Numpy().add_flags(ext)
return ext
class Tri(SetupPackage):
name = "tri"
def get_extension(self):
sources = [
"lib/matplotlib/tri/_tri.cpp",
"src/mplutils.cpp"
]
ext = make_extension('matplotlib._tri', sources)
Numpy().add_flags(ext)
CXX().add_flags(ext)
return ext
class Dateutil(SetupPackage):
name = "dateutil"
def check(self):
try:
import dateutil
except ImportError:
return (
"dateutil was not found. It is required for date axis "
"support. pip/easy_install may attempt to install it "
"after matplotlib.")
return "using dateutil version %s" % dateutil.__version__
def get_install_requires(self):
return ['python-dateutil']
class Tornado(SetupPackage):
name = "tornado"
def check(self):
try:
import tornado
except ImportError:
return (
"tornado was not found. It is required for the WebAgg "
"backend. pip/easy_install may attempt to install it "
"after matplotlib.")
return "using tornado version %s" % tornado.version
def get_install_requires(self):
return ['tornado']
class Pyparsing(SetupPackage):
name = "pyparsing"
def check(self):
try:
import pyparsing
except ImportError:
return (
"pyparsing was not found. It is required for mathtext "
"support. pip/easy_install may attempt to install it "
"after matplotlib.")
if sys.version_info[0] >= 3:
required = [2, 0, 0]
if [int(x) for x in pyparsing.__version__.split('.')] < required:
return (
"matplotlib requires pyparsing >= {0} on Python 3.x".format(
'.'.join(str(x) for x in required)))
else:
required = [1, 5, 6]
if [int(x) for x in pyparsing.__version__.split('.')] < required:
return (
"matplotlib requires pyparsing >= {0} on Python 2.x".format(
'.'.join(str(x) for x in required)))
if pyparsing.__version__ == "2.0.0":
return (
"pyparsing 2.0.0 is not compatible with Python 2.x")
return "using pyparsing version %s" % pyparsing.__version__
def get_install_requires(self):
if sys.version_info[0] >= 3:
return ['pyparsing>=1.5.6']
else:
# pyparsing >= 2.0.0 is not compatible with Python 2
return ['pyparsing>=1.5.6,!=2.0.0']