@@ -294,13 +294,13 @@ def get_package_data(self):
294
294
"""
295
295
return {}
296
296
297
- def get_extension (self ):
297
+ def get_extensions (self ):
298
298
"""
299
- Get a list of C extensions (`distutils.core.Extension`
299
+ Return or yield a list of C extensions (`distutils.core.Extension`
300
300
objects) to add to the configuration. These are added to the
301
301
`extensions` list passed to `distutils.setup`.
302
302
"""
303
- return None
303
+ return []
304
304
305
305
def do_custom_build (self ):
306
306
"""
@@ -400,6 +400,88 @@ def get_package_data(self):
400
400
],
401
401
}
402
402
403
+ def get_extensions (self ):
404
+ # contour
405
+ ext = Extension ('matplotlib._contour' , [
406
+ "src/_contour.cpp" ,
407
+ "src/_contour_wrapper.cpp" ,
408
+ 'src/py_converters.cpp' ,
409
+ ])
410
+ add_numpy_flags (ext )
411
+ add_libagg_flags (ext )
412
+ yield ext
413
+ # ft2font
414
+ ext = Extension ('matplotlib.ft2font' , [
415
+ 'src/ft2font.cpp' ,
416
+ 'src/ft2font_wrapper.cpp' ,
417
+ 'src/mplutils.cpp' ,
418
+ 'src/py_converters.cpp' ,
419
+ ])
420
+ FreeType ().add_flags (ext )
421
+ add_numpy_flags (ext )
422
+ add_libagg_flags (ext )
423
+ yield ext
424
+ # image
425
+ ext = Extension ('matplotlib._image' , [
426
+ 'src/_image.cpp' ,
427
+ 'src/mplutils.cpp' ,
428
+ 'src/_image_wrapper.cpp' ,
429
+ 'src/py_converters.cpp'
430
+ ])
431
+ add_numpy_flags (ext )
432
+ add_libagg_flags_and_sources (ext )
433
+ yield ext
434
+ # path
435
+ ext = Extension ('matplotlib._path' , [
436
+ 'src/py_converters.cpp' ,
437
+ 'src/_path_wrapper.cpp'
438
+ ])
439
+ add_numpy_flags (ext )
440
+ add_libagg_flags_and_sources (ext )
441
+ yield ext
442
+ # png
443
+ ext = Extension ('matplotlib._png' , [
444
+ 'src/checkdep_libpng.c' ,
445
+ 'src/_png.cpp' ,
446
+ 'src/mplutils.cpp' ,
447
+ ])
448
+ pkg_config_setup_extension (
449
+ ext , 'libpng' ,
450
+ atleast_version = '1.2' ,
451
+ alt_exec = ['libpng-config' , '--ldflags' ],
452
+ default_libraries = (
453
+ ['png' , 'z' ] if os .name == 'posix' else
454
+ # libpng upstream names their lib libpng16.lib, not png.lib.
455
+ # zlib upstream names their lib zlib.lib, not z.lib.
456
+ ['libpng16' , 'zlib' ] if os .name == 'nt' else
457
+ []))
458
+ add_numpy_flags (ext )
459
+ yield ext
460
+ # qhull
461
+ ext = Extension ('matplotlib._qhull' , ['src/qhull_wrap.c' ],
462
+ define_macros = [('MPL_DEVNULL' , os .devnull )])
463
+ add_numpy_flags (ext )
464
+ add_qhull_flags (ext )
465
+ yield ext
466
+ # tri
467
+ ext = Extension ('matplotlib._tri' , [
468
+ "src/tri/_tri.cpp" ,
469
+ "src/tri/_tri_wrapper.cpp" ,
470
+ "src/mplutils.cpp"
471
+ ])
472
+ add_numpy_flags (ext )
473
+ yield ext
474
+ # ttconv
475
+ ext = Extension ('matplotlib.ttconv' , [
476
+ 'src/_ttconv.cpp' ,
477
+ 'extern/ttconv/pprdrv_tt.cpp' ,
478
+ 'extern/ttconv/pprdrv_tt2.cpp' ,
479
+ 'extern/ttconv/ttutil.cpp'
480
+ ])
481
+ add_numpy_flags (ext )
482
+ ext .include_dirs .insert (0 , 'extern' )
483
+ yield ext
484
+
403
485
404
486
class SampleData (OptionalPackage ):
405
487
"""
@@ -448,26 +530,38 @@ def add_numpy_flags(ext):
448
530
])
449
531
450
532
451
- class LibAgg (SetupPackage ):
452
- name = 'libagg'
453
-
454
- def add_flags (self , ext , add_sources = True ):
455
- # We need a patched Agg not available elsewhere, so always use the
456
- # vendored version.
457
- ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
458
- if add_sources :
459
- agg_sources = [
460
- 'agg_bezier_arc.cpp' ,
461
- 'agg_curves.cpp' ,
462
- 'agg_image_filters.cpp' ,
463
- 'agg_trans_affine.cpp' ,
464
- 'agg_vcgen_contour.cpp' ,
465
- 'agg_vcgen_dash.cpp' ,
466
- 'agg_vcgen_stroke.cpp' ,
467
- 'agg_vpgen_segmentator.cpp'
468
- ]
469
- ext .sources .extend (os .path .join ('extern' , 'agg24-svn' , 'src' , x )
470
- for x in agg_sources )
533
+ def add_libagg_flags (ext ):
534
+ # We need a patched Agg not available elsewhere, so always use the vendored
535
+ # version.
536
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
537
+
538
+
539
+ def add_libagg_flags_and_sources (ext ):
540
+ # We need a patched Agg not available elsewhere, so always use the vendored
541
+ # version.
542
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
543
+ agg_sources = [
544
+ 'agg_bezier_arc.cpp' ,
545
+ 'agg_curves.cpp' ,
546
+ 'agg_image_filters.cpp' ,
547
+ 'agg_trans_affine.cpp' ,
548
+ 'agg_vcgen_contour.cpp' ,
549
+ 'agg_vcgen_dash.cpp' ,
550
+ 'agg_vcgen_stroke.cpp' ,
551
+ 'agg_vpgen_segmentator.cpp' ,
552
+ ]
553
+ ext .sources .extend (
554
+ os .path .join ('extern' , 'agg24-svn' , 'src' , x ) for x in agg_sources )
555
+
556
+
557
+ def add_qhull_flags (ext ):
558
+ # Qhull doesn't distribute pkg-config info, so we have no way of knowing
559
+ # whether a system install is recent enough. Thus, always use the vendored
560
+ # version.
561
+ ext .include_dirs .insert (0 , 'extern' )
562
+ ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
563
+ if sysconfig .get_config_var ('LIBM' ) == '-lm' :
564
+ ext .libraries .extend ('m' )
471
565
472
566
473
567
# For FreeType2 and libpng, we add a separate checkdep_foo.c source to at the
@@ -608,154 +702,11 @@ def do_custom_build(self):
608
702
str (pathlib .Path (src_path , "objs/.libs/libfreetype.lib" )))
609
703
610
704
611
- class FT2Font (SetupPackage ):
612
- name = 'ft2font'
613
-
614
- def get_extension (self ):
615
- sources = [
616
- 'src/ft2font.cpp' ,
617
- 'src/ft2font_wrapper.cpp' ,
618
- 'src/mplutils.cpp' ,
619
- 'src/py_converters.cpp' ,
620
- ]
621
- ext = Extension ('matplotlib.ft2font' , sources )
622
- FreeType ().add_flags (ext )
623
- add_numpy_flags (ext )
624
- LibAgg ().add_flags (ext , add_sources = False )
625
- return ext
626
-
627
-
628
- class Png (SetupPackage ):
629
- name = "png"
630
-
631
- def get_extension (self ):
632
- sources = [
633
- 'src/checkdep_libpng.c' ,
634
- 'src/_png.cpp' ,
635
- 'src/mplutils.cpp' ,
636
- ]
637
- ext = Extension ('matplotlib._png' , sources )
638
- pkg_config_setup_extension (
639
- ext , 'libpng' ,
640
- atleast_version = '1.2' ,
641
- alt_exec = ['libpng-config' , '--ldflags' ],
642
- default_libraries = (
643
- ['png' , 'z' ] if os .name == 'posix' else
644
- # libpng upstream names their lib libpng16.lib, not png.lib.
645
- # zlib upstream names their lib zlib.lib, not z.lib.
646
- ['libpng16' , 'zlib' ] if os .name == 'nt' else
647
- []
648
- ))
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
705
class BackendAgg (OptionalBackendPackage ):
755
706
name = "agg"
756
707
force = True
757
708
758
- def get_extension (self ):
709
+ def get_extensions (self ):
759
710
sources = [
760
711
"src/mplutils.cpp" ,
761
712
"src/py_converters.cpp" ,
@@ -764,9 +715,9 @@ def get_extension(self):
764
715
]
765
716
ext = Extension ('matplotlib.backends._backend_agg' , sources )
766
717
add_numpy_flags (ext )
767
- LibAgg (). add_flags (ext )
718
+ add_libagg_flags_and_sources (ext )
768
719
FreeType ().add_flags (ext )
769
- return ext
720
+ yield ext
770
721
771
722
772
723
class BackendTkAgg (OptionalBackendPackage ):
@@ -776,7 +727,7 @@ class BackendTkAgg(OptionalBackendPackage):
776
727
def check (self ):
777
728
return "installing; run-time loading from Python Tcl/Tk"
778
729
779
- def get_extension (self ):
730
+ def get_extensions (self ):
780
731
sources = [
781
732
'src/_tkagg.cpp' ,
782
733
'src/py_converters.cpp' ,
@@ -785,8 +736,8 @@ def get_extension(self):
785
736
ext = Extension ('matplotlib.backends._tkagg' , sources )
786
737
self .add_flags (ext )
787
738
add_numpy_flags (ext )
788
- LibAgg (). add_flags ( ext , add_sources = False )
789
- return ext
739
+ add_libagg_flags ( ext )
740
+ yield ext
790
741
791
742
def add_flags (self , ext ):
792
743
ext .include_dirs .insert (0 , 'src' )
@@ -807,12 +758,12 @@ def check(self):
807
758
raise CheckFailed ("Mac OS-X only" )
808
759
return super ().check ()
809
760
810
- def get_extension (self ):
761
+ def get_extensions (self ):
811
762
sources = [
812
763
'src/_macosx.m'
813
764
]
814
765
ext = Extension ('matplotlib.backends._macosx' , sources )
815
766
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
816
767
if platform .python_implementation ().lower () == 'pypy' :
817
768
ext .extra_compile_args .append ('-DPYPY=1' )
818
- return ext
769
+ yield ext
0 commit comments