@@ -314,13 +314,13 @@ def get_package_data(self):
314
314
"""
315
315
return {}
316
316
317
- def get_extension (self ):
317
+ def get_extensions (self ):
318
318
"""
319
- Get a list of C extensions (`distutils.core.Extension`
319
+ Return or yield a list of C extensions (`distutils.core.Extension`
320
320
objects) to add to the configuration. These are added to the
321
321
`extensions` list passed to `distutils.setup`.
322
322
"""
323
- return None
323
+ return []
324
324
325
325
def do_custom_build (self ):
326
326
"""
@@ -420,6 +420,70 @@ def get_package_data(self):
420
420
],
421
421
}
422
422
423
+ def get_extensions (self ):
424
+ # contour
425
+ ext = Extension ('matplotlib._contour' , [
426
+ "src/_contour.cpp" ,
427
+ "src/_contour_wrapper.cpp" ,
428
+ 'src/py_converters.cpp' ,
429
+ ])
430
+ add_numpy_flags (ext )
431
+ add_libagg_flags (ext )
432
+ yield ext
433
+ # ft2font
434
+ ext = Extension ('matplotlib.ft2font' , [
435
+ 'src/ft2font.cpp' ,
436
+ 'src/ft2font_wrapper.cpp' ,
437
+ 'src/mplutils.cpp' ,
438
+ 'src/py_converters.cpp' ,
439
+ ])
440
+ FreeType ().add_flags (ext )
441
+ add_numpy_flags (ext )
442
+ add_libagg_flags (ext )
443
+ yield ext
444
+ # image
445
+ ext = Extension ('matplotlib._image' , [
446
+ 'src/_image.cpp' ,
447
+ 'src/mplutils.cpp' ,
448
+ 'src/_image_wrapper.cpp' ,
449
+ 'src/py_converters.cpp'
450
+ ])
451
+ add_numpy_flags (ext )
452
+ add_libagg_flags_and_sources (ext )
453
+ yield ext
454
+ # path
455
+ ext = Extension ('matplotlib._path' , [
456
+ 'src/py_converters.cpp' ,
457
+ 'src/_path_wrapper.cpp'
458
+ ])
459
+ add_numpy_flags (ext )
460
+ add_libagg_flags_and_sources (ext )
461
+ yield ext
462
+ # qhull
463
+ ext = Extension ('matplotlib._qhull' , ['src/qhull_wrap.c' ],
464
+ define_macros = [('MPL_DEVNULL' , os .devnull )])
465
+ add_numpy_flags (ext )
466
+ add_qhull_flags (ext )
467
+ yield ext
468
+ # tri
469
+ ext = Extension ('matplotlib._tri' , [
470
+ "src/tri/_tri.cpp" ,
471
+ "src/tri/_tri_wrapper.cpp" ,
472
+ "src/mplutils.cpp"
473
+ ])
474
+ add_numpy_flags (ext )
475
+ yield ext
476
+ # ttconv
477
+ ext = Extension ('matplotlib.ttconv' , [
478
+ 'src/_ttconv.cpp' ,
479
+ 'extern/ttconv/pprdrv_tt.cpp' ,
480
+ 'extern/ttconv/pprdrv_tt2.cpp' ,
481
+ 'extern/ttconv/ttutil.cpp'
482
+ ])
483
+ add_numpy_flags (ext )
484
+ ext .include_dirs .insert (0 , 'extern' )
485
+ yield ext
486
+
423
487
424
488
class SampleData (OptionalPackage ):
425
489
"""
@@ -468,26 +532,38 @@ def add_numpy_flags(ext):
468
532
])
469
533
470
534
471
- class LibAgg (SetupPackage ):
472
- name = 'libagg'
473
-
474
- def add_flags (self , ext , add_sources = True ):
475
- # We need a patched Agg not available elsewhere, so always use the
476
- # vendored version.
477
- ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
478
- if add_sources :
479
- agg_sources = [
480
- 'agg_bezier_arc.cpp' ,
481
- 'agg_curves.cpp' ,
482
- 'agg_image_filters.cpp' ,
483
- 'agg_trans_affine.cpp' ,
484
- 'agg_vcgen_contour.cpp' ,
485
- 'agg_vcgen_dash.cpp' ,
486
- 'agg_vcgen_stroke.cpp' ,
487
- 'agg_vpgen_segmentator.cpp'
488
- ]
489
- ext .sources .extend (os .path .join ('extern' , 'agg24-svn' , 'src' , x )
490
- for x in agg_sources )
535
+ def add_libagg_flags (ext ):
536
+ # We need a patched Agg not available elsewhere, so always use the vendored
537
+ # version.
538
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
539
+
540
+
541
+ def add_libagg_flags_and_sources (ext ):
542
+ # We need a patched Agg not available elsewhere, so always use the vendored
543
+ # version.
544
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
545
+ agg_sources = [
546
+ 'agg_bezier_arc.cpp' ,
547
+ 'agg_curves.cpp' ,
548
+ 'agg_image_filters.cpp' ,
549
+ 'agg_trans_affine.cpp' ,
550
+ 'agg_vcgen_contour.cpp' ,
551
+ 'agg_vcgen_dash.cpp' ,
552
+ 'agg_vcgen_stroke.cpp' ,
553
+ 'agg_vpgen_segmentator.cpp' ,
554
+ ]
555
+ ext .sources .extend (
556
+ os .path .join ('extern' , 'agg24-svn' , 'src' , x ) for x in agg_sources )
557
+
558
+
559
+ def add_qhull_flags (ext ):
560
+ # Qhull doesn't distribute pkg-config info, so we have no way of knowing
561
+ # whether a system install is recent enough. Thus, always use the vendored
562
+ # version.
563
+ ext .include_dirs .insert (0 , 'extern' )
564
+ ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
565
+ if sysconfig .get_config_var ('LIBM' ) == '-lm' :
566
+ ext .libraries .extend ('m' )
491
567
492
568
493
569
# First compile checkdep_freetype2.c, which aborts the compilation either
@@ -621,129 +697,11 @@ def do_custom_build(self):
621
697
shutil .copy2 (lib_path , src_path / "objs/.libs/libfreetype.lib" )
622
698
623
699
624
- class FT2Font (SetupPackage ):
625
- name = 'ft2font'
626
-
627
- def get_extension (self ):
628
- sources = [
629
- 'src/ft2font.cpp' ,
630
- 'src/ft2font_wrapper.cpp' ,
631
- 'src/mplutils.cpp' ,
632
- 'src/py_converters.cpp' ,
633
- ]
634
- ext = Extension ('matplotlib.ft2font' , sources )
635
- FreeType ().add_flags (ext )
636
- add_numpy_flags (ext )
637
- LibAgg ().add_flags (ext , add_sources = False )
638
- return ext
639
-
640
-
641
- class Qhull (SetupPackage ):
642
- name = "qhull"
643
-
644
- def add_flags (self , ext ):
645
- # Qhull doesn't distribute pkg-config info, so we have no way of
646
- # knowing whether a system install is recent enough. Thus, always use
647
- # the vendored version.
648
- ext .include_dirs .insert (0 , 'extern' )
649
- ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
650
- if sysconfig .get_config_var ('LIBM' ) == '-lm' :
651
- ext .libraries .extend ('m' )
652
-
653
-
654
- class TTConv (SetupPackage ):
655
- name = "ttconv"
656
-
657
- def get_extension (self ):
658
- sources = [
659
- 'src/_ttconv.cpp' ,
660
- 'extern/ttconv/pprdrv_tt.cpp' ,
661
- 'extern/ttconv/pprdrv_tt2.cpp' ,
662
- 'extern/ttconv/ttutil.cpp'
663
- ]
664
- ext = Extension ('matplotlib.ttconv' , sources )
665
- add_numpy_flags (ext )
666
- ext .include_dirs .insert (0 , 'extern' )
667
- return ext
668
-
669
-
670
- class Path (SetupPackage ):
671
- name = "path"
672
-
673
- def get_extension (self ):
674
- sources = [
675
- 'src/py_converters.cpp' ,
676
- 'src/_path_wrapper.cpp'
677
- ]
678
- ext = Extension ('matplotlib._path' , sources )
679
- add_numpy_flags (ext )
680
- LibAgg ().add_flags (ext )
681
- return ext
682
-
683
-
684
- class Image (SetupPackage ):
685
- name = "image"
686
-
687
- def get_extension (self ):
688
- sources = [
689
- 'src/_image.cpp' ,
690
- 'src/mplutils.cpp' ,
691
- 'src/_image_wrapper.cpp' ,
692
- 'src/py_converters.cpp'
693
- ]
694
- ext = Extension ('matplotlib._image' , sources )
695
- add_numpy_flags (ext )
696
- LibAgg ().add_flags (ext )
697
-
698
- return ext
699
-
700
-
701
- class Contour (SetupPackage ):
702
- name = "contour"
703
-
704
- def get_extension (self ):
705
- sources = [
706
- "src/_contour.cpp" ,
707
- "src/_contour_wrapper.cpp" ,
708
- 'src/py_converters.cpp' ,
709
- ]
710
- ext = Extension ('matplotlib._contour' , sources )
711
- add_numpy_flags (ext )
712
- LibAgg ().add_flags (ext , add_sources = False )
713
- return ext
714
-
715
-
716
- class QhullWrap (SetupPackage ):
717
- name = "qhull_wrap"
718
-
719
- def get_extension (self ):
720
- sources = ['src/qhull_wrap.c' ]
721
- ext = Extension ('matplotlib._qhull' , sources ,
722
- define_macros = [('MPL_DEVNULL' , os .devnull )])
723
- add_numpy_flags (ext )
724
- Qhull ().add_flags (ext )
725
- return ext
726
-
727
-
728
- class Tri (SetupPackage ):
729
- name = "tri"
730
-
731
- def get_extension (self ):
732
- sources = [
733
- "src/tri/_tri.cpp" ,
734
- "src/tri/_tri_wrapper.cpp" ,
735
- "src/mplutils.cpp"
736
- ]
737
- ext = Extension ('matplotlib._tri' , sources )
738
- add_numpy_flags (ext )
739
- return ext
740
-
741
-
742
700
class BackendAgg (OptionalBackendPackage ):
743
701
name = "agg"
744
702
force = True
745
703
746
- def get_extension (self ):
704
+ def get_extensions (self ):
747
705
sources = [
748
706
"src/mplutils.cpp" ,
749
707
"src/py_converters.cpp" ,
@@ -752,9 +710,9 @@ def get_extension(self):
752
710
]
753
711
ext = Extension ('matplotlib.backends._backend_agg' , sources )
754
712
add_numpy_flags (ext )
755
- LibAgg (). add_flags (ext )
713
+ add_libagg_flags_and_sources (ext )
756
714
FreeType ().add_flags (ext )
757
- return ext
715
+ yield ext
758
716
759
717
760
718
class BackendTkAgg (OptionalBackendPackage ):
@@ -764,7 +722,7 @@ class BackendTkAgg(OptionalBackendPackage):
764
722
def check (self ):
765
723
return "installing; run-time loading from Python Tcl/Tk"
766
724
767
- def get_extension (self ):
725
+ def get_extensions (self ):
768
726
sources = [
769
727
'src/_tkagg.cpp' ,
770
728
'src/py_converters.cpp' ,
@@ -773,8 +731,8 @@ def get_extension(self):
773
731
ext = Extension ('matplotlib.backends._tkagg' , sources )
774
732
self .add_flags (ext )
775
733
add_numpy_flags (ext )
776
- LibAgg (). add_flags ( ext , add_sources = False )
777
- return ext
734
+ add_libagg_flags ( ext )
735
+ yield ext
778
736
779
737
def add_flags (self , ext ):
780
738
ext .include_dirs .insert (0 , 'src' )
@@ -795,12 +753,12 @@ def check(self):
795
753
raise CheckFailed ("Mac OS-X only" )
796
754
return super ().check ()
797
755
798
- def get_extension (self ):
756
+ def get_extensions (self ):
799
757
sources = [
800
758
'src/_macosx.m'
801
759
]
802
760
ext = Extension ('matplotlib.backends._macosx' , sources )
803
761
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
804
762
if platform .python_implementation ().lower () == 'pypy' :
805
763
ext .extra_compile_args .append ('-DPYPY=1' )
806
- return ext
764
+ yield ext
0 commit comments