unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Inkscape export errors
@ 2020-10-20 12:53 Ekaitz Zarraga
  2020-10-20 16:34 ` Thorsten Wilms
  2020-10-21 13:03 ` Ludovic Courtès
  0 siblings, 2 replies; 8+ messages in thread
From: Ekaitz Zarraga @ 2020-10-20 12:53 UTC (permalink / raw)
  To: guix-devel\@gnu.org

Hi,

I'm experiencing export errors in Inkscape 1.0.1 on several formats like DXF or Optimized SVG. I'm getting the following error:

```
Traceback (most recent call last):
  File "output_scour.py", line 8, in <module>
    import inkex
  File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/__init__.py", line 11, in <module>
    from .extensions import *
  File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/extensions.py", line 33, in <module>
    from .elements import load_svg, BaseElement, ShapeElement, Group, Layer, Grid, \
  File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/elements/__init__.py", line 8, in <module>
    from ._base import SVG_PARSER, load_svg, ShapeElement, BaseElement
  File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/elements/_base.py", line 31, in <module>
    from lxml import etree
ModuleNotFoundError: No module named 'lxml'
```

I suppose it's because python-lxml package is not included in Inkscape. Is there any reason for that?

I tried to edit package description to add python-lxml as a propagated input but it didn't work. Why is that?
Also, adding python-lxml as a propagated input should leave it available system wide, shouldn't it? Am I getting this wrong?

Thanks for your help.

Cheers,
Ekaitz



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-20 12:53 Inkscape export errors Ekaitz Zarraga
@ 2020-10-20 16:34 ` Thorsten Wilms
  2020-10-20 17:51   ` Ekaitz Zarraga
  2020-10-21 13:03 ` Ludovic Courtès
  1 sibling, 1 reply; 8+ messages in thread
From: Thorsten Wilms @ 2020-10-20 16:34 UTC (permalink / raw)
  To: guix-devel\@gnu.org

On Tue, 20 Oct 2020 12:53:58 +0000
Ekaitz Zarraga <ekaitz@elenq.tech> wrote:
 
> I'm experiencing export errors in Inkscape 1.0.1 on several formats
> like DXF or Optimized SVG. I'm getting the following error:

> I suppose it's because python-lxml package is not included in
> Inkscape. Is there any reason for that?

For optimized SVG, the error is due to missing the package scour, which
I meant to report, but was just reminded of because of your email.

---
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning:
the imp module is deprecated in favour of importlib; see the module's
documentation for alternative uses import fnmatch, glob, traceback,
errno, sys, atexit, locale, imp Traceback (most recent call last): File
"output_scour.py", line 11, in <module> import scour
ModuleNotFoundError: No module named 'scour'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "output_scour.py", line 17, in <module>
    """)
inkex.utils.DependencyError: Failed to import module 'scour'.
Please make sure it is installed (e.g. using 'pip install scour'
  or 'sudo apt-get install python-scour') and try again.
---

-- 
Thorsten Wilms <t_w_@freenet.de>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-20 16:34 ` Thorsten Wilms
@ 2020-10-20 17:51   ` Ekaitz Zarraga
  2020-10-21  7:35     ` Thorsten Wilms
  0 siblings, 1 reply; 8+ messages in thread
From: Ekaitz Zarraga @ 2020-10-20 17:51 UTC (permalink / raw)
  To: Thorsten Wilms; +Cc: guix-devel\\@gnu.org

