From e3cff5cc9f74c31e3707f85a468c6d558ade3e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 15 Mar 2024 22:45:15 +0100 Subject: [PATCH] build: do not recreate images in install phase (#88254) --- setup.py | 3 +++ src/render-imgs-categories.py | 7 +++++++ src/render-imgs-dashboard.py | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/setup.py b/setup.py index 5b849bf8..076d0890 100644 --- a/setup.py +++ b/setup.py @@ -162,6 +162,9 @@ class build_icons(Command): 'python3 src/render-imgs-dashboard.py static/somme-cd80/img/ --normal 4D4D4D ' '--selected 87A738 --title FFFFFF --title-width 80', ] + if self.distribution.commands == ['install']: + cmds = [f'{x} --skip-existing' for x in cmds] + if not os.path.exists('static/tournai/img'): os.mkdir('static/tournai/img') for image in glob.glob('static/tournai/assets/*.svg'): diff --git a/src/render-imgs-categories.py b/src/render-imgs-categories.py index 2988e120..0c13e21e 100644 --- a/src/render-imgs-categories.py +++ b/src/render-imgs-categories.py @@ -92,6 +92,7 @@ parser = argparse.ArgumentParser() parser.add_argument('path', help='out path') parser.add_argument('--primary', default='E0037A') parser.add_argument('--secondary', default='6D1F80') +parser.add_argument('--skip-existing', action='store_true') args = parser.parse_args() path_out = args.path @@ -100,6 +101,12 @@ os.makedirs(path_out, exist_ok=True) for filename in filenames: outname = names.get(re.search(r'\d+', filename).group()) + if ( + args.skip_existing + and os.path.exists(os.path.join(path_out, '%s.png' % outname)) + and os.path.exists(os.path.join(path_out, '%s-on.png' % outname)) + ): + continue fd = open('tmp-%s.svg' % outname, 'w') fd.write( diff --git a/src/render-imgs-dashboard.py b/src/render-imgs-dashboard.py index 576f2c3f..de2820e0 100644 --- a/src/render-imgs-dashboard.py +++ b/src/render-imgs-dashboard.py @@ -56,6 +56,7 @@ parser.add_argument('--selected-width') parser.add_argument('--title') parser.add_argument('--title-height') parser.add_argument('--title-width') +parser.add_argument('--skip-existing', action='store_true') args = parser.parse_args() path_out = args.path @@ -88,6 +89,9 @@ for filename in filenames: else: out_filepath = os.path.join(path_out, '%s.png' % icon_name) + if args.skip_existing and os.path.exists(out_filepath): + continue + for node in tree.iter(): tag_name = node.tag.split('}')[-1] if tag_name == 'path':