@@ -608,37 +608,37 @@ def check(self):
608608 return sys .version
609609
610610
611+ def _pkg_data_helper (pkg , subdir ):
612+ """Glob "lib/$pkg/$subdir/**/*", returning paths relative to "lib/$pkg"."""
613+ base = pathlib .Path ("lib" , pkg )
614+ return [str (path .relative_to (base )) for path in (base / subdir ).rglob ("*" )]
615+
616+
611617class Matplotlib (SetupPackage ):
612618 name = "matplotlib"
613619
614620 def check (self ):
615621 return versioneer .get_version ()
616622
617623 def get_packages (self ):
618- return setuptools .find_packages (
619- "lib" ,
620- include = [ "matplotlib" , "matplotlib.*" ],
621- exclude = [ "matplotlib.tests" , "matplotlib.*.tests" ])
624+ return setuptools .find_packages ("lib" , exclude = [ "*.tests" ])
625+
626+ def get_namespace_packages ( self ):
627+ return [ 'mpl_toolkits' ]
622628
623629 def get_py_modules (self ):
624630 return ['pylab' ]
625631
626632 def get_package_data (self ):
627-
628- def iter_dir (base ):
629- return [
630- str (path .relative_to ('lib/matplotlib' ))
631- for path in pathlib .Path ('lib/matplotlib' , base ).rglob ('*' )]
632-
633633 return {
634- 'matplotlib' :
635- [
634+ 'matplotlib' : [
636635 'mpl-data/matplotlibrc' ,
637- * iter_dir ('mpl-data/fonts' ),
638- * iter_dir ('mpl-data/images' ),
639- * iter_dir ('mpl-data/stylelib' ),
640- * iter_dir ('backends/web_backend' ),
641- ]}
636+ * _pkg_data_helper ('matplotlib' , 'mpl-data/fonts' ),
637+ * _pkg_data_helper ('matplotlib' , 'mpl-data/images' ),
638+ * _pkg_data_helper ('matplotlib' , 'mpl-data/stylelib' ),
639+ * _pkg_data_helper ('matplotlib' , 'backends/web_backend' ),
640+ ],
641+ }
642642
643643
644644class SampleData (OptionalPackage ):
@@ -649,39 +649,17 @@ class SampleData(OptionalPackage):
649649 name = "sample_data"
650650
651651 def get_package_data (self ):
652-
653- def iter_dir (base ):
654- return [
655- str (path .relative_to ('lib/matplotlib' ))
656- for path in pathlib .Path ('lib/matplotlib' , base ).rglob ('*' )]
657-
658652 return {
659- 'matplotlib' :
660- [
661- * iter_dir ('mpl-data/sample_data' ),
662- ]}
663-
664-
665- class Toolkits (OptionalPackage ):
666- name = "toolkits"
667-
668- def get_packages (self ):
669- return [
670- 'mpl_toolkits' ,
671- 'mpl_toolkits.mplot3d' ,
672- 'mpl_toolkits.axes_grid' ,
673- 'mpl_toolkits.axes_grid1' ,
674- 'mpl_toolkits.axisartist' ,
675- ]
676-
677- def get_namespace_packages (self ):
678- return ['mpl_toolkits' ]
653+ 'matplotlib' : [
654+ * _pkg_data_helper ('matplotlib' , 'mpl-data/sample_data' ),
655+ ],
656+ }
679657
680658
681659class Tests (OptionalPackage ):
682660 name = "tests"
683661 pytest_min_version = '3.6'
684- default_config = False
662+ default_config = True
685663
686664 def check (self ):
687665 super ().check ()
@@ -706,61 +684,24 @@ def check(self):
706684 return ' / ' .join (msgs )
707685
708686 def get_packages (self ):
709- return [
710- 'matplotlib.tests' ,
711- 'matplotlib.sphinxext.tests' ,
712- ]
687+ return setuptools .find_packages ("lib" , include = ["*.tests" ])
713688
714689 def get_package_data (self ):
715- baseline_images = [
716- 'tests/baseline_images/%s/*' % x
717- for x in os .listdir ('lib/matplotlib/tests/baseline_images' )]
718-
719690 return {
720- 'matplotlib' :
721- baseline_images +
722- [
691+ 'matplotlib' : [
692+ * _pkg_data_helper ('matplotlib' , 'tests/baseline_images' ),
723693 'tests/cmr10.pfb' ,
724694 'tests/mpltest.ttf' ,
725695 'tests/test_rcparams.rc' ,
726696 'tests/test_utf32_be_rcparams.rc' ,
727697 'sphinxext/tests/tinypages/*.rst' ,
728698 'sphinxext/tests/tinypages/*.py' ,
729699 'sphinxext/tests/tinypages/_static/*' ,
730- ]}
731-
732-
733- class Toolkits_Tests (Tests ):
734- name = "toolkits_tests"
735-
736- def check_requirements (self ):
737- conf = self .get_config ()
738- toolkits_conf = Toolkits .get_config ()
739- tests_conf = Tests .get_config ()
740-
741- if conf is True :
742- Tests .force = True
743- Toolkits .force = True
744- elif conf == "auto" and not (toolkits_conf and tests_conf ):
745- # Only auto-install if both toolkits and tests are set
746- # to be installed
747- raise CheckFailed ("toolkits_tests needs 'toolkits' and 'tests'" )
748- return ""
749-
750- def get_packages (self ):
751- return [
752- 'mpl_toolkits.tests' ,
700+ ],
701+ 'mpl_toolkits' : [
702+ * _pkg_data_helper ('mpl_toolkits' , 'tests/baseline_images' ),
753703 ]
754-
755- def get_package_data (self ):
756- baseline_images = [
757- 'tests/baseline_images/%s/*' % x
758- for x in os .listdir ('lib/mpl_toolkits/tests/baseline_images' )]
759-
760- return {'mpl_toolkits' : baseline_images }
761-
762- def get_namespace_packages (self ):
763- return ['mpl_toolkits' ]
704+ }
764705
765706
766707class DelayedExtension (Extension , object ):
0 commit comments