8000 Added machinery for the mpl_baseline package · matplotlib/matplotlib@c726906 · GitHub
[go: up one dir, main page]

Skip to content

Commit c726906

Browse files
Added machinery for the mpl_baseline package
1 parent 7a3c3c5 commit c726906

File tree

17 files changed

+178
-46
lines changed

17 files changed

+178
-46
lines changed

.appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ test_script:
7575
# Now build the thing..
7676
- set LINK=/LIBPATH:%cd%\lib
7777
- pip install -ve .
78+
- cd sub-wheels/matplotlib-baseline-images && python -mpip install -ve .
79+
- cd ../..
7880
# this should show no freetype dll...
7981
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"
8082
- '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ install:
170170
fi
171171
- |
172172
python -mpip install -ve . # Install Matplotlib.
173+
cd sub-wheels/matplotlib-baseline-images && python -mpip install -ve .
174+
cd ../..
173175
- |
174176
if [[ $TRAVIS_OS_NAME != 'osx' ]]; then
175177
unset CPPFLAGS

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ recursive-include tutorials *
2121
include versioneer.py
2222
include lib/matplotlib/_version.py
2323
include tests.py
24+
prune sub-wheels

azure-pipelines.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ steps:
103103
[[ "$PYTHON_VERSION" = 'Pre' ]]
104104
displayName: "Install self"
105105

106+
- bash: |
107+
cd sub-wheels/matplotlib-baseline-images
108+
python -m pip install -ve .
109+
cd ../..
110+
displayName: "Install matplotlib_baseline_images"
111+
106112
- script: env
107113
displayName: 'print env'
108114

doc/devel/testing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ The first time this test is run, there will be no baseline image to compare
148148
against, so the test will fail. Copy the output images (in this case
149149
:file:`result_images/test_lines/test_line_dashes.png`) to the correct
150150
subdirectory of :file:`baseline_images` tree in the source directory (in this
151-
case :file:`lib/matplotlib/tests/baseline_images/test_lines`). Put this new
152-
file under source code revision control (with ``git add``). When rerunning
153-
the tests, they should now pass.
151+
case :file:`sub-wheels/matplotlib-baseline-images/lib`). Put this new file
152+
under source code revision control (with ``git add``). When rerunning the
153+
tests, they should now pass.
154154

155155
Baseline images take a lot of space in the Matplotlib repository.
156156
An alternative approach for image comparison tests is to use the