> For optimized SVG, the error is due to missing the package scour, which
> I meant to report, but was just reminded of because of your email.
>
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
> /usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning:
> the imp module is deprecated in favour of importlib; see the module's
> documentation for alternative uses import fnmatch, glob, traceback,
> errno, sys, atexit, locale, imp Traceback (most recent call last): File
> "output_scour.py", line 11, in <module> import scour
> ModuleNotFoundError: No module named 'scour'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "output_scour.py", line 17, in <module>
>
>     """)
>
>
> inkex.utils.DependencyError: Failed to import module 'scour'.
> Please make sure it is installed (e.g. using 'pip install scour'
> or 'sudo apt-get install python-scour') and try again.
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> --
>
> Thorsten Wilms t_w_@freenet.de

Hi, thanks for the feedback.

I tried to replicate that and I can't.

I made some research. Yours is passing the "import inkex" line because it's able to load `lxml`.
The first question I'd like to make is: why?

If you check the code of the extensions under `output_scour.py`[^1] file:


``` python
#!/usr/bin/env python
"""
Run the scour module on the svg output.
"""

from distutils.version import StrictVersion

import inkex

try:
    import scour
    from scour.scour import scourString
except ImportError:
    raise inkex.DependencyError("""Failed to import module 'scour'.
Please make sure it is installed (e.g. using 'pip install scour'
  or 'sudo apt-get install python-scour') and try again.
