build: add a inkscape wrapper for 1.0 compatibility (#43865)

This commit is contained in:
Thomas NOËL 2020-06-10 13:39:13 +02:00
parent 331e42c5fd
commit 83a70d3489
2 changed files with 18 additions and 1 deletions

15
inkscape_wrapper.py Executable file
View File

@ -0,0 +1,15 @@
#! /usr/bin/env python3
# inkscape wrapper to support command-line parameters for <1.0 and 1.0
# versions.
import subprocess
import sys
inkscape_version = subprocess.check_output('inkscape --version', shell=True)
args = sys.argv[1:]
if b'Inkscape 0' not in inkscape_version:
# --export-png replaced by --export-filename
# --without-gui and --file removed
args = [x.replace('--export-png', '--export-filename') for x in args if x not in ('--without-gui', '--file')]
sys.exit(subprocess.call(['inkscape'] + args))

View File

@ -17,6 +17,8 @@ from distutils.command.build import build as _build
from distutils.command.sdist import sdist
from setuptools import setup, find_packages
inkscape = os.path.abspath(os.path.join(os.path.dirname(__file__), 'inkscape_wrapper.py'))
class eo_sdist(sdist):
def run(self):
@ -181,7 +183,7 @@ class build_icons(Command):
f.write(ET.tostring(tree))
f.close()
subprocess.call(['inkscape', '--without-gui',
subprocess.call([inkscape, '--without-gui',
'--file', f.name,
'--export-area-drawing',
'--export-area-snap',