From 19a588999c0fa5602c072ed8c258c809a4c43e3c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 22 Jul 2018 02:33:29 +0200 Subject: [PATCH] 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 73d7eb8bea39..41b242669a2e 100644 --- a/doc/devel/release_guide.rst +++ b/doc/devel/release_guide.rst @@ -188,6 +188,10 @@ Once you have collected all of the wheels, 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. You should use ``twine`` to upload all of the files to pypi :: 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__)] +)