feat(confluence): make SVG processing optional to fix pycairo install… #20115
+649
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make SVG processing optional to fix pycairo installation issues
Description
Referring to Issue
This PR addresses critical installation failures on Debian/Ubuntu systems caused by
svglib 1.6.0
introducing breaking changes that requirepycairo
compilation. Thepycairo
package requires system-level C compilers (gcc
) and Cairo development libraries (cairo-dev
), which are often not available in minimal Docker images or CI/CD environments.Problem:
svglib>=1.5.1,<2
was a required dependencypycairo
requiring C compilation and system librariesSolution:
svglib
an optional dependency via Python's extras mechanismType of Change
Note: While SVG processing now requires explicit installation with
[svg]
extra, this is NOT a breaking change due to graceful degradation. Existing code continues to work - SVG attachments are simply skipped with informative warnings when dependencies are not installed.Changes Made
Core Implementation
pyproject.toml
: Movedsvglib>=1.5.1,<1.6.0
to[project.optional-dependencies]
sectionbase.py
: Enhancedprocess_svg()
method with:event.py
: AddedFileType.SVG = "svg"
to enum for custom parser registrationrequirements.txt
: Auto-updated to reflect dependency changesDocumentation
README.md
: Added "Optional Dependencies" section with installation instructionsCHANGELOG.md
: Documented the change and migration pathMIGRATION_GUIDE.md
: Created comprehensive guide with 4 migration options:Testing & Examples
tests/test_svg_optional.py
: Added 4 unit tests covering:examples/svg_parsing_examples.py
: Created working examples demonstrating all 4 approachesInstallation Options
Default (No SVG support):
With SVG support:
pip install 'llama-index-readers-confluence[svg]'
With custom parser (no pycairo needed):
Backward Compatibility
✅ Fully maintained through graceful degradation:
[svg]
extraHow Has This Been Tested?
Test Results:
Smoke Tests:
New Package?
Version Bump?
Suggested Checklist
uv run make format; uv run make lint
to appease the lint godsAdditional Context
This follows the established Python pattern for optional dependencies (similar to
pandas[excel]
,requests[security]
, etc.). Users who don't need SVG processing benefit from faster installation without C compilation requirements, while users who need SVG support can explicitly opt-in.The implementation provides three migration paths:
See
MIGRATION_GUIDE.md
for detailed migration instructions and examples.