[ebuild R ] dev-python/lxml-4.9.4 USE="threads -debug -doc -examples -test" PYTHON_TARGETS="python3_11 -pypy3 -python3_10 -python3_12" [ebuild R ] media-gfx/inkscape-1.3.2 USE="X exif jpeg readline -cdr -dia -graphicsmagick -imagemagick -inkjar -openmp -postscript -sourceview -spell -svg2 -test -visio -wpg" PYTHON_SINGLE_TARGET="python3_11 -python3_10" Both Inkscape and lxml are installed for Python 3.11 only, yet Inkscape fails to find lxml at runtime when I attempt to use the "Optimized SVG" output extension: Traceback (most recent call last): File "/usr/share/inkscape/extensions/output_scour.py", line 7, in <module> import inkex File "/usr/share/inkscape/extensions/inkex/__init__.py", line 11, in <module> from .extensions import * File "/usr/share/inkscape/extensions/inkex/extensions.py", line 34, in <module> from .elements import ( File "/usr/share/inkscape/extensions/inkex/elements/__init__.py", line 9, in <module> from ._parser import SVG_PARSER, load_svg File "/usr/share/inkscape/extensions/inkex/elements/_parser.py", line 30, in <module> from lxml import etree ModuleNotFoundError: No module named 'lxml' It appears that Inkscape is executing Python scripts in /usr/share/inkscape/extensions/ without EPYTHON having been set in the environment. Thus, when python-exec's global default python3 interpreter is Python 3.12, these scripts are interpreted under Python 3.12, and thus they can't find their dependencies, which are installed for Python 3.11 only. Shouldn't there be some wrapper when launching Inkscape that sets EPYTHON to the correct value corresponding to the active PYTHON_SINGLE_TARGET so that any Python scripts executed by Inkscape will exec the correct python3 interpreter version?
inkscape uses python-single-r1, so python_fix_shebang or similar needs to be used on its installed scripts.
(In reply to Sam James from comment #1) > inkscape uses python-single-r1, so python_fix_shebang or similar needs to be > used on its installed scripts. .. if there's no shebang on them (can't check right now), and inkscape is doing something else (if it does, say, python /path/to/foo.py), then ofc a different strategy may be needed
I can confirm that launching Inkscape using the command line "EPYTHON=python3.11 inkscape" does allow the plugin to work as expected. Munging the shebang lines in the extension scripts (yes, they do have them) would probably also work, but I haven't tried it.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f3867c8f2e4b1f7dcaa0c2e19812b3133bed141 commit 8f3867c8f2e4b1f7dcaa0c2e19812b3133bed141 Author: Sam James <sam@gentoo.org> AuthorDate: 2024-03-12 00:49:40 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-03-12 00:52:22 +0000 media-gfx/inkscape: fix Python dependencies & shebangs * Fix Python dependency (needs pillow for jpeg/tiff/webp at least) * Fix shebangs on Python extensions so we respect PYTHON_SINGLE_TARGET Closes: https://bugs.gentoo.org/924747 Closes: https://bugs.gentoo.org/922320 Signed-off-by: Sam James <sam@gentoo.org> media-gfx/inkscape/inkscape-1.3.2-r1.ebuild | 208 ++++++++++++++++++++++++++++ media-gfx/inkscape/inkscape-9999.ebuild | 5 +- 2 files changed, 210 insertions(+), 3 deletions(-)
Either this has broken again, or it was never really fixed. Today I tried saving an drawing using the "Optimized SVG" output format, which delegates to the output_scour.py Inkscape extension. I got this error: Traceback (most recent call last): File "/usr/share/inkscape/extensions/output_scour.py", line 6, in <module> import inkex File "/usr/share/inkscape/extensions/inkex/__init__.py", line 11, in <module> from .extensions import * File "/usr/share/inkscape/extensions/inkex/extensions.py", line 32, in <module> from .utils import errormsg, Boolean File "/usr/share/inkscape/extensions/inkex/utils.py", line 34, in <module> import numpy as np ModuleNotFoundError: No module named 'numpy' dev-python/numpy is installed for Python 3.11 and 3.12 but not for 3.13. When I launch Inkscape using "EPYTHON=python3.12 inkscape", then the output plugin works fine. The shebang line in /usr/share/inkscape/extensions/output_scour.py is #!/usr/bin/python3.12, so I think there needs to be a different solution, as evidently Inkscape is not executing the script in a manner that respects the shebang line. To be sure, I can run "python3.12 -c 'import numpy'" with no error, but "python -c 'import numpy'" throws a ModuleNotFoundError.