From 29c8245d0a28d70851b0be8635a88cf2c70316f0 Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 29 Sep 2021 18:44:09 +0200 Subject: Auto-discover usvg and svg-flatten properly --- gerbolyze/gerbolyze.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gerbolyze') diff --git a/gerbolyze/gerbolyze.py b/gerbolyze/gerbolyze.py index d4b4ab5..53b10a4 100755 --- a/gerbolyze/gerbolyze.py +++ b/gerbolyze/gerbolyze.py @@ -624,17 +624,24 @@ def svg_to_gerber(infile, outfile, candidates = [os.environ['SVG_FLATTEN']] else: - # By default, try three options: + # By default, try four options: candidates = [ # somewhere in $PATH 'svg-flatten', + 'wasi-svg-flatten', # in user-local pip installation Path.home() / '.local' / 'bin' / 'svg-flatten', - # next to our current python interpreter (e.g. in virtualenv + Path.home() / '.local' / 'bin' / 'wasi-svg-flatten', + # next to our current python interpreter (e.g. in virtualenv) str(Path(sys.executable).parent / 'svg-flatten'), + str(Path(sys.executable).parent / 'wasi-svg-flatten'), # next to this python source file in the development repo str(Path(__file__).parent.parent / 'svg-flatten' / 'build' / 'svg-flatten') ] + # if SVG_FLATTEN envvar is set, try that first. + if 'SVG_FLATTEN' in os.environ: + candidates = [os.environ['SVG_FLATTEN'], *candidates] + args = [ '--format', ('gerber-outline' if outline_mode else 'gerber'), '--precision', '6', # intermediate file, use higher than necessary precision '--trace-space', str(trace_space) ] -- cgit