Closed dstansby closed 4 years ago
does
diff --git i/lib/matplotlib/testing/compare.py w/lib/matplotlib/testing/compare.py
index 06f2074e0..0e1258f79 100644
--- i/lib/matplotlib/testing/compare.py
+++ w/lib/matplotlib/testing/compare.py
@@ -173,7 +173,7 @@ class _SVGConverter(_Converter):
# just be reported as a regular exception below).
"DISPLAY": "",
# Do not load any user options.
- "INKSCAPE_PROFILE_DIR": os.devnull,
+ "INKSCAPE_PROFILE_DIR": self._tmpdir.name,
}
# Old versions of Inkscape (e.g. 0.48.3.1) seem to sometimes
# deadlock when stderr is redirected to a pipe, so we redirect it
help?
It stops the invalid directory error, but the "Inkscape encountered and internal error and will close now" message still pops up and a sample test now fails with
self = <matplotlib.testing.compare._SVGConverter object at 0x7fb6ac092700>
orig = PosixPath('/Users/dstansby/github/matplotlib/result_images/test_patches/all_quadrants_arcs.svg')
dest = PosixPath('/Users/dstansby/github/matplotlib/result_images/test_patches/all_quadrants_arcs_svg.png')
def __call__(self, orig, dest):
old_inkscape = mpl._get_executable_info("inkscape").version < "1"
terminator = b"\n>" if old_inkscape else b"> "
if not hasattr(self, "_tmpdir"):
self._tmpdir = TemporaryDirectory()
if (not self._proc # First run.
or self._proc.poll() is not None): # Inkscape terminated.
env = {
**os.environ,
# If one passes e.g. a png file to Inkscape, it will try to
# query the user for conversion options via a GUI (even with
# `--without-gui`). Unsetting `DISPLAY` prevents this (and
# causes GTK to crash and Inkscape to terminate, but that'll
# just be reported as a regular exception below).
"DISPLAY": "",
# Do not load any user options.
"INKSCAPE_PROFILE_DIR": self._tmpdir.name,
}
# Old versions of Inkscape (e.g. 0.48.3.1) seem to sometimes
# deadlock when stderr is redirected to a pipe, so we redirect it
# to a temporary file instead. This is not necessary anymore as of
# Inkscape 0.92.1.
stderr = TemporaryFile()
self._proc = subprocess.Popen(
["inkscape", "--without-gui", "--shell"] if old_inkscape else
["inkscape", "--shell"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr,
env=env, cwd=self._tmpdir.name)
# Slight abuse, but makes shutdown handling easier.
self._proc.stderr = stderr
try:
self._read_until(terminator)
except _ConverterError as err:
raise OSError("Failed to start Inkscape in interactive "
"mode") from err
# Inkscape's shell mode does not support escaping metacharacters in the
# filename ("\n", and ":;" for inkscape>=1). Avoid any problems by
# running from a temporary directory and using fixed filenames.
inkscape_orig = Path(self._tmpdir.name, os.fsdecode(b"f.svg"))
inkscape_dest = Path(self._tmpdir.name, os.fsdecode(b"f.png"))
try:
inkscape_orig.symlink_to(Path(orig).resolve())
except OSError:
shutil.copyfile(orig, inkscape_orig)
self._proc.stdin.write(
b"f.svg --export-png=f.png\n" if old_inkscape else
b"file-open:f.svg;export-filename:f.png;export-do;file-close\n")
self._proc.stdin.flush()
try:
self._read_until(terminator)
except _ConverterError as err:
# Inkscape's output is not localized but gtk's is, so the output
# stream probably has a mixed encoding. Using the filesystem
# encoding should at least get the filenames right...
self._proc.stderr.seek(0)
> raise ImageComparisonFailure(
self._proc.stderr.read().decode(
sys.getfilesystemencoding(), "replace")) from err
E matplotlib.testing.exceptions.ImageComparisonFailure: Pango version: 1.43.0
E InkscapeApplication::shell: Failed to find file in |file-open:f.svg;export-filename:f.png;export-do;file-close|
E verbs_action: Invalid verb: file-open
E
E Emergency save activated!
E Emergency save completed. Inkscape will close now.
E If you can reproduce this crash, please file a bug at https://inkscape.org/report
E with a detailed description of the steps leading to the crash, so we can fix it.
what does inkscape --action-list
give you? (and I guess inkscape --verb-list
, while we're at it)
Thanks for the debug help!
Looks like the command matplotlib is calling should be FileOpen
etc. instead of file-open
?
No, FileOpen goes through the GUI; there's should also be a file-open action for non-interactive opening. (Unless you manage to make it work with FileOpen...) file-open works locally on linux + inkscape 1.0, at least; perhaps it's a inkscape 1.0b2 vs 1.0 thing?
Ah fab, working fine now with 1.0. Turns out I hadn't upgraded in a while. Thanks!
Bug report
When I try to run the tests, all the
.svg
tests fail because of an Inkscape crash. When a svg test runs, an Inkscape window opens:Clicking through this leads to another window:
which then leads to the test crashing. My Inkscape version is Inkscape 1.0beta2 (2b71d25, 2019-12-03), installd through homebrew. Perhaps this is a compatability issue with Inkscape 1.0?
The full traceback is:
Matplotlib version
print(matplotlib.get_backend())
): QT5Agg