Extensions check for Python dependencies

Bug #174992 reported by Diti Torterat
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Triaged
Wishlist
Unassigned

Bug Description

I'm testing the 0.46.0-svn+16641 version of Inkscape because the perspective tool didn't work. On this version, after I had installed the “python-lxml” (see bug #169095) and “numpy” packages (see bug #169802), I got this error message :

 Traceback (most recent call last):
  File "/usr/share/inkscape/extensions/perspective.py", line 127, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 153, in affect
    self.effect()
  File "/usr/share/inkscape/extensions/perspective.py", line 80, in effect
    solmatrix[i][0] = sp[i][0]
UnboundLocalError: local variable 'sp' referenced before assignment

And the perspective extension does nothing.
I hope my bug will help the developpers. Thanks.

Revision history for this message
hash (hash-g) wrote :

In Inkscape0712071739.7z win32 build this script still wants phyton24.

Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Diti Torterat (diti) wrote :

I'm using Ubuntu Linux 8.04 (Alpha version). I thought, as I have the 2 versions installed, that Inkscape would choose the best version to work (here, 2.4).
Can I help?

Revision history for this message
prkos (prkos) wrote :

After installing numpy it works fine on fedora 7.

But on WinXP I get this:

Traceback (most recent call last):
  File "share\extensions\perspective.py", line 127, in <module>
    e.affect()
  File "C:\Program Files\Inkscape\share\extensions\inkex.py", line 153, in affect
    self.effect()
  File "share\extensions\perspective.py", line 72, in effect
    q[query] = float(f.read())
ValueError: empty string for float()

Changed in inkscape:
milestone: none → 0.46
Revision history for this message
Bryce Harrington (bryce) wrote : Re: perspective.py requires dependency on python-numpy - causes UnboundLocalError

Ubuntu already lists python-numpy as a Recommends (same as is done for python-xml, as per bug 115589. I assume other Linux distros will also update their depends accordingly if they've not already.

The Windows packages will need to be updated to also include this, if they don't already. I'll subscribe Ishmal for that.

Someone should test on OSX as well.

Ultimately, a much better solution than brute forcing this at the package layer, would be for the Inkscape extension warning/error dialogs to tell the user to install the requisite dependencies in order to make it work. Perhaps the inkex file format needs to be modified to include some sort of dependency checking functionality? Ted, what do you think?

Changed in inkscape:
assignee: nobody → ted-gould
Revision history for this message
Bryce Harrington (bryce) wrote :

Fwiw, on Ubuntu python-numpy, et al cannot be included as a Depends since Inkscape is in main, but that package isn't.

Revision history for this message
JiHO (jiho) wrote : Re: [Bug 174992] Re: perspective.py requires dependency on python-numpy - causes UnboundLocalError

On 2008-January-07 , at 02:00 , Bryce Harrington wrote:
> Someone should test on OSX as well.

It is now possible to include python packages (numpy and lxml)
directly in the application bundle on OS X. The results is that people
just drag and drop Inkscape on their machines and everything just
works. The side effect is that Inkscape weights nearly 140Mb now
(instead of 80 before).

JiHO

Revision history for this message
Tom Davidson (tjd-mit) wrote : Re: perspective.py requires dependency on python-numpy - causes UnboundLocalError

At bug 186582, Mourad finds that he gets this error (the one in the original report) only when he tries to apply the extension to an object without first converting it to a path. So maybe that's the problem?

Revision history for this message
Mourad Mokrane (momo-lumenstudio) wrote :

bug #186592 is also related as it is caused by the same limitation, except that the problem occurs with another extention.

Revision history for this message
prkos (prkos) wrote :

I always convert objects to paths before applying Perspective or Envelope so it can't be that. Im still getting ValueError: empty string for float() on WinXP, 29th Jan build.

Traceback (most recent call last):
  File "share\extensions\perspective.py", line 127, in <module>
    e.affect()
  File "C:\Program Files\Inkscape\share\extensions\inkex.py", line 154, in affect
    self.effect()
  File "share\extensions\perspective.py", line 72, in effect
    q[query] = float(f.read())
ValueError: empty string for float()

Diti Torterat (diti)
description: updated
Revision history for this message
Tom Davidson (tjd-mit) wrote :

@prkos: That's true, but you're getiing a different error message than Dmitri and Mourad are. I think you are seeing a different bug...

In fact there are several different issues in this bug report, the first two of which I think should be broken out:

1- The original 'UnboundLocalError: local variable 'sp' referenced before assignment' error that Dmitri reported. I believe Mourad correctly identified this as being due to not converting to paths before running the extension, which is discussed at bug 186582 . Note that the bug title as it stands is wrong: Dmitri only saw this error *after* he installed numpy. A missing numpy is not what causes the error.

2- The 'ValueError: empty string for float' error in the envelope and perspective extensions that prkos sees. This is extensively discussed at bug 176750

3- The delivery of the numpy libraries on various platforms. This seems like what the subject of this bug has evolved into, so I'll update the title. There is also some useful discussion at a couple other bugs:
   - delivery of the lxml libraries on Win32: bug 178022
   - discussion of extensions checking for the existence of numpy/other deps at run time is at bug: 168843 (closed, but some useful comments from Aaron)

Revision history for this message
Ted Gould (ted) wrote : Re: perspective.py requires dependency on python-numpy

I'm marking this as wishlist. With the wishlist item being to have extensions check for specific python libraries as part of the dependencies. It seems (through the comments) that all of the other angles (win32 packaging, etc.) of this bug are handled through other bugs.

Changed in inkscape:
importance: Medium → Wishlist
milestone: 0.46 → none
Revision history for this message
KevinM (kevbert1) wrote :

I'm using Inkscape 0.45.1 on Ubuntu 7.10 X64. I've installed python-numpy and python-lxml, so that I can use the Perspective tool. Depending on what object I use I get different warning Messages. For text I get
** (inkscape:17486): WARNING **: Format autodetect failed. The file is being opened as SVG.
** (inkscape:17488): WARNING **: Format autodetect failed. The file is being opened as SVG.
** (inkscape:17490): WARNING **: Format autodetect failed. The file is being opened as SVG.
** (inkscape:17494): WARNING **: Format autodetect failed. The file is being opened as SVG.
For a rectangle I get
** (inkscape:17782): WARNING **: Format autodetect failed. The file is being opened as SVG.
** (inkscape:17784): WARNING **: Format autodetect failed. The file is being opened as SVG.
** (inkscape:17786): WARNING **: Format autodetect failed. The file is being opened as SVG.
** (inkscape:17788): WARNING **: Format autodetect failed. The file is being opened as SVG.
Even though these messages are displayed the perspective view is correct.

Revision history for this message
Ted Gould (ted) wrote : Re: [Bug 174992] Re: perspective.py requires dependency on python-numpy

On Sat, 2008-03-08 at 20:50 +0000, KevinM wrote:
> I'm using Inkscape 0.45.1 on Ubuntu 7.10 X64. I've installed python-numpy and python-lxml, so that I can use the Perspective tool. Depending on what object I use I get different warning Messages. For text I get
> ** (inkscape:17486): WARNING **: Format autodetect failed. The file is being opened as SVG.
> ** (inkscape:17488): WARNING **: Format autodetect failed. The file is being opened as SVG.
> ** (inkscape:17490): WARNING **: Format autodetect failed. The file is being opened as SVG.
> ** (inkscape:17494): WARNING **: Format autodetect failed. The file is being opened as SVG.
> For a rectangle I get
> ** (inkscape:17782): WARNING **: Format autodetect failed. The file is being opened as SVG.
> ** (inkscape:17784): WARNING **: Format autodetect failed. The file is being opened as SVG.
> ** (inkscape:17786): WARNING **: Format autodetect failed. The file is being opened as SVG.
> ** (inkscape:17788): WARNING **: Format autodetect failed. The file is being opened as SVG.
> Even though these messages are displayed the perspective view is correct.

Yes, these errors are caused by GLib making the temporary file
incorrectly. It makes it so that the .svg is not at the end.
Unfortunately it is only fixed in the newer versions of Glib.

Revision history for this message
MarceloSilva (celobox) wrote : Re: perspective.py requires dependency on python-numpy

On Ubuntu GUTSY perspective donts works, needs python-numpy but after installed dont woks too

Revision history for this message
Rena Kunisaki (i-am-inuyasha) wrote :

Yep, still same error with that package installed.

su_v (suv-lp)
tags: added: extensions-plugins packaging
Revision history for this message
Alvin Penner (apenner) wrote :

@HyperHacker or MarceloSilva:
- could you attach the error message you are getting?
- also, could you attach the .svg file you are using?

Revision history for this message
Alvin Penner (apenner) wrote :

could someone confirm that this problem still exists, with sample files?

Changed in inkscape:
status: Confirmed → Incomplete
Revision history for this message
su_v (suv-lp) wrote :

Reverting bug status to 'Confirmed' based on comment #11:
«I'm marking this as wishlist. With the wishlist item being to have extensions check for specific python libraries as part of the dependencies. It seems (through the comments) that all of the other angles (win32 packaging, etc.) of this bug are handled through other bugs.»

AFAIK this is not yet supported by the extension system.

Related discussion with useful comments in
Bug #168843 (sf1777739) “Modify path->perspective is broken”

Changed in inkscape:
status: Incomplete → Confirmed
Ted Gould (ted)
Changed in inkscape:
assignee: Ted Gould (ted) → nobody
jazzynico (jazzynico)
summary: - perspective.py requires dependency on python-numpy
+ Extensions check for Python dependencies
Changed in inkscape:
status: Confirmed → Triaged
tags: removed: packaging
Revision history for this message
jazzynico (jazzynico) wrote :

Closely related: Bug #479944 "Extensions check for Perl dependencies"
<https://bugs.launchpad.net/inkscape/+bug/479944 >

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.