Skip to content

FIX Inkscape version detection when diagnostic messages precede version output#624

Merged
mvdoc merged 3 commits into
mainfrom
copilot/fix-inkscape-version-detection
May 7, 2026
Merged

FIX Inkscape version detection when diagnostic messages precede version output#624
mvdoc merged 3 commits into
mainfrom
copilot/fix-inkscape-version-detection

Conversation

Copilot AI commented May 7, 2026

Copy link
Copy Markdown
Contributor

On some Linux systems (e.g. CentOS/RHEL), Inkscape prints a libgc workaround message before the version line, causing INKSCAPE_VERSION to be set to _INKSCAPE_GC=disable instead of the actual version string. This breaks any LooseVersion comparison (e.g. in svgoverlay.get_texture and utils.add_roi), raising a TypeError.

Changes

  • cortex/testing_utils.pyinkscape_version()

    • Replace blind output.split()[1] with line-by-line parsing of combined stdout+stderr
    • Return the version token only from the line starting with Inkscape
    • Switch from check_output to sp.run(..., check=True) to capture both streams
  • cortex/tests/test_testing_utils.py — new unit tests for inkscape_version() covering:

    • Inkscape not installed → None
    • Clean stdout → version parsed correctly
    • Newer version string format (e.g. 1.2.2)
    • Diagnostic noise before version line on stdout (regression test for the bug)
    • Diagnostic noise on stderr, version on stdout
    • No Inkscape line in output → None
    • Non-zero exit code → CalledProcessError propagated

Before — breaks when Inkscape emits extra output:

output = sp.check_output(cmd.split(), stderr=sp.PIPE)
version = output.split()[1]  # grabs '_INKSCAPE_GC=disable' instead of '1.2.2'

After — robust to diagnostic noise on stdout or stderr:

result = sp.run(cmd.split(), stdout=sp.PIPE, stderr=sp.PIPE, check=True)
combined = result.stdout + result.stderr
for line in combined.decode('utf-8').splitlines():
    if line.strip().startswith('Inkscape'):
        return line.split()[1]  # always '1.2.2'

Copilot AI changed the title [WIP] Fix Inkscape version detection to capture correct version string Fix Inkscape version detection when diagnostic messages precede version output May 7, 2026
Copilot finished work on behalf of mvdoc May 7, 2026 17:50
Copilot AI requested a review from mvdoc May 7, 2026 17:50
@mvdoc

mvdoc commented May 7, 2026

Copy link
Copy Markdown
Contributor

@copilot add tests

Copilot AI commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add tests

Added 7 unit tests in cortex/tests/test_testing_utils.py (commit 96c354d), covering:

  • Inkscape not installed → None
  • Clean stdout → version parsed correctly
  • Newer version string (e.g. 1.2.2)
  • Diagnostic noise before version line on stdout — regression test for the bug
  • Diagnostic noise on stderr, version on stdout
  • No Inkscape line in output → None
  • Non-zero exit code → CalledProcessError propagated

Copilot finished work on behalf of mvdoc May 7, 2026 18:16
@mvdoc mvdoc changed the title Fix Inkscape version detection when diagnostic messages precede version output FIX Inkscape version detection when diagnostic messages precede version output May 7, 2026
@mvdoc mvdoc marked this pull request as ready for review May 7, 2026 23:41
@mvdoc mvdoc merged commit c70ddf5 into main May 7, 2026
13 checks passed
@mvdoc mvdoc deleted the copilot/fix-inkscape-version-detection branch May 7, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inkscape version detection captures irrelevant output, breaking LooseVersion comparison

2 participants