@@ -316,13 +316,13 @@ def get_package_data(self):
316
316
"""
317
317
return {}
318
318
319
- def get_extension (self ):
319
+ def get_extensions (self ):
320
320
"""
321
- Get a list of C extensions (`distutils.core.Extension`
321
+ Return or yield a list of C extensions (`distutils.core.Extension`
322
322
objects) to add to the configuration. These are added to the
323
323
`extensions` list passed to `distutils.setup`.
324
324
"""
325
- return None
325
+ return []
326
326
327
327
def do_custom_build (self ):
328
328
"""
@@ -422,6 +422,88 @@ def get_package_data(self):
422
422
],
423
423
}
424
424
425
+ def get_extensions (self ):
426
+ # contour
427
+ ext = Extension ('matplotlib._contour' , [
428
+ "src/_contour.cpp" ,
429
+ "src/_contour_wrapper.cpp" ,
430
+ 'src/py_converters.cpp' ,
431
+ ])
432
+ add_numpy_flags (ext )
433
+ add_libagg_flags (ext )
434
+ yield ext
435
+ # ft2font
436
+ ext = Extension ('matplotlib.ft2font' , [
437
+ 'src/ft2font.cpp' ,
438
+ 'src/ft2font_wrapper.cpp' ,
439
+ 'src/mplutils.cpp' ,
440
+ 'src/py_converters.cpp' ,
441
+ ])
442
+ FreeType ().add_flags (ext )
443
+ add_numpy_flags (ext )
444
+ add_libagg_flags (ext )
445
+ yield ext
446
+ # image
447
+ ext = Extension ('matplotlib._image' , [
448
+ 'src/_image.cpp' ,
449
+ 'src/mplutils.cpp' ,
450
+ 'src/_image_wrapper.cpp' ,
451
+ 'src/py_converters.cpp'
452
+ ])
453
+ add_numpy_flags (ext )
454
+ add_libagg_flags_and_sources (ext )
455
+ yield ext
456
+ # path
457
+ ext = Extension ('matplotlib._path' , [
458
+ 'src/py_converters.cpp' ,
459
+ 'src/_path_wrapper.cpp'
460
+ ])
461
+ add_numpy_flags (ext )
462
+ add_libagg_flags_and_sources (ext )
463
+ yield ext
464
+ # png
465
+ ext = Extension ('matplotlib._png' , [
466
+ 'src/checkdep_libpng.c' ,
467
+ 'src/_png.cpp' ,
468
+ 'src/mplutils.cpp' ,
469
+ ])
470
+ pkg_config_setup_extension (
471
+ ext , 'libpng' ,
472
+ atleast_version = '1.2' ,
473
+ alt_exec = ['libpng-config' , '--ldflags' ],
474
+ default_libraries = (
475
+ ['png' , 'z' ] if os .name == 'posix' else
476
+ # libpng upstream names their lib libpng16.lib, not png.lib.
477
+ # zlib upstream names their lib zlib.lib, not z.lib.
478
+ [deplib ('libpng16' ), deplib ('z' )] if os .name == 'nt' else
479
+ []))
480
+ add_numpy_flags (ext )
481
+ yield ext
482
+ # qhull
483
+ ext = Extension ('matplotlib._qhull' , ['src/qhull_wrap.c' ],
484
+ define_macros = [('MPL_DEVNULL' , os .devnull )])
485
+ add_numpy_flags (ext )
486
+ add_qhull_flags (ext )
487
+ yield ext
488
+ # tri
489
+ ext = Extension ('matplotlib._tri' , [
490
+ "src/tri/_tri.cpp" ,
491
+ "src/tri/_tri_wrapper.cpp" ,
492
+ "src/mplutils.cpp"
493
+ ])
494
+ add_numpy_flags (ext )
495
+ yield ext
496
+ # ttconv
497
+ ext = Extension ('matplotlib.ttconv' , [
498
+ 'src/_ttconv.cpp' ,
499
+ 'extern/ttconv/pprdrv_tt.cpp' ,
500
+ 'extern/ttconv/pprdrv_tt2.cpp' ,
501
+ 'extern/ttconv/ttutil.cpp'
502
+ ])
503
+ add_numpy_flags (ext )
504
+ ext .include_dirs .insert (0 , 'extern' )
505
+ yield ext
506
+
425
507
426
508
class SampleData (OptionalPackage ):
427
509
"""
@@ -470,26 +552,38 @@ def add_numpy_flags(ext):
470
552
])
471
553
472
554
473
- class LibAgg (SetupPackage ):
474
- name = 'libagg'
475
-
476
- def add_flags (self , ext , add_sources = True ):
477
- # We need a patched Agg not available elsewhere, so always use the
478
- # vendored version.
479
- ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
480
- if add_sources :
481
- agg_sources = [
482
- 'agg_bezier_arc.cpp' ,
483
- 'agg_curves.cpp' ,
484
- 'agg_image_filters.cpp' ,
485
- 'agg_trans_affine.cpp' ,
486
- 'agg_vcgen_contour.cpp' ,
487
- 'agg_vcgen_dash.cpp' ,
488
- 'agg_vcgen_stroke.cpp' ,
489
- 'agg_vpgen_segmentator.cpp'
490
- ]
491
- ext .sources .extend (os .path .join ('extern' , 'agg24-svn' , 'src' , x )
492
- for x in agg_sources )
555
+ def add_libagg_flags (ext ):
556
+ # We need a patched Agg not available elsewhere, so always use the vendored
557
+ # version.
558
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
559
+
560
+
561
+ def add_libagg_flags_and_sources (ext ):
562
+ # We need a patched Agg not available elsewhere, so always use the vendored
563
+ # version.
564
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
565
+ agg_sources = [
566
+ 'agg_bezier_arc.cpp' ,
567
+ 'agg_curves.cpp' ,
568
+ 'agg_image_filters.cpp' ,
569
+ 'agg_trans_affine.cpp' ,
570
+ 'agg_vcgen_contour.cpp' ,
571
+ 'agg_vcgen_dash.cpp' ,
572
+ 'agg_vcgen_stroke.cpp' ,
573
+ 'agg_vpgen_segmentator.cpp' ,
574
+ ]
575
+ ext .sources .extend (
576
+ os .path .join ('extern' , 'agg24-svn' , 'src' , x ) for x in agg_sources )
577
+
578
+
579
+ def add_qhull_flags (ext ):
580
+ # Qhull doesn't distribute pkg-config info, so we have no way of knowing
581
+ # whether a system install is recent enough. Thus, always use the vendored
582
+ # version.
583
+ ext .include_dirs .insert (0 , 'extern' )
584
+ ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
585
+ if sysconfig .get_config_var ('LIBM' ) == '-lm' :
586
+ ext .libraries .extend ('m' )
493
587
494
588
495
589
# For FreeType2 and libpng, we add a separate checkdep_foo.c source to at the
@@ -625,153 +719,11 @@ def do_custom_build(self):
625
719
shutil .copy2 (lib_path , src_path / "objs/.libs/libfreetype.lib" )
626
720
627
721
628
- class FT2Font (SetupPackage ):
629
- name = 'ft2font'
630
-
631
- def get_extension (self ):
632
- sources = [
633
- 'src/ft2font.cpp' ,
634
- 'src/ft2font_wrapper.cpp' ,
635
- 'src/mplutils.cpp' ,
636
- 'src/py_converters.cpp' ,
637
- ]
638
- ext = Extension ('matplotlib.ft2font' , sources )
639
- FreeType ().add_flags (ext )
640
- add_numpy_flags (ext )
641
- LibAgg ().add_flags (ext , add_sources = False )
642
- return ext
643
-
644
-
645
- class Png (SetupPackage ):
646
- name = "png"
647
-
648
- def get_extension (self ):
649
- sources = [
650
- 'src/checkdep_libpng.c' ,
651
- 'src/_png.cpp' ,
652
- 'src/mplutils.cpp' ,
653
- ]
654
- ext = Extension ('matplotlib._png' , sources )
655
- pkg_config_setup_extension (
656
- ext , 'libpng' ,
657
- atleast_version = '1.2' ,
658
- alt_exec = ['libpng-config' , '--ldflags' ],
659
- default_libraries = (
660
- ['png' , 'z' ] if os .name == 'posix' else
661
- # libpng upstream names their lib libpng16.lib, not png.lib.
662
- [deplib ('libpng16' ), deplib ('z' )] if os .name == 'nt' else
663
- []
664
- ))
665
- add_numpy_flags (ext )
666
- return ext
667
-
668
-
669
- class Qhull (SetupPackage ):
670
- name = "qhull"
671
-
672
- def add_flags (self , ext ):
673
- # Qhull doesn't distribute pkg-config info, so we have no way of
674
- # knowing whether a system install is recent enough. Thus, always use
675
- # the vendored version.
676
- ext .include_dirs .insert (0 , 'extern' )
677
- ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
678
- if sysconfig .get_config_var ('LIBM' ) == '-lm' :
679
- ext .libraries .extend ('m' )
680
-
681
-
682
- class TTConv (SetupPackage ):
683
- name = "ttconv"
684
-
685
- def get_extension (self ):
686
- sources = [
687
- 'src/_ttconv.cpp' ,
688
- 'extern/ttconv/pprdrv_tt.cpp' ,
689
- 'extern/ttconv/pprdrv_tt2.cpp' ,
690
- 'extern/ttconv/ttutil.cpp'
691
- ]
692
- ext = Extension ('matplotlib.ttconv' , sources )
693
- add_numpy_flags (ext )
694
- ext .include_dirs .insert (0 , 'extern' )
695
- return ext
696
-
697
-
698
- class Path (SetupPackage ):
699
- name = "path"
700
-
701
- def get_extension (self ):
702
- sources = [
703
- 'src/py_converters.cpp' ,
704
- 'src/_path_wrapper.cpp'
705
- ]
706
- ext = Extension ('matplotlib._path' , sources )
707
- add_numpy_flags (ext )
708
- LibAgg ().add_flags (ext )
709
- return ext
710
-
711
-
712
- class Image (SetupPackage ):
713
- name = "image"
714
-
715
- def get_extension (self ):
716
- sources = [
717
- 'src/_image.cpp' ,
718
- 'src/mplutils.cpp' ,
719
- 'src/_image_wrapper.cpp' ,
720
- 'src/py_converters.cpp'
721
- ]
722
- ext = Extension ('matp
10000
lotlib._image' , sources )
723
- add_numpy_flags (ext )
724
- LibAgg ().add_flags (ext )
725
-
726
- return ext
727
-
728
-
729
- class Contour (SetupPackage ):
730
- name = "contour"
731
-
732
- def get_extension (self ):
733
- sources = [
734
- "src/_contour.cpp" ,
735
- "src/_contour_wrapper.cpp" ,
736
- 'src/py_converters.cpp' ,
737
- ]
738
- ext = Extension ('matplotlib._contour' , sources )
739
- add_numpy_flags (ext )
740
- LibAgg ().add_flags (ext , add_sources = False )
741
- return ext
742
-
743
-
744
- class QhullWrap (SetupPackage ):
745
- name = "qhull_wrap"
746
-
747
- def get_extension (self ):
748
- sources = ['src/qhull_wrap.c' ]
749
- ext = Extension ('matplotlib._qhull' , sources ,
750
- define_macros = [('MPL_DEVNULL' , os .devnull )])
751
- add_numpy_flags (ext )
752
- Qhull ().add_flags (ext )
753
- return ext
754
-
755
-
756
- class Tri (SetupPackage ):
757
- name = "tri"
758
-
759
- def get_extension (self ):
760
- sources = [
761
- "src/tri/_tri.cpp" ,
762
- "src/tri/_tri_wrapper.cpp" ,
763
- "src/mplutils.cpp"
764
- ]
765
- ext = Extension ('matplotlib._tri' , sources )
766
- add_numpy_flags (ext )
767
- return ext
768
-
769
-
770
722
class BackendAgg (OptionalBackendPackage ):
771
723
name = "agg"
772
724
force = True
773
725
774
- def get_extension (self ):
726
+ def get_extensions (self ):
775
727
sources = [
776
728
"src/mplutils.cpp" ,
777
729
"src/py_converters.cpp" ,
@@ -780,9 +732,9 @@ def get_extension(self):
780
732
]
781
733
ext = Extension ('matplotlib.backends._backend_agg' , sources )
782
734
add_numpy_flags (ext )
783
- LibAgg (). add_flags (ext )
735
+ add_libagg_flags_and_sources (ext )
784
736
FreeType ().add_flags (ext )
785
- return ext
737
+ yield ext
786
738
787
739
788
740
class BackendTkAgg (OptionalBackendPackage ):
@@ -792,7 +744,7 @@ class BackendTkAgg(OptionalBackendPackage):
792
744
def check (self ):
793
745
return "installing; run-time loading from Python Tcl/Tk"
794
746
795
- def get_extension (self ):
747
+ def get_extensions (self ):
796
748
sources = [
797
749
'src/_tkagg.cpp' ,
798
750
'src/py_converters.cpp' ,
@@ -801,8 +753,8 @@ def get_extension(self):
801
753
ext = Extension ('matplotlib.backends._tkagg' , sources )
802
754
self .add_flags (ext )
803
755
add_numpy_flags (ext )
804
- LibAgg (). add_flags ( ext , add_sources = False )
805
- return ext
756
+ add_libagg_flags ( ext )
757
+ yield ext
806
758
807
759
def add_flags (self , ext ):
808
760
ext .include_dirs .insert (0 , 'src' )
@@ -823,12 +775,12 @@ def check(self):
823
775
raise CheckFailed ("Mac OS-X only" )
824
776
73C0
return super ().check ()
825
777
826
- def get_extension (self ):
778
+ def get_extensions (self ):
827
779
sources = [
828
780
'src/_macosx.m'
829
781
]
830
782
ext = Extension ('matplotlib.backends._macosx' , sources )
831
783
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
832
784
if platform .python_implementation ().lower () == 'pypy' :
833
785
ext .extra_compile_args .append ('-DPYPY=1' )
834
- return ext
786
+ yield ext
0 commit comments