lib/matplotlib/testing/decorators.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,25 @@ def _image_directories(func):
482482
doesn't exist.
483483
"""
484484
module_path = Path(sys.modules[func.__module__].__file__)
485-
baseline_dir = module_path.parent / "baseline_images" / module_path.stem
485+
if func.__module__.startswith("matplotlib."):
486+
try:
487+
import matplotlib_baseline_images
488+
except:
489+
raise ImportError("Not able to import matplotlib_baseline_images")
490+
baseline_dir = (Path(matplotlib_baseline_images.__file__).parent /
491+
module_path.stem)
492+
elif func.__module__.startswith("mpl_toolkits."):
493+
try:
494+
import mpl_toolkits_baseline_images
495+
except:
496+
raise ImportError("Not able to import "
497+
"mpl_toolkits_baseline_images")
498+
baseline_dir = (Path(mpl_toolkits_baseline_images.__file__).parent /
499+
module_path.stem)
500+
else:
501+
baseline_dir = (module_path.parent /
502+
"baseline_images" /
503+
module_path.stem)
486504
result_dir = Path().resolve() / "result_images" / module_path.stem
487505
result_dir.mkdir(parents=True, exist_ok=True)
488506
return baseline_dir, result_dir

lib/matplotlib/tests/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from pathlib import Path
2-
3-
4-
# Check that the test directories exist.
5-
if not (Path(__file__).parent / 'baseline_images').exists():
6-
raise IOError(
1+
# Check for the matplotlib_baseline_images.
2+
try:
3+
import matplotlib_baseline_images
4+
except:
5+
raise ImportError(
76
'The baseline image directory does not exist. '
87
'This is most likely because the test data is not installed. '
9-
'You may need to install matplotlib from source to get the '
8+
'You may need to install matplotlib_baseline_images to get the '
109
'test data.')

lib/mpl_toolkits/tests/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from pathlib import Path
2-
3-
4-
# Check that the test directories exist
5-
if not (Path(__file__).parent / "baseline_images").exists():
6-
raise IOError(
1+
# Check for the mpl_toolkits_baseline_images.
2+
try:
3+
import mpl_toolkits_baseline_images
4+
except:
5+
raise ImportError(
76
'The baseline image directory does not exist. '
87
'This is most likely because the test data is not installed. '
9-
'You may need to install matplotlib from source to get the '
8+
'You may need to install mpl_toolkits_baseline_images to get the '
109
'test data.')

setup.cfg.template

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
[packages]
1616
# There are a number of data subpackages from Matplotlib that are
17-
# considered optional. All except 'tests' data (meaning the baseline
18-
# image files) are installed by default, but that can be changed here.
19-
#tests = False
17+
# considered optional. Sample data are installed by default, but that can be
18+
# changed here.
2019
#sample_data = True
2120

2221
[gui_support]

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
setupext.Platform(),
6060
setupext.FreeType(),
6161
setupext.SampleData(),
62-
setupext.Tests(),
6362
setupext.BackendMacOSX(),
6463
]
6564

setupext.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -444,24 +444,6 @@ def get_package_data(self):
444444
}
445445

446446

447-
class Tests(OptionalPackage):
448-
name = "tests"
449-
default_config = False
450-
451-
def get_package_data(self):
452-
return {
453-
'matplotlib': [
454-
*_pkg_data_helper('matplotlib', 'tests/baseline_images'),
455-
*_pkg_data_helper('matplotlib', 'tests/tinypages'),
456-
'tests/cmr10.pfb',
457-
'tests/mpltest.ttf',
458-
],
459-
'mpl_toolkits': [
460-
*_pkg_data_helper('mpl_toolkits', 'tests/baseline_images'),
461-
]
462-
}
463-
464-
465447
def add_numpy_flags(ext):
466448
import numpy as np
467449
ext.include_dirs.append(np.get_include())
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
License agreement for matplotlib versions 1.3.0 and later
2+
=========================================================
3+
4+
1. This LICENSE AGREEMENT is between the Matplotlib Development Team
5+
(" F438 MDT"), and the Individual or Organization ("Licensee") accessing and
6+
otherwise using matplotlib software in source or binary form and its
7+
associated documentation.
8+
9+
2. Subject to the terms and conditions of this License Agreement, MDT
10+
hereby grants Licensee a nonexclusive, royalty-free, world-wide license
11+
to reproduce, analyze, test, perform and/or display publicly, prepare
12+
derivative works, distribute, and otherwise use matplotlib
13+
alone or in any derivative version, provided, however, that MDT's
14+
License Agreement and MDT's notice of copyright, i.e., "Copyright (c)
15+
2012- Matplotlib Development Team; All Rights Reserved" are retained in
16+
matplotlib alone or in any derivative version prepared by
17+
Licensee.
18+
19+
3. In the event Licensee prepares a derivative work that is based on or
20+
incorporates matplotlib or any part thereof, and wants to
21+
make the derivative work available to others as provided herein, then
22+
Licensee hereby agrees to include in any such work a brief summary of
23+
the changes made to matplotlib .
24+
25+
4. MDT is making matplotlib available to Licensee on an "AS
26+
IS" basis. MDT MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
27+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, MDT MAKES NO AND
28+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
29+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB
30+
WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
31+
32+
5. MDT SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB
33+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
34+
LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
35+
MATPLOTLIB , OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
36+
THE POSSIBILITY THEREOF.
37+
38+
6. This License Agreement will automatically terminate upon a material
39+
breach of its terms and conditions.
40+
41+
7. Nothing in this License Agreement shall be deemed to create any
42+
relationship of agency, partnership, or joint venture between MDT and
43+
Licensee. This License Agreement does not grant permission to use MDT
44+
trademarks or trade name in a trademark sense to endorse or promote
45+
products or services of Licensee, or any third party.
46+
47+
8. By copying, installing or otherwise using matplotlib ,
48+
Licensee agrees to be bound by the terms and conditions of this License
49+
Agreement.
50+
51+
License agreement for matplotlib versions prior to 1.3.0
52+
========================================================
53+
54+
1. This LICENSE AGREEMENT is between John D. Hunter ("JDH"), and the
55+
Individual or Organization ("Licensee") accessing and otherwise using
56+
matplotlib software in source or binary form and its associated
57+
documentation.
58+
59+
2. Subject to the terms and conditions of this License Agreement, JDH
60+
hereby grants Licensee a nonexclusive, royalty-free, world-wide license
61+
to reproduce, analyze, test, perform and/or display publicly, prepare
62+
derivative works, distribute, and otherwise use matplotlib
63+
alone or in any derivative version, provided, however, that JDH's
64+
License Agreement and JDH's notice of copyright, i.e., "Copyright (c)
65+
2002-2011 John D. Hunter; All Rights Reserved" are retained in
66+
matplotlib alone or in any derivative version prepared by
67+
Licensee.
68+
69+
3. In the event Licensee prepares a derivative work that is based on or
70+
incorporates matplotlib or any part thereof, and wants to
71+
make the derivative work available to others as provided herein, then
72+
Licensee hereby agrees to include in any such work a brief summary of
73+
the changes made to matplotlib.
74+
75+
4. JDH is making matplotlib available to Licensee on an "AS
76+
IS" basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
77+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND
78+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
< 10000 /code>
79+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB
80+
WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
81+
82+
5. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB
83+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
84+
LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
85+
MATPLOTLIB , OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
86+
THE POSSIBILITY THEREOF.
87+
88+
6. This License Agreement will automatically terminate upon a material
89+
breach of its terms and conditions.
90+
91+
7. Nothing in this License Agreement shall be deemed to create any
92+
relationship of agency, partnership, or joint venture between JDH and
93+
Licensee. This License Agreement does not grant permission to use JDH
94+
trademarks or trade name in a trademark sense to endorse or promote
95+
products or services of Licensee, or any third party.
96+
97+
8. By copying, installing or otherwise using matplotlib,
98+
Licensee agrees to be bound by the terms and conditions of this License
99+
Agreement.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Matplotlib-baseline-images is a data package containing matplotlib baseline images and matplotlib toolkit baseline images.
2+
Baseline images were earlier installed with the matplotlib. Now they are separately installed with the main matplotlib package.

sub-wheels/matplotlib-baseline-images/lib/matplotlib_baseline_images/__init__.py

Whitespace-only changes.

sub-wheels/matplotlib-baseline-images/lib/mpl_toolkits_baseline_images/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from setuptools import setup, find_packages
2+
import sys
3+
import subprocess
4+
5+
# The version number of the matplotlib_baseline_images should be same as that
6+
# of matplotlib package. Checking the matplotlib version number needs cwd as
7+
# the grandparent directory without changing the directory in the
8+
# sub-wheels/matplotlib-baseline-images/setup.py.
9+
__version__ = subprocess.check_output(
10+
[sys.executable, "setup.py", "--version"], cwd="../..",
11+
universal_newlines=True).rstrip("\n")
12+
13+
setup(
14+
name="matplotlib-baseline-images",
15+
version=__version__,
16+
description="Package contains mpl baseline images and mpl toolkit images",
17+
package_dir={"": "lib"},
18+
packages=find_packages("lib"),
19+
include_package_data=True,
20+
install_requires=["matplotlib=={}".format(__version__)],
21+
)

tools/triage_tests.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@
3737
# order to find the source, we need to search for a match in one of
3838
# these two places.
3939

40-
BASELINE_IMAGES = [
41-
Path('lib/matplotlib/tests/baseline_images'),
42-
Path('lib/mpl_toolkits/tests/baseline_images'),
43-
]
44-
45-
40+
try:
41+
import matplotlib_baseline_images
42+
import mpl_toolkits_baseline_images
43+
BASELINE_IMAGES = [
44+
(Path(matplotlib_baseline_images.__file__)),
45+
(Path(mpl_toolkits_baseline_images.__file__)),
46+
]
47+
except:
48+
raise ImportError("Not able to import baseline images packages")
4649
# Non-png image extensions
4750

4851
exts = ['pdf', 'svg']

0 commit comments

Comments
 (0)
0