@@ -300,13 +300,13 @@ def get_package_data(self):
300
300
"""
301
301
return {}
302
302
303
- def get_extension (self ):
303
+ def get_extensions (self ):
304
304
"""
305
- Get a list of C extensions (`distutils.core.Extension`
305
+ Return or yield a list of C extensions (`distutils.core.Extension`
306
306
objects) to add to the configuration. These are added to the
307
307
`extensions` list passed to `distutils.setup`.
308
308
"""
309
- return None
309
+ return []
310
310
311
311
def do_custom_build (self ):
312
312
"""
@@ -404,6 +404,83 @@ def get_package_data(self):
404
404
],
405
405
}
406
406
407
+ def get_extensions (self ):
408
+ # contour
409
+ ext = Extension ('matplotlib._contour' , [
410
+ "src/_contour.cpp" ,
411
+ "src/_contour_wrapper.cpp" ,
412
+ 'src/py_converters.cpp' ,
413
+ ])
414
+ add_numpy_flags (ext )
415
+ add_libagg_flags (ext )
416
+ yield ext
417
+ # ft2font
418
+ ext = Extension ('matplotlib.ft2font' , [
419
+ 'src/ft2font.cpp' ,
420
+ 'src/ft2font_wrapper.cpp' ,
421
+ 'src/mplutils.cpp' ,
422
+ 'src/py_converters.cpp' ,
423
+ ])
424
+ FreeType ().add_flags (ext )
425
+ add_numpy_flags (ext )
426
+ add_libagg_flags (ext )
427
+ yield ext
428
+ # image
429
+ ext = Extension ('matplotlib._image' , [
430
+ 'src/_image.cpp' ,
431
+ 'src/mplutils.cpp' ,
432
+ 'src/_image_wrapper.cpp' ,
433
+ 'src/py_converters.cpp'
434
+ ])
435
+ add_numpy_flags (ext )
436
+ add_libagg_flags_and_sources (ext )
437
+ yield ext
438
+ # path
439
+ ext = Extension ('matplotlib._path' , [
440
+ 'src/py_converters.cpp' ,
441
+ 'src/_path_wrapper.cpp'
442
+ ])
443
+ add_numpy_flags (ext )
444
+ add_libagg_flags_and_sources (ext )
445
+ yield ext
446
+ # png
447
+ ext = Extension ('matplotlib._png' , [
448
+ 'src/checkdep_libpng.c' ,
449
+ 'src/_png.cpp' ,
450
+ 'src/mplutils.cpp' ,
451
+ ])
452
+ pkg_config_setup_extension (
453
+ ext , 'libpng' ,
454
+ atleast_version = '1.2' ,
455
+ alt_exec = ['libpng-config' , '--ldflags' ],
456
+ default_libraries = ['png' , 'z' ])
457
+ add_numpy_flags (ext )
458
+ yield ext
459
+ # qhull
460
+ ext = Extension ('matplotlib._qhull' , ['src/qhull_wrap.c' ],
461
+ define_macros = [('MPL_DEVNULL' , os .devnull )])
462
+ add_numpy_flags (ext )
463
+ add_qhull_flags (ext )
464
+ yield ext
465
+ # tri
466
+ ext = Extension ('matplotlib._tri' , [
467
+ "src/tri/_tri.cpp" ,
468
+ "src/tri/_tri_wrapper.cpp" ,
469
+ "src/mplutils.cpp"
470
+ ])
471
+ add_numpy_flags (ext )
472
+ yield ext
473
+ # ttconv
474
+ ext = Extension ('matplotlib.ttconv' , [
475
+ 'src/_ttconv.cpp' ,
476
+ 'extern/ttconv/pprdrv_tt.cpp' ,
477
+ 'extern/ttconv/pprdrv_tt2.cpp' ,
478
+ 'extern/ttconv/ttutil.cpp'
479
+ ])
480
+ add_numpy_flags (ext )
481
+ ext .include_dirs .insert (0 , 'extern' )
482
+ yield ext
483
+
407
484
408
485
class SampleData (OptionalPackage ):
409
486
"""
@@ -454,26 +531,38 @@ def add_numpy_flags(ext):
454
531
])
455
532
456
533
457
- class LibAgg (SetupPackage ):
458
- name = 'libagg'
459
-
460
- def add_flags (self , ext , add_sources = True ):
461
- # We need a patched Agg not available elsewhere, so always use the
462
- # vendored version.
463
- ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
464
- if add_sources :
465
- agg_sources = [
466
- 'agg_bezier_arc.cpp' ,
467
- 'agg_curves.cpp' ,
468
- 'agg_image_filters.cpp' ,
469
- 'agg_trans_affine.cpp' ,
470
- 'agg_vcgen_contour.cpp' ,
471
- 'agg_vcgen_dash.cpp' ,
472
- 'agg_vcgen_stroke.cpp' ,
473
- 'agg_vpgen_segmentator.cpp'
474
- ]
475
- ext .sources .extend (os .path .join ('extern' , 'agg24-svn' , 'src' , x )
476
- for x in agg_sources )
534
+ def add_libagg_flags (ext ):
535
+ # We need a patched Agg not available elsewhere, so always use the vendored
536
+ # version.
537
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
538
+
539
+
540
+ def add_libagg_flags_and_sources (ext ):
541
+ # We need a patched Agg not available elsewhere, so always use the vendored
542
+ # version.
543
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
544
+ agg_sources = [
545
+ 'agg_bezier_arc.cpp' ,
546
+ 'agg_curves.cpp' ,
547
+ 'agg_image_filters.cpp' ,
548
+ 'agg_trans_affine.cpp' ,
549
+ 'agg_vcgen_contour.cpp' ,
550
+ 'agg_vcgen_dash.cpp' ,
551
+ 'agg_vcgen_stroke.cpp' ,
552
+ 'agg_vpgen_segmentator.cpp' ,
553
+ ]
554
+ ext .sources .extend (
555
+ os .path .join ('extern' , 'agg24-svn' , 'src' , x ) for x in agg_sources )
556
+
557
+
558
+ def add_qhull_flags (ext ):
559
+ # Qhull doesn't distribute pkg-config info, so we have no way of knowing
560
+ # whether a system install is recent enough. Thus, always use the vendored
561
+ # version.
562
+ ext .include_dirs .insert (0 , 'extern' )
563
+ ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
564
+ if sysconfig .get_config_var ('LIBM' ) == '-lm' :
565
+ ext .libraries .extend ('m' )
477
566
478
567
479
568
# For FreeType2 and libpng, we add a separate checkdep_foo.c source to at the
@@ -614,148 +703,11 @@ def do_custom_build(self):
614
703
str (pathlib .Path (src_path , "objs/.libs/libfreetype.lib" )))
615
704
616
705
617
- class FT2Font (SetupPackage ):
618
- name = 'ft2font'
619
-
620
- def get_extension (self ):
621
- sources = [
622
- 'src/ft2font.cpp' ,
623
- 'src/ft2font_wrapper.cpp' ,
624
- 'src/mplutils.cpp' ,
625
- 'src/py_converters.cpp' ,
626
- ]
627
- ext = Extension ('matplotlib.ft2font' , sources )
628
- FreeType ().add_flags (ext )
629
- add_numpy_flags (ext )
630
- LibAgg ().add_flags (ext , add_sources = False )
631
- return ext
632
-
633
-
634
- class Png (SetupPackage ):
635
- name = "png"
636
-
637
- def get_extension (self ):
638
- sources = [
639
- 'src/checkdep_libpng.c' ,
640
- 'src/_png.cpp' ,
641
- 'src/mplutils.cpp' ,
642
- ]
643
- ext = Extension ('matplotlib._png' , sources )
644
- pkg_config_setup_extension (
645
- ext , 'libpng' ,
646
- atleast_version = '1.2' ,
647
- alt_exec = ['libpng-config' , '--ldflags' ],
648
- default_libraries = ['png' , 'z' ])
649
- add_numpy_flags (ext )
650
- return ext
651
-
652
-
653
- class Qhull (SetupPackage ):
654
- name = "qhull"
655
-
656
- def add_flags (self , ext ):
657
- # Qhull doesn't distribute pkg-config info, so we have no way of
658
- # knowing whether a system install is recent enough. Thus, always use
659
- # the vendored version.
660
- ext .include_dirs .insert (0 , 'extern' )
661
- ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
662
- if sysconfig .get_config_var ('LIBM' ) == '-lm' :
663
- ext .libraries .extend ('m' )
664
-
665
-
666
- class TTConv (SetupPackage ):
667
- name = "ttconv"
668
-
669
- def get_extension (self ):
670
- sources = [
671
- 'src/_ttconv.cpp' ,
672
- 'extern/ttconv/pprdrv_tt.cpp' ,
673
- 'extern/ttconv/pprdrv_tt2.cpp' ,
674
- 'extern/ttconv/ttutil.cpp'
675
- ]
676
- ext = Extension ('matplotlib.ttconv' , sources )
677
- add_numpy_flags (ext )
678
- ext .include_dirs .insert (0 , 'extern' )
679
- return ext
680
-
681
-
682
- class Path (SetupPackage ):
683
- name = "path"
684
-
685
- def get_extension (self ):
686
- sources = [
687
- 'src/py_converters.cpp' ,
688
- 'src/_path_wrapper.cpp'
689
- ]
690
- ext = Extension ('matplotlib._path' , sources )
691
- add_numpy_flags (ext )
692
- LibAgg ().add_flags (ext )
693
- return ext
694
-
695
-
696
- class Image (SetupPackage ):
697
- name = "image"
698
-
699
- def get_extension (self ):
700
- sources = [
701
- 'src/_image.cpp' ,
702
- 'src/mplutils.cpp' ,
703
- 'src/_image_wrapper.cpp' ,
704
- 'src/py_converters.cpp'
705
- ]
706
- ext = Extension ('matplotlib._image' , sources )
707
- add_numpy_flags (ext )
708
- LibAgg ().add_flags (ext )
709
-
710
- return ext
711
-
712
-
713
- class Contour (SetupPackage ):
714
- name = "contour"
715
-
716
- def get_extension (self ):
717
- sources = [
718
- "src/_contour.cpp" ,
719
- "src/_contour_wrapper.cpp" ,
720
- 'src/py_converters.cpp' ,
721
- ]
722
- ext = Extension ('matplotlib._contour' , sources )
723
- add_numpy_flags (ext )
724
- LibAgg ().add_flags (ext , add_sources = False )
725
- return ext
726
-
727
-
728
- class QhullWrap (SetupPackage ):
729
- name = "qhull_wrap"
730
-
731
- def get_extension (self ):
732
- sources = ['src/qhull_wrap.c' ]
733
- ext = Extension ('matplotlib._qhull' , sources ,
734
- define_macros = [('MPL_DEVNULL' , os .devnull )])
735
- add_numpy_flags (ext )
736
- Qhull ().add_flags (ext )
737
- return ext
738
-
739
-
740
- class Tri (SetupPackage ):
741
- name = "tri"
742
-
743
- def get_extension (self ):
744
- sources = [
745
- "src/tri/_tri.cpp" ,
746
- "src/tri/_tri_wrapper.cpp" ,
747
- "src/mplutils.cpp"
748
- ]
749
- ext = Extension ('matplotlib._tri' , sources )
750
- add_numpy_flags (ext )
751
- return ext
752
-
753
-
754
706
class BackendAgg (OptionalBackendPackage ):
755
707
name = "agg"
756
708
force = True
757
709
758
- def get_extension (self ):
710
+ def get_extensions (self ):
759
711
sources = [
760
712
"src/mplutils.cpp" ,
761
713
"src/py_converters.cpp" ,
@@ -764,9 +716,9 @@ def get_extension(self):
764
716
]
765
717
ext = Extension ('matplotlib.backends._backend_agg' , sources )
766
718
add_numpy_flags (ext )
767
- LibAgg (). add_flags (ext )
719
+ add_libagg_flags_and_sources (ext )
768
720
FreeType ().add_flags (ext )
769
- return ext
721
+ yield ext
770
722
771
723
772
724
class BackendTkAgg (OptionalBackendPackage ):
@@ -776,7 +728,7 @@ class BackendTkAgg(OptionalBackendPackage):
776
728
def check (self ):
777
729
return "installing; run-time loading from Python Tcl/Tk"
778
730
779
- def get_extension (self ):
731
+ def get_extensions (self ):
780
732
sources = [
781
733
'src/_tkagg.cpp' ,
782
734
'src/py_converters.cpp' ,
@@ -785,8 +737,8 @@ def get_extension(self):
785
737
ext = Extension ('matplotlib.backends._tkagg' , sources )
786
738
self .add_flags (ext )
787
739
add_numpy_flags (ext )
788
- LibAgg (). add_flags ( ext , add_sources = False )
789
- return ext
740
+ add_libagg_flags ( ext )
741
+ yield ext
790
742
791
743
def add_flags (self , ext ):
792
744
ext .include_dirs .insert (0 , 'src' )
@@ -807,15 +759,15 @@ def check(self):
807
759
raise CheckFailed ("Mac OS-X only" )
808
760
return super ().check ()
809
761
810
- def get_extension (self ):
762
+ def get_extensions (self ):
811
763
sources = [
812
764
'src/_macosx.m'
813
765
]
814
766
ext = Extension ('matplotlib.backends._macosx' , sources )
815
767
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
816
768
if platform .python_implementation ().lower () == 'pypy' :
817
769
ext .extra_compile_args .append ('-DPYPY=1' )
818
- return ext
770
+ yield ext
819
771
820
772
821
773
class OptionalPackageData (OptionalPackage ):
0 commit comments