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