From 781c5405dfe2f140094e9bb324be9dbc11b997ce Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 22 Jul 2018 02:33:29 +0200 Subject: [PATCH 1/3] Add machinery to generate test-only wheels. Generate a matplotlib.tests wheel that can be uploaded to PyPI as a separate PyPI package ("distribution", in distutils parlance), to make it possible to install tests and test data from PyPI. This is useful e.g. for mplcairo, whose test suite relies on matplotlib's one. --- doc/devel/release_guide.rst | 4 ++++ sub-wheels/matplotlib.tests/README.rst | 12 ++++++++++++ sub-wheels/matplotlib.tests/setup.py | 27 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 sub-wheels/matplotlib.tests/README.rst create mode 100644 sub-wheels/matplotlib.tests/setup.py diff --git a/doc/devel/release_guide.rst b/doc/devel/release_guide.rst index aac6fe5438fc..8e09d9e03c75 100644 --- a/doc/devel/release_guide.rst +++ b/doc/devel/release_guide.rst @@ -277,6 +277,10 @@ day), generate the tarball :: git checkout v2.0.0 git clean -xfd python setup.py sdist + # Generate test-only wheels. + for dir in sub-wheels/*; do + (cd "$dir" && python setup.py bdist_wheel) + done and copy all of the wheels into :file:`dist` directory. First, check that the dist files are OK :: diff --git a/sub-wheels/matplotlib.tests/README.rst b/sub-wheels/matplotlib.tests/README.rst new file mode 100644 index 000000000000..1bbf9b4fa118 --- /dev/null +++ b/sub-wheels/matplotlib.tests/README.rst @@ -0,0 +1,12 @@ +Running ``python setup.py bdist_wheel`` (*not* ``pip wheel .``) generates a +wheel for a ``matplotlib.tests`` distribution (in the distutils sense, i.e. +a PyPI package) that can be installed alongside a main, test-less Matplotlib +distribution. + +Note that + +- ``pip wheel`` doesn't work as that starts by copying the *current* directory + to a temporary one (for isolation purposes), before we get to ``chdir`` back + to the root directory. +- ``python setup.py sdist`` doesn't work as that would pick up the + ``MANIFEST.in`` file in the root directory. diff --git a/sub-wheels/matplotlib.tests/setup.py b/sub-wheels/matplotlib.tests/setup.py new file mode 100644 index 000000000000..fc1a589f4712 --- /dev/null +++ b/sub-wheels/matplotlib.tests/setup.py @@ -0,0 +1,27 @@ +import os +from pathlib import Path +import sys + + +rootdir = str(Path(__file__).resolve().parents[2]) +sys.path.insert(0, rootdir) +os.chdir(rootdir) + + +from setuptools import setup, find_packages +import versioneer + + +__version__ = versioneer.get_version() + + +if "sdist" in sys.argv: + sys.exit("Only wheels can be generated.") +setup( + name="matplotlib.tests", + version=__version__, + package_dir={"": "lib"}, + packages=find_packages("lib", include=["*.tests"]), + include_package_data=True, + install_requires=["matplotlib=={}".format(__version__)] +) From b96c4c709b7051aaf4ce0144c13f9a54ae24c2cb Mon Sep 17 00:00:00 2001 From: SidharthBansal Date: Mon, 25 May 2020 13:36:19 +0530 Subject: [PATCH 2/3] Handle changes in MANIFEST --- MANIFEST.in | 2 -- sub-wheels/matplotlib.tests/MANIFEST.in | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 sub-wheels/matplotlib.tests/MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in index 39e693f1014f..37dd3758c67f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include INSTALL.rst README.rst -include pytest.ini include MANIFEST.in include matplotlibrc.template setup.cfg.template include setupext.py setup.py @@ -20,4 +19,3 @@ recursive-include tools * recursive-include tutorials * include versioneer.py include lib/matplotlib/_version.py -include tests.py diff --git a/sub-wheels/matplotlib.tests/MANIFEST.in b/sub-wheels/matplotlib.tests/MANIFEST.in new file mode 100644 index 000000000000..d57f0933a594 --- /dev/null +++ b/sub-wheels/matplotlib.tests/MANIFEST.in @@ -0,0 +1,4 @@ +include sub-wheels/matplotlib.tests/README.rst +include sub-wheels/matplotlib.tests/MANIFEST.in +include pytest.ini +include tests.py From 7fd5a0246b8388d4a51b9737e6c2023a8f4623dc Mon Sep 17 00:00:00 2001 From: SidharthBansal Date: Mon, 25 May 2020 13:59:51 +0530 Subject: [PATCH 3/3] Handled setup.cfg --- setup.cfg.template | 7 ------- sub-wheels/matplotlib.tests/MANIFEST.in | 1 + sub-wheels/matplotlib.tests/setup.cfg.template | 8 ++++++++ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 sub-wheels/matplotlib.tests/setup.cfg.template diff --git a/setup.cfg.template b/setup.cfg.template index 562544fb1e59..f0882a7573f6 100644 --- a/setup.cfg.template +++ b/setup.cfg.template @@ -9,13 +9,6 @@ #system_freetype = False #system_qhull = False -[packages] -# There are a number of data subpackages from Matplotlib that are -# considered optional. All except 'tests' data (meaning the baseline -# image files) are installed by default, but that can be changed here. -#tests = False -#sample_data = True - [gui_support] # Matplotlib supports multiple GUI toolkits, known as backends. # The MacOSX backend requires the Cocoa headers included with XCode. diff --git a/sub-wheels/matplotlib.tests/MANIFEST.in b/sub-wheels/matplotlib.tests/MANIFEST.in index d57f0933a594..cbbebbab4daa 100644 --- a/sub-wheels/matplotlib.tests/MANIFEST.in +++ b/sub-wheels/matplotlib.tests/MANIFEST.in @@ -1,4 +1,5 @@ include sub-wheels/matplotlib.tests/README.rst include sub-wheels/matplotlib.tests/MANIFEST.in +include matplotlibrc.template sub-wheels/matplotlib.test/setup.cfg.template include pytest.ini include tests.py diff --git a/sub-wheels/matplotlib.tests/setup.cfg.template b/sub-wheels/matplotlib.tests/setup.cfg.template new file mode 100644 index 000000000000..99868180f5f5 --- /dev/null +++ b/sub-wheels/matplotlib.tests/setup.cfg.template @@ -0,0 +1,8 @@ +# Rename this file to setup.cfg to modify Matplotlib-tests's build options. + +[packages] +# There are a number of data subpackages from Matplotlib that are +# considered optional. All except 'tests' data (meaning the baseline +# image files) are installed by default, but that can be changed here. +#tests = False +#sample_data = True