Agreed. It would be great if extensions work with both Python 2 and 3. As for
existing scripts, we could use 2to3 to make them compatible. But I think the
best way to maintain extensions is leaving them to extension developers. Hope
an extension center could be set up in the near future.

Regards,
Minglangjun

On Fri, Mar 10, 2017 at 11:11 AM, Windell H. Oskay <windell@...3474...> wrote:
I have made minor modifications to several of the supported python extension files for compatibility with Python 3. These modifications allow them to continue working in python 2.x, and do not add dependencies. I am not sure if this is duplicating existing work, but I thought it might be best to discuss it here just in case.

The changed files are:
inkex.py
bezmisc.py
cspsubdiv.py
simplepath.py
simplestyle.py
simpletransform.py

These patches are based on files from 0.92, and which are unchanged in current bzr.
I have posted the files here, since I am not an approved Inkscape developer: http://evilmadscientist.com/source/extensionfiles-py2-3.zip (18 kB)

(In addition to these, I would note that ffgeom.py and cubicsuperpath.py work in both Python 2 and 3 without changes. I have not tested other extension files for compatibility.)

These changes appear to be non-breaking within Inkscape, as tested via invoking extensions that depend upon these, including flatten, Voronoi pattern (generate from path), and alphabetsoup. I have tested back to Python 2.6 under Inkscape 0.91, and up to Python 3.6 on the command line. While this is neither a formal test procedure nor exhaustive, I have not observed issues or errors due to these changes. If there are formal tests that could identify other issues, I would certainly welcome learning about them.

One coding note that I have is that the function definitions in bezmisc.py required "manually" unpacking the named tuples on their inputs, which adds one line of code to each function. Someone more expert at python may know of a more elegant approach.

I would assert that making the extension environment compatible with Python 3 is a worthwhile goal, even if we are quite some ways away from making Python 3 compatibility a requirement. This particular set of changes potentially allows certain Inkscape extensions to be run from the command line without opening the Inkscape GUI (not otherwise possible for verbs) on systems running either Python 2 or 3 as default.

Thank you all,
-Windell


Windell H. Oskay, Ph.D.
Co-Founder and Chief Scientist
Evil Mad Scientist Laboratories
175 San Lazaro Ave, STE 150
Sunnyvale CA 94086
http://www.evilmadscientist.com/



Windell H. Oskay, Ph.D.
Co-Founder and Chief Scientist
Evil Mad Scientist Laboratories
175 San Lazaro Ave, STE 150
Sunnyvale CA 94086
http://www.evilmadscientist.com/


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Inkscape-devel mailing list
Inkscape-devel@...1656...784...sourceforge.net
https://lists.sourceforge.net/lists/listinfo/inkscape-devel