diff --git a/setup.cfg.template b/setup.cfg.template index 09fd92f7134e..9d50b4441582 100644 --- a/setup.cfg.template +++ b/setup.cfg.template @@ -83,3 +83,9 @@ # #backend = Agg # + +[package_data] +# Package additional files found in the lib/matplotlib directories. +# +# On Windows, package DLL files. +#dlls = True diff --git a/setup.py b/setup.py index b896f6f84c11..392ed2c8c28b 100644 --- a/setup.py +++ b/setup.py @@ -110,7 +110,9 @@ setupext.DviPng(), setupext.Ghostscript(), setupext.LaTeX(), - setupext.PdfToPs() + setupext.PdfToPs(), + 'Optional package data', + setupext.Dlls(), ] diff --git a/setupext.py b/setupext.py index 3011bf9e9834..33b4a5c30f58 100755 --- a/setupext.py +++ b/setupext.py @@ -2165,3 +2165,34 @@ def check(self): pass raise CheckFailed() + + +class OptionalPackageData(OptionalPackage): + config_category = "package_data" + + +class Dlls(OptionalPackageData): + """ + On Windows, this packages any DLL files that can be found in the + lib/matplotlib/* directories. + """ + name = "dlls" + + def check_requirements(self): + if sys.platform != 'win32': + raise CheckFailed("Microsoft Windows only") + + def get_package_data(self): + return {'': ['*.dll']} + + @classmethod + def get_config(cls): + """ + Look at `setup.cfg` and return one of ["auto", True, False] indicating + if the package is at default state ("auto"), forced by the user (True) + or opted-out (False). + """ + try: + return config.getboolean(cls.config_category, cls.name) + except: + return False # <-- default