""")
```

Yours is failing in the try-except block, in the `import scour` and mine fails before, in the `import inkex` line.

Any thoughts about why is this happening?

I tried to add python-lxml as a dep but it doesn't solve the import in any case.

Ideas?

Ekaitz

[^1]: https://gitlab.com/inkscape/extensions/-/blob/1.0.x/output_scour.py


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-20 17:51   ` Ekaitz Zarraga
@ 2020-10-21  7:35     ` Thorsten Wilms
  0 siblings, 0 replies; 8+ messages in thread
From: Thorsten Wilms @ 2020-10-21  7:35 UTC (permalink / raw)
  To: guix-devel

On Tue, 20 Oct 2020 17:51:09 +0000
Ekaitz Zarraga <ekaitz@elenq.tech> wrote:

> I made some research. Yours is passing the "import inkex" line
> because it's able to load `lxml`. The first question I'd like to make
> is: why?

No real idea. I can only note that my store contains python-lxml-4.4.2
and inkscape-1.0.1/share/inkscape/extensions/inkex.py.


-- 
Thorsten Wilms <t_w_@freenet.de>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-20 12:53 Inkscape export errors Ekaitz Zarraga
  2020-10-20 16:34 ` Thorsten Wilms
@ 2020-10-21 13:03 ` Ludovic Courtès
  2020-10-21 13:56   ` Ekaitz Zarraga
  1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2020-10-21 13:03 UTC (permalink / raw)
  To: Ekaitz Zarraga; +Cc: guix-devel@gnu.org

Egun on,

Ekaitz Zarraga <ekaitz@elenq.tech> skribis:

> I'm experiencing export errors in Inkscape 1.0.1 on several formats like DXF or Optimized SVG. I'm getting the following error:
>
> ```
> Traceback (most recent call last):
>   File "output_scour.py", line 8, in <module>
>     import inkex
>   File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/__init__.py", line 11, in <module>
>     from .extensions import *
>   File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/extensions.py", line 33, in <module>
>     from .elements import load_svg, BaseElement, ShapeElement, Group, Layer, Grid, \
>   File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/elements/__init__.py", line 8, in <module>
>     from ._base import SVG_PARSER, load_svg, ShapeElement, BaseElement
>   File "/gnu/store/ky8vkkxi4b7a3bqlbmlagmv5j2vdnafb-inkscape-1.0.1/share/inkscape/extensions/inkex/elements/_base.py", line 31, in <module>
>     from lxml import etree
> ModuleNotFoundError: No module named 'lxml'
> ```
>
> I suppose it's because python-lxml package is not included in Inkscape. Is there any reason for that?
>
> I tried to edit package description to add python-lxml as a propagated input but it didn't work. Why is that?

You would then need to include this variant of ‘inkscape’ alongside
‘python’ so that ~/.guix-profile/etc/profile sets ‘PYTHONPATH’
accordingly.

A better fix would be to use ‘wrap-program’ to wrap ‘inkscape’ such that
‘PYTHONPATH’ always points to ‘python-lxml’.  There are several examples
of packages that do that.

Does that make sense?

HTH,
Ludo’.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-21 13:03 ` Ludovic Courtès
@ 2020-10-21 13:56   ` Ekaitz Zarraga
  2020-10-21 15:59     ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Ekaitz Zarraga @ 2020-10-21 13:56 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel\@gnu.org

On Wednesday, October 21, 2020 2:03 PM, Ludovic Courtès <ludo@gnu.org> wrote:

> Egun on,

Saluton Ludo,

>
> You would then need to include this variant of ‘inkscape’ alongside
> ‘python’ so that ~/.guix-profile/etc/profile sets ‘PYTHONPATH’
> accordingly.
>
> A better fix would be to use ‘wrap-program’ to wrap ‘inkscape’ such that
> ‘PYTHONPATH’ always points to ‘python-lxml’. There are several examples
> of packages that do that.

Yes, kind of the same change I did on Icecat for the WebGL support.
This is going to create a shell script that sets the environment
variables and then call the actual binary, right?


> Does that make sense?

It does but it doesn't.

Why isn't inkscape detecting python-lxml if I can load it from the python
shell?
Does this mean the package's environment is being cleaned by someone else?
Why does Thorsten's (in the thread) inkscape detect lxml and
mine doesn't?
Isn't this supposed to be reproducible?

Sorry but I'm a little bit confused.

> HTH,
> Ludo’.

Thanks!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-21 13:56   ` Ekaitz Zarraga
@ 2020-10-21 15:59     ` Ludovic Courtès
  2020-10-21 17:17       ` Ekaitz Zarraga
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2020-10-21 15:59 UTC (permalink / raw)
  To: Ekaitz Zarraga; +Cc: guix-devel@gnu.org

Saluton!

Ekaitz Zarraga <ekaitz@elenq.tech> skribis:

>> You would then need to include this variant of ‘inkscape’ alongside
>> ‘python’ so that ~/.guix-profile/etc/profile sets ‘PYTHONPATH’
>> accordingly.
>>
>> A better fix would be to use ‘wrap-program’ to wrap ‘inkscape’ such that
>> ‘PYTHONPATH’ always points to ‘python-lxml’. There are several examples
>> of packages that do that.
>
> Yes, kind of the same change I did on Icecat for the WebGL support.
> This is going to create a shell script that sets the environment
> variables and then call the actual binary, right?

Exactly.

> Why isn't inkscape detecting python-lxml if I can load it from the python
> shell?
> Does this mean the package's environment is being cleaned by someone else?
> Why does Thorsten's (in the thread) inkscape detect lxml and
> mine doesn't?
> Isn't this supposed to be reproducible?

Heheh.  To make sure you’re both testing the same thing, use:

  guix environment --pure --ad-hoc inkscape -- inkscape

That will avoid interference from the environment.

Ludo’.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Inkscape export errors
  2020-10-21 15:59     ` Ludovic Courtès
@ 2020-10-21 17:17       ` Ekaitz Zarraga
  0 siblings, 0 replies; 8+ messages in thread
From: Ekaitz Zarraga @ 2020-10-21 17:17 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel\@gnu.org

Hi,

I think I managed to solve the issues.
All the issues I had were coming from the extensions' dependencies
not being added to Inkscape's.

With the following changes it's supposed to work (it worked in my
machine lol).

I had to package scour too, because it wasn't packaged.

I have a question here btw. In general, python deps are propagated,
and that makes sense. But in programs like inkscape and kicad they
are not propagated. Is this because they create a separate python
interpreter for themselves that has those dependencies separated?
That's why we need to wrap it?

Sorry for the amount of questions but I thought I could understand
it but now everything is blurred in my mind and I'm afraid of myself.
:)

Patch candidate below, please tell me if it makes sense or if it's
anything wrong and I'll update and send to guix-patches.

Thanks!

From 21a439f6f1978116584a6dc9ac80c0759c3fa771 Mon Sep 17 00:00:00 2001
From: Ekaitz Zarraga <ekaitz@elenq.tech>
Date: Wed, 21 Oct 2020 19:08:20 +0200
Subject: [PATCH] gnu: Correct Inkscape extension dependencies

    * gnu/packages/inkscape.scm (inkscape@1.0.1): Add dependencies.
    * gnu/packages/python-xyz.scm (python-scour): New variable.
---
 gnu/packages/inkscape.scm   | 27 +++++++++++++++++++++++++--
 gnu/packages/python-xyz.scm | 27 +++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/inkscape.scm b/gnu/packages/inkscape.scm
index 4ac3cf3966..b02a8ba8ef 100644
--- a/gnu/packages/inkscape.scm
+++ b/gnu/packages/inkscape.scm
@@ -44,6 +44,7 @@
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages popt)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages fontutils)
@@ -250,7 +251,25 @@ endif()~%~%"
          (add-after 'install 'glib-or-gtk-compile-schemas
            (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
          (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
-           (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
+           (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
+         (add-after 'install 'wrap-program
+           ;; Ensure correct Python at runtime.
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (python (assoc-ref inputs "python"))
+                    (file (string-append out "/bin/inkscape"))
+                    (path (string-append
+                           out
+                           "/lib/python"
+                           ,(version-major+minor
+                             (package-version python))
+                           "/site-packages:"
+                           (getenv "PYTHONPATH"))))
+               (wrap-program file
+                 `("PYTHONPATH" ":" prefix (,path))
+                 `("PATH" ":" prefix
+                   (,(string-append python "/bin:")))))
+             #t)))))
     (inputs
      `(("aspell" ,aspell)
        ("autotrace" ,autotrace)
@@ -283,7 +302,11 @@ endif()~%~%"
        ("googletest" ,googletest)
        ("perl" ,perl)
        ("pkg-config" ,pkg-config)
-       ("python" ,python-wrapper)))
+       ("python" ,python-wrapper)
+       ("python-scour" ,python-scour)
+       ("python-pyserial" ,python-pyserial)
+       ("python-numpy" ,python-numpy)
+       ("python-lxml" ,python-lxml)))
     (home-page "https://inkscape.org/")
     (synopsis "Vector graphics editor")
     (description "Inkscape is a vector graphics editor.  What sets Inkscape
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 575ce40ac8..5e8aedc63b 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -22524,3 +22524,30 @@ applications with variable CPU loads).")

 (define-public python2-parallel
   (package-with-python2 python-parallel))
+
+(define-public python-scour
+  (package
+    (name "python-scour")
+    (version "038.1")
+    (source
+      (origin
+        (method git-fetch)
+        (uri
+          (git-reference
+            (url "https://github.com/scour-project/scour.git")
+            (commit
+              (string-append "v" version))))
+        (sha256
+          (base32 "0rgiypb9ig8x4rl3hfzpy7kwnx1q3064nvlrv4fk0dnp84girn0v"))))
+    (propagated-inputs
+     `(("python-six" ,python-six)))
+    (build-system python-build-system)
+    (home-page "https://github.com/scour-project/scour")
+    (synopsis "Scour is an SVG optimizer/cleaner that reduces the size of
+scalable vector graphics by optimizing structure and removing unnecessary data
+written in Python.")
+    (description "The goal of Scour is to output a file that renderes
+identically at a fraction of the size by removing a lot of redundant
+information created by most SVG editors.  Optimization options are typically
+lossless but can be tweaked for more agressive cleaning.")
+    (license license:asl2.0)))
--
2.28.0




^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-10-21 17:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20 12:53 Inkscape export errors Ekaitz Zarraga
2020-10-20 16:34 ` Thorsten Wilms
2020-10-20 17:51   ` Ekaitz Zarraga
2020-10-21  7:35     ` Thorsten Wilms
2020-10-21 13:03 ` Ludovic Courtès
2020-10-21 13:56   ` Ekaitz Zarraga
2020-10-21 15:59     ` Ludovic Courtès
2020-10-21 17:17       ` Ekaitz Zarraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).