Extention engine doesn't use updated scripts?

Bug #517870 reported by Marvin86
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Undecided
Unassigned

Bug Description

Hi there,

it seems to me that Inkscape's extension system doesn't really care about updates I make in my python extension scripts.

I have successfully managed to get an Inkscape Pyhton script extention launched on Inkscape (created the INX file and so on).

It's no problem Inkscape finds my extention script called <mapmaker.py> (I put it in the share/extensions directory).

I was trying to do some debugging, because Inkscape gives me the following error message on the script:

Traceback (most recent call last):

  File "C:\Program Files\Inkscape\share\extensions\mapmaker.py", line 7, in <module>

    runmapmaker()

NameError: name 'runmapmaker' is not defined

To test whether Inkscape really got the proper script version, I edited my <mapmaker.py> script located at <C:\Program Files\Inkscape\share\extensions\> by removing the line that calls "runmapmaker()". I also intentionally added some random function names that don't exist, like "wakarata()" or something, and some imports like "import nonsense". There's definately no "runmapmaker()" call in my script now, but still Inkscape thinks there is. Inkscape keeps giving me the exact same error message you see up there, over and over again, no matter what I change, add or remove in the script! It's like Inkscape doesn't really look at my new version of the script at all and pretends like it only knows some old version of it!

Does Inkscape keep some cache memory somewhere to fetch previously used Python scripts from? I don't know how else to explain this, it just doesn't make any sense at all, this is running me crazy!

Thanks in advance

Marvin

Revision history for this message
Marvin86 (marvin-offiah) wrote :

I have now completely erased every single line in <mapmaker.py>, so the script is now completely blank!

But still, Inkscape launches it and thinks there's some line in it saying "runmapmaker()". This is crazy! Either Inkscape is keeping some hidden version of my script somewhere and refuses to look at the true script location or it has somehow conspired to fool me forever! It's unfeasable to me how Inkscape can produce information that doesn't even exist anymore!

I've done everything, run a file search on the Inkscape root directory, tried to search for "mapmaker.py", relaunched Inkscape...
...I hope you're not going to tell me I need to reboot my PC after every debugging step for my script?

Thanks
Marvin

su_v (suv-lp)
tags: added: extensions-plugins
Revision history for this message
Marvin86 (marvin-offiah) wrote :

Hmm...no idea? Nobody could reproduce the problem?

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

could you attach the .inx and .py files you are using?

Revision history for this message
su_v (suv-lp) wrote :

> Hmm...no idea? Nobody could reproduce the problem?
hey, it's just 12 hours ago that you reported your issue!

Could you attach both the inx file and the original python script you used? And provide information about your Inkscape and OS version?
Did you by chance install an earlier version of your extension in the user extensions folder? Any duplicate files therein override files with the same name in 'share/extensions'. AFAIK the inkscape user profile folder on win32 platforms is in %APPDATA%\Inkscape

I have not seen this issue with extensions I modified locally (Inkscape 0.47, 0.47+devel on OS X 10.5.8 testing extensions with Python 2.5.1 and 2.6.x) - neither when stored in 'share/extensions' nor when saved in the user extensions folder in '~/.config/inkscape/extensions'. The changes in python scripts (*not* those in inx files which are read only once when Inkscape launches) are picked up without relaunching Inkscape. IIUC a new python process is created each time you call an extension by its entry in 'Extensions' menu or when using it as an input or output extension.

Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :

mapmaker.py and mapmaker.inx are both located in the extensions folder.

There is also a folder called "mapmaker_" within the extensions folder that contains the "__init__.py" and "mapmake.py".

I would have loved to make things less complicated by putting EVERY file related to my extension into the "mapmaker_" folder and calling it "mapmaker" instead of "mapmaker_", but unfortunately Inkscape doesn't understand it when I try to enter a relative path of "extensions\mapmaker" into the INX file.

I'd hate putting all the files into the extensions folder, because they're gonna be many later, and I want to substructure them into folders when the time comes.

Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :

I don't know what's wrong here. I've been posting the __init__.py two times now, but it seems always the wrong content gets postet.

My own __init__.py contains one line only:

import mapmake

so ignore the wrong contents of the __init__.py I posted here, I don't know why your interface keeps uploading another file all the time.

Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :
Revision history for this message
Marvin86 (marvin-offiah) wrote :

Hmm...not matter what I do: Whether I try to upload editor.py or __init__.py, it always uploads __init__.py. Sorry.

Revision history for this message
Marvin86 (marvin-offiah) wrote :

Sorry, I mean it always uploads the contents of editor.py.

Revision history for this message
Marvin86 (marvin-offiah) wrote :

editor.py is also located in the "mapmaker_" folder btw.

