8000 Add utility to remove test images · MacPython/matplotlib-wheels@216ed29 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Commit 216ed29

Browse files
committed
Add utility to remove test images
1 parent 1ef65d6 commit 216ed29

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ install:
7979
# Maybe get and clean and patch source
8080
- clean_code $REPO_DIR $BUILD_COMMIT
8181
- build_wheel $REPO_DIR $PLAT
82+
# Remove test images
83+
- pip install delocate
84+
- python rm_test_images.py wheelhouse/*.whl
8285

8386
script:
8487
# increase number of open files allowed for tests, on OSX

rm_test_images.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env
2+
""" Remove test images from matplotlib wheel(s)
3+
"""
4+
from __future__ import print_function
5+
6+
from os.path import join as pjoin, basename, abspath, isdir
7+
from shutil import rmtree
8+
from argparse import ArgumentParser
9+
10+
from subprocess import check_call, check_output
11+
12+
IMAGE_PATH = pjoin('matplotlib', 'tests', 'baseline_images')
13+
14+
from delocate.wheeltools import InWheelCtx
15+
16+
17+
def get_needed(lib_fname):
18+
res = check_output(['patchelf', '--print-needed'] + [lib_fname])
19+
return [name.strip() for name in res.decode('latin1').splitlines()]
20+
21+
22+
def rm_needed(lib_name, lib_fname):
23+
check_call(['patchelf', '--remove-needed', lib_name, lib_fname])
24+
25+
26+
def rm_images(whl_fname, out_fname, verbose=False):
27+
whl_fname = abspath(whl_fname)
28+
out_fname = abspath(out_fname)
29+
with InWheelCtx(whl_fname) as ctx:
30+
if not isdir(IMAGE_PATH):
31+
if verbose:
32+
print('No {} in {}'.format(IMAGE_PATH, whl_fname))
33+
return
34+
rmtree(IMAGE_PATH)
35+
# Write the wheel
36+
ctx.out_wheel = out_fname
37+
38+
39+
def get_parser():
40+
parser = ArgumentParser()
41+
parser.add_argument('whl_fnames', nargs='+')
42+
parser.add_argument('--verbose', action='store_true')
43+
parser.add_argument('--out-path')
44+
return parser
45+
46+
47+
def main():
48+
args = get_parser().parse_args()
49+
for whl_fname in args.whl_fnames:
50+
out_fname = (pjoin(args.out_path, basename(whl_fname)) if args.out_path
51+
else whl_fname)
52+
if args.verbose:
53+
print('Removing test images from {}'.format(whl_fname))
54+
rm_images(whl_fname, out_fname, verbose=args.verbose)
55+
56+
57+
if __name__ == "__main__":
58+
main()

0 commit comments

Comments
 (0)
0