matplotlib icon indicating copy to clipboard operation
matplotlib copied to clipboard

Tests in Distribution Files

Open npikall opened this issue 2 weeks ago • 2 comments

This may be a stupid question, but I don't see the reason why this is the case.

I was running the following (essentially checking out matplotlib in a venv)

uv init example
cd example
uv add matplotlib

This created a new repo with a virtual environment. When I was checking out example/.venv/lib/python3.13/site-packages/matplotlib I found the tests directory with a bunch of pytest files. Basically, these files seem to be distributed. I then ran du -h and found out that the tests alone amass to just about 2MB. This seems to be a lot of wasted disk space.

Therefore, my questions.

  • Are these tests actually used in the distributed package?
  • Would it make sense to exclude them from the distribution, if they are not used by any user anyway?

npikall avatar Dec 10 '25 17:12 npikall

The tests are provided so that user can test their installed copy of matplotlib. The wheels already drop the baseline images but they are included in the sdist.

I am mildly 👎🏻 as this has been long standing behavior and there is an interesting question if this would require a deprecation cycle.

tacaswell avatar Dec 10 '25 21:12 tacaswell

I have a slight preference for removing the tests. You‘ll need test dependencies and the reference images additionally, so it‘s anyway generally not easily possible to run the tests.

Instead, we should document the steps necessary to run the tests.

Side remark: To test an installation, you‘d likely not need to run the full tests suite. A small set of selected checks should be sufficient, similar to what’s discussed here: https://discuss.python.org/t/standard-library-health-check-module/ Ideally that could run without any dev dependencies. While it’s not a priority, such a functionality could start small and expand over time.

timhoffm avatar Dec 10 '25 23:12 timhoffm