Don't worry about the PyQt4 thing...I've already swapped Inkscape's "python" directory with one that contains pyhton31, so I can use the most current version of PyQt, which is PyQt4. PyQt4 doesn't run on python2x. Ultimately, if I publish my extension, I'll have to write some installer that updates Inkscape's python to 3.11. Or is there a way to configure python to use a different python directory?

Your binding-mechanism seems to be different from what I read about Blender. Your python interpreter is not integrated into the Inkscape.exe, since your python interpreter exists in a standalone folder, while Blender integrates some python.dll into the EXE.

This makes me wonder how the access to the SVG content of the currently opened document acutally works. When launching an extension, am I only getting access to a snapshot version of the SVG content provided in some temp directory accessed by inkex.py, or am I getting the real SVG. I'd like my extension just to open some PyQt window, so editing on canvas can continue parallel to configuring things on the PyQt window.

Revision history for this message
Marvin86 (marvin-offiah) wrote :

...and the SVG I'm accessing should then always be the one managed by Inkscape:

Like I'm editing something on canvas, selecting some objects, then configuring something on the PyQt window to affect the SVG, then again maybe use Inkscape's editing functionalities again...
Do your bindings somehow allow accessing the currently selected item on canvas, not only the one selected before extension launch?

Revision history for this message
Marvin86 (marvin-offiah) wrote :

You know, basically I'm just trying to write another toolbox that can be integrated into Inkscape, just like the Fill-And-Stroke-Box. Only I want to write it in Python, using PyQt, as to avoid dealing with the complicated and undocumented Inkscape source code.

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

    if you are using subdirectories, then it may be worthwhile to use the same methods used by extensions such as 'render barcode' and 'alphabet soup', which also use subdirectories. These extensions do not explicitly refer to the subdirectories in the inx file, but declare the dependencies in the Python file.
    also, just to be safe, it may be worthwhile to delete all new .pyc files to force them to be regenerated.

Revision history for this message
su_v (suv-lp) wrote :

not reproduced with Inkscape 0.47 on OS X 10.5.8

whenever I make changes to one of the scripts
 mapmaker.py
 mapmaker_/__init__.py
 mapmaker_/mapmake.py
 mapmaker_/editor.py
they are immediately reflected in the next error messages Inkscape shows returned from the python script - without the need to restart Inkscape or - as you hinted - even rebooting the whole system. I suggest there's something else going on with your system - as indicated by your troubles to upload the correct files as intended.

Revision history for this message
Marvin86 (marvin-offiah) wrote :

Hey, thanks for helping! ;-)

@Alvin
Right, as I described, that's exactly what I'm doing, since I couldn't get it working any other way. I put just the launch file into extensions and describe the dependencies there, everything else is in a subdirectory called mapmaker_

@~suv
Hmm...that's strange...I'll try some other things like deleting and recreating the file maybe...

BTW, could anybody comment on my remarks on Inkscape's binding mechanism? I'd like to know whether the SVG-object accessed through Pyhton is live or just a snapshot. I would be great if it was live, because then I could just ask my extension to create a PyQt window, let Inkscape think the extension has finished executing with the window still on, and continue some SVG editing via my own tool window in along to some extra Inkscape-internal edits.

Revision history for this message
Marvin86 (marvin-offiah) wrote :

Hey, seem to have gotten rid of my problem now:

Actually always wondered why I was able to edit the mapmaker.py file in Inkscape's extension directory with my python editor (PyhtonWin) as a standard user all the time, while it ought to be impossible since that directory was only supposed to be editable by the admin.
Somehow I have been able to edit the mapmaker.py in spite of that all the time as a standard user by opening it with PythonWin and starting to edit it, PythonWin never complained about me not being allowed to write changes to the file this way, but obviously Vista itself must have been quietly ignoring my edits to the file system anyway and appears to have been presenting me with some "pseudo" edited file all the time that only exists on display level in that directory, but is stored elsewhere while maintaining the original admin-generated file in place.

Revision history for this message
Marvin86 (marvin-offiah) wrote :

So bottom line: Don't start editing Admin-owned Pyhton files with PythonWin as a standard user, even if PythonWin makes you believe it's allowed to do so!

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

1. the svg that you get access to when you write a Python extension is a snapshot, which gets refreshed every time you click on the 'Apply' button.

2. if you are on Vista, then you have my deepest sympathy. What Vista will sometimes do, if you do not have the authority to execute the command, is store the results of the command in a well-hidden directory somewhere under your user name. You will be able to find it if you search for the filename. So then you will have two different versions of the results of the same command, depending on how you executed it, as an admin or not.

3. In any event, since this is not an Inkscape issue, and if there is no objection, I'll mark this as invalid so it gets taken off the list of things to fix.

Changed in inkscape:
status: New → Invalid
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.