From c60df5ee95d875d75d0c402daae7fba5992af3e7 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 8 May 2019 18:00:22 +0200 Subject: [PATCH] In setup.py, inline the packages that need to be installed into setup(). ... instead of hiding that behind a function call in setupext. Also always install the test source files -- setting `tests = False` in setup.cfg now only ignores the test data (this is also consistent with the contents of `matplotlib/tests/__init__.py which is clearly intended to handle the case where the test source files are installed but not the baseline images). This is done for simplicity of implementation and also to make it possibly easier to separately install the baseline images (as these are now pure "data") in the future. --- setup.py | 22 +++++++--------------- setupext.py | 37 ------------------------------------- 2 files changed, 7 insertions(+), 52 deletions(-) diff --git a/setup.py b/setup.py index 98461de24520..823f04ba58e8 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ import os from zipfile import ZipFile -from setuptools import setup, Extension +from setuptools import setup, find_packages, Extension from setuptools.command.build_ext import build_ext as BuildExtCommand from setuptools.command.develop import develop as DevelopCommand from setuptools.command.install_lib import install_lib as InstallLibCommand @@ -169,12 +169,7 @@ def run(self): # however, this is needed on Windows to avoid creating infinite subprocesses # when using multiprocessing. if __name__ == '__main__': - # These are distutils.setup parameters that the various packages add - # things to. - packages = [] - namespace_packages = [] - py_modules = [] - package_data = {} + package_data = {} # Will be filled below by the various components. # If the user just queries for information, don't bother figuring out which # packages to build or install. @@ -224,9 +219,6 @@ def run(self): # Now collect all of the information we need to build all of the # packages. for package in good_packages: - packages.extend(package.get_packages()) - namespace_packages.extend(package.get_namespace_packages()) - py_modules.extend(package.get_py_modules()) # Extension modules only get added in build_ext, as numpy will have # been installed (as setup_requires) at that point. data = package.get_package_data() @@ -267,14 +259,14 @@ def run(self): interfaces and hardcopy output formats. """, license="PSF", - packages=packages, - namespace_packages=namespace_packages, - platforms='any', - py_modules=py_modules, + platforms="any", + package_dir={"": "lib"}, + packages=find_packages("lib"), + namespace_packages=["mpl_toolkits"], + py_modules=["pylab"], # Dummy extension to trigger build_ext, which will swap it out with # real extensions that can depend on numpy for the build. ext_modules=[Extension("", [])], - package_dir={"": "lib"}, package_data=package_data, classifiers=classifiers, diff --git a/setupext.py b/setupext.py index e0a805bdd4f7..fc22b404f777 100644 --- a/setupext.py +++ b/setupext.py @@ -8,7 +8,6 @@ import os import pathlib import platform -import setuptools import shlex import shutil import subprocess @@ -310,30 +309,6 @@ def check(self): """ pass - def get_packages(self): - """ - Get a list of package names to add to the configuration. - These are added to the `packages` list passed to - `distutils.setup`. - """ - return [] - - def get_namespace_packages(self): - """ - Get a list of namespace package names to add to the configuration. - These are added to the `namespace_packages` list passed to - `distutils.setup`. - """ - return [] - - def get_py_modules(self): - """ - Get a list of top-level modules to add to the configuration. - These are added to the `py_modules` list passed to - `distutils.setup`. - """ - return [] - def get_package_data(self): """ Get a package data dictionary to add to the configuration. @@ -485,15 +460,6 @@ class Matplotlib(SetupPackage): def check(self): return versioneer.get_version() - def get_packages(self): - return setuptools.find_packages("lib", exclude=["*.tests"]) - - def get_namespace_packages(self): - return ['mpl_toolkits'] - - def get_py_modules(self): - return ['pylab'] - def get_package_data(self): return { 'matplotlib': [ @@ -525,9 +491,6 @@ class Tests(OptionalPackage): name = "tests" default_config = False - def get_packages(self): - return setuptools.find_packages("lib", include=["*.tests"]) - def get_package_data(self): return { 'matplotlib': [