@@ -283,13 +283,13 @@ def get_package_data(self):
283
283
"""
284
284
return {}
285
285
286
- def get_extension (self ):
286
+ def get_extensions (self ):
287
287
"""
288
- Get a list of C extensions (`distutils.core.Extension`
288
+ Return or yield a list of C extensions (`distutils.core.Extension`
289
289
objects) to add to the configuration. These are added to the
290
290
`extensions` list passed to `distutils.setup`.
291
291
"""
292
- return None
292
+ return []
293
293
294
294
def do_custom_build (self ):
295
295
"""
@@ -388,6 +388,70 @@ def get_package_data(self):
388
388
],
389
389
}
390
390
391
+ def get_extensions (self ):
392
+ # contour
393
+ ext = Extension ('matplotlib._contour' , [
394
+ "src/_contour.cpp" ,
395
+ "src/_contour_wrapper.cpp" ,
396
+ 'src/py_converters.cpp' ,
397
+ ])
398
+ add_numpy_flags (ext )
399
+ add_libagg_flags (ext )
400
+ yield ext
401
+ # ft2font
402
+ ext = Extension ('matplotlib.ft2font' , [
403
+ 'src/ft2font.cpp' ,
404
+ 'src/ft2font_wrapper.cpp' ,
405
+ 'src/mplutils.cpp' ,
406
+ 'src/py_converters.cpp' ,
407
+ ])
408
+ FreeType ().add_flags (ext )
409
+ add_numpy_flags (ext )
410
+ add_libagg_flags (ext )
411
+ yield ext
412
+ # image
413
+ ext = Extension ('matplotlib._image' , [
414
+ 'src/_image.cpp' ,
415
+ 'src/mplutils.cpp' ,
416
+ 'src/_image_wrapper.cpp' ,
417
+ 'src/py_converters.cpp'
418
+ ])
419
+ add_numpy_flags (ext )
420
+ add_libagg_flags_and_sources (ext )
421
+ yield ext
422
+ # path
423
+ ext = Extension ('matplotlib._path' , [
424
+ 'src/py_converters.cpp' ,
425
+ 'src/_path_wrapper.cpp'
426
+ ])
427
+ add_numpy_flags (ext )
428
+ add_libagg_flags_and_sources (ext )
429
+ yield ext
430
+ # qhull
431
+ ext = Extension ('matplotlib._qhull' , ['src/qhull_wrap.c' ],
432
+ define_macros = [('MPL_DEVNULL' , os .devnull )])
433
+ add_numpy_flags (ext )
434
+ add_qhull_flags (ext )
435
+ yield ext
436
+ # tri
437
+ ext = Extension ('matplotlib._tri' , [
438
+ "src/tri/_tri.cpp" ,
439
+ "src/tri/_tri_wrapper.cpp" ,
440
+ "src/mplutils.cpp"
441
+ ])
442
+ add_numpy_flags (ext )
443
+ yield ext
444
+ # ttconv
445
+ ext = Extension ('matplotlib.ttconv' , [
446
+ 'src/_ttconv.cpp' ,
447
+ 'extern/ttconv/pprdrv_tt.cpp' ,
448
+ 'extern/ttconv/pprdrv_tt2.cpp' ,
449
+ 'extern/ttconv/ttutil.cpp'
450
+ ])
451
+ add_numpy_flags (ext )
452
+ ext .include_dirs .insert (0 , 'extern' )
453
+ yield ext
454
+
391
455
392
456
class SampleData (OptionalPackage ):
393
457
"""
@@ -436,26 +500,38 @@ def add_numpy_flags(ext):
436
500
])
437
501
438
502
439
- class LibAgg (SetupPackage ):
440
- name = 'libagg'
441
-
442
- def add_flags (self , ext , add_sources = True ):
443
- # We need a patched Agg not available elsewhere, so always use the
444
- # vendored version.
445
- ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
446
- if add_sources :
447
- agg_sources = [
448
- 'agg_bezier_arc.cpp' ,
449
- 'agg_curves.cpp' ,
450
- 'agg_image_filters.cpp' ,
451
- 'agg_trans_affine.cpp' ,
452
- 'agg_vcgen_contour.cpp' ,
453
- 'agg_vcgen_dash.cpp' ,
454
- 'agg_vcgen_stroke.cpp' ,
455
- 'agg_vpgen_segmentator.cpp'
456
- ]
457
- ext .sources .extend (os .path .join ('extern' , 'agg24-svn' , 'src' , x )
458
- for x in agg_sources )
503
+ def add_libagg_flags (ext ):
504
+ # We need a patched Agg not available elsewhere, so always use the vendored
505
+ # version.
506
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
507
+
508
+
509
+ def add_libagg_flags_and_sources (ext ):
510
+ # We need a patched Agg not available elsewhere, so always use the vendored
511
+ # version.
512
+ ext .include_dirs .insert (0 , 'extern/agg24-svn/include' )
513
+ agg_sources = [
514
+ 'agg_bezier_arc.cpp' ,
515
+ 'agg_curves.cpp' ,
516
+ 'agg_image_filters.cpp' ,
517
+ 'agg_trans_affine.cpp' ,
518
+ 'agg_vcgen_contour.cpp' ,
519
+ 'agg_vcgen_dash.cpp' ,
520
+ 'agg_vcgen_stroke.cpp' ,
521
+ 'agg_vpgen_segmentator.cpp' ,
522
+ ]
523
+ ext .sources .extend (
524
+ os .path .join ('extern' , 'agg24-svn' , 'src' , x ) for x in agg_sources )
525
+
526
+
527
+ def add_qhull_flags (ext ):
528
+ if options .get ('system_qhull' ):
529
+ ext .libraries .append ('qhull' )
530
+ else :
531
+ ext .include_dirs .insert (0 , 'extern' )
532
+ ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
533
+ if sysconfig .get_config_var ('LIBM' ) == '-lm' :
534
+ ext .libraries .extend ('m' )
459
535
460
536
461
537
# First compile checkdep_freetype2.c, which aborts the compilation either
@@ -589,129 +665,11 @@ def do_custom_build(self):
589
665
shutil .copy2 (lib_path , src_path / "objs/.libs/libfreetype.lib" )
590
666
591
667
592
- class FT2Font (SetupPackage ):
593
- name = 'ft2font'
594
-
595
- def get_extension (self ):
596
- sources = [
597
- 'src/ft2font.cpp' ,
598
- 'src/ft2font_wrapper.cpp' ,
599
- 'src/mplutils.cpp' ,
600
- 'src/py_converters.cpp' ,
601
- ]
602
- ext = Extension ('matplotlib.ft2font' , sources )
603
- FreeType ().add_flags (ext )
604
- add_numpy_flags (ext )
605
- LibAgg ().add_flags (ext , add_sources = False )
606
- return ext
607
-
608
-
609
- class Qhull (SetupPackage ):
610
- name = "qhull"
611
-
612
- def add_flags (self , ext ):
613
- if options .get ('system_qhull' ):
614
- ext .libraries .append ('qhull' )
615
- else :
616
- ext .include_dirs .insert (0 , 'extern' )
617
- ext .sources .extend (sorted (glob .glob ('extern/libqhull/*.c' )))
618
- if sysconfig .get_config_var ('LIBM' ) == '-lm' :
619
- ext .libraries .extend ('m' )
620
-
621
-
622
- class TTConv (SetupPackage ):
623
- name = "ttconv"
624
-
625
- def get_extension (self ):
626
- sources = [
627
- 'src/_ttconv.cpp' ,
628
- 'extern/ttconv/pprdrv_tt.cpp' ,
629
- 'extern/ttconv/pprdrv_tt2.cpp' ,
630
- 'extern/ttconv/ttutil.cpp'
631
- ]
632
- ext = Extension ('matplotlib.ttconv' , sources )
633
- add_numpy_flags (ext )
634
- ext .include_dirs .insert (0 , 'extern' )
635
- return ext
636
-
637
-
638
- class Path (SetupPackage ):
639
- name = "path"
640
-
641
- def get_extension (self ):
642
- sources = [
643
- 'src/py_converters.cpp' ,
644
- 'src/_path_wrapper.cpp'
645
- ]
646
- ext = Extension ('matplotlib._path' , sources )
647
- add_numpy_flags (ext )
648
- LibAgg ().add_flags (ext )
649
- return ext
650
-
651
-
652
- class Image (SetupPackage ):
653
- name = "image"
654
-
655
- def get_extension (self ):
656
- sources = [
657
- 'src/_image.cpp' ,
658
- 'src/mplutils.cpp' ,
659
- 'src/_image_wrapper.cpp' ,
660
- 'src/py_converters.cpp'
661
- ]
662
- ext = Extension ('matplotlib._image' , sources )
663
- add_numpy_flags (ext )
664
- LibAgg ().add_flags (ext )
665
-
666
- return ext
667
-
668
-
669
- class Contour (SetupPackage ):
670
- name = "contour"
671
-
672
- def get_extension (self ):
673
- sources = [
674
- "src/_contour.cpp" ,
675
- "src/_contour_wrapper.cpp" ,
676
- 'src/py_converters.cpp' ,
677
- ]
678
- ext = Extension ('matplotlib._contour' , sources )
679
- add_numpy_flags (ext )
680
- LibAgg ().add_flags (ext , add_sources = False )
681
- return ext
682
-
683
-
684
- class QhullWrap (SetupPackage ):
685
- name = "qhull_wrap"
686
-
687
- def get_extension (self ):
688
- sources = ['src/qhull_wrap.c' ]
689
- ext = Extension ('matplotlib._qhull' , sources ,
690
- define_macros = [('MPL_DEVNULL' , os .devnull )])
691
- add_numpy_flags (ext )
692
- Qhull ().add_flags (ext )
693
- return ext
694
-
695
-
696
- class Tri (SetupPackage ):
697
- name = "tri"
698
-
699
- def get_extension (self ):
700
- sources = [
701
- "src/tri/_tri.cpp" ,
702
- "src/tri/_tri_wrapper.cpp" ,
703
- "src/mplutils.cpp"
704
- ]
705
- ext = Extension ('matplotlib._tri' , sources )
706
- add_numpy_flags (ext )
707
- return ext
708
-
709
-
710
668
class BackendAgg (OptionalBackendPackage ):
711
669
name = "agg"
712
670
force = True
713
671
714
- def get_extension (self ):
672
+ def get_extensions (self ):
715
673
sources = [
716
674
"src/mplutils.cpp" ,
717
675
"src/py_converters.cpp" ,
@@ -720,9 +678,9 @@ def get_extension(self):
720
678
]
721
679
ext = Extension ('matplotlib.backends._backend_agg' , sources )
722
680
add_numpy_flags (ext )
723
- LibAgg (). add_flags (ext )
681
+ add_libagg_flags_and_sources (ext )
724
682
FreeType ().add_flags (ext )
725
- return ext
683
+ yield ext
726
684
727
685
728
686
class BackendTkAgg (OptionalBackendPackage ):
@@ -732,7 +690,7 @@ class BackendTkAgg(OptionalBackendPackage):
732
690
def check (self ):
733
691
return "installing; run-time loading from Python Tcl/Tk"
734
692
735
- def get_extension (self ):
693
+ def get_extensions (self ):
736
694
sources = [
737
695
'src/_tkagg.cpp' ,
738
696
'src/py_converters.cpp' ,
@@ -741,8 +699,8 @@ def get_extension(self):
741
699
ext = Extension ('matplotlib.backends._tkagg' , sources )
742
700
self .add_flags (ext )
743
701
add_numpy_flags (ext )
744
- LibAgg (). add_flags ( ext , add_sources = False )
745
- return ext
702
+ add_libagg_flags ( ext )
703
+ yield ext
746
704
747
705
def add_flags (self , ext ):
748
706
ext .include_dirs .insert (0 , 'src' )
@@ -763,12 +721,12 @@ def check(self):
763
721
raise CheckFailed ("Mac OS-X only" )
764
722
return super ().check ()
765
723
766
- def get_extension (self ):
724
+ def get_extensions (self ):
767
725
sources = [
768
726
'src/_macosx.m'
769
727
]
770
728
ext = Extension ('matplotlib.backends._macosx' , sources )
771
729
ext .extra_link_args .extend (['-framework' , 'Cocoa' ])
772
730
if platform .python_implementation ().lower () == 'pypy' :
773
731
ext .extra_compile_args .append ('-DPYPY=1' )
774
- return ext
732
+ yield ext
0 commit comments