Inkscape + Python, version usage

Discussion about writing code for Inkscape.
User avatar
kstingel
Posts: 62
Joined: Fri Feb 12, 2016 3:27 pm

Inkscape + Python, version usage

Postby kstingel » Mon May 16, 2016 1:54 pm

Just wondering which version of Python (if any) Inkscape 0.91 (and future versions) is, or will be compiled to use by default in Windows

I am running Windows 10 Pro 64-bit and have Python locally installed (both 2.7.11 and 3.5.1), I ask the question because I would like to be able to test my scripting against the correct Python engine

When I checked my current (inkscape 0.91) install path, I see a copy of Python 2.7 - but that could be because it was the Python version active in my path

For any "missing" packages, do I just copy the folders/files from my global Python27/Lib/site-packages to Inkscape/python/lib/site-packages, or is there a place to tell Inkscape use my global Python version instead of the included version?

Off topic:
I also have an Ubuntu 16.4 system setup and running Inkscape, but I'm not as familiar with Ubuntu (yet)

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Inkscape + Python, version usage

Postby brynn » Mon May 16, 2016 4:37 pm

You shouldn't need to do anything. Inkscape installs whatever it needs.

What kind of scripting are you doing?

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Inkscape + Python, version usage

Postby Moini » Mon May 16, 2016 9:38 pm

Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
kstingel
Posts: 62
Joined: Fri Feb 12, 2016 3:27 pm

Re: Inkscape + Python, version usage

Postby kstingel » Wed May 18, 2016 9:26 am

@brynn: I have a few extensions in my global Python27 which I've used in my (current) Hex script, I was thinking I could just copy them across without the need to run pip install {blah} against Inkscape's Python

I'm trying to write a Grid Extension to create Hexagonal Rings on the fly... both flat hexes and pointy hexes
initially I'm only creating 48px Hexes, but I hope to make the Hex-width dynamic before I release to general use

I've found extensions that will create Hexagonal Grids with the Origin Hex at Top Left corner, but as yet I can't find one which will allow me to create Hex Rings, centered on the page/canvas

My general premise is to acquire the length of an edge, I realise I could do something similar with Star objects, but I specifically need the Hex to have 6 (tweakable) nodes, which (from what I see) A Star won't give me
using the edge length, calculate the height and width of the hex and create a single Hex to use as a master

:idea: A possible alternate method would be to just use an XYgrid and an Axonometric grid centered to the page and allow the user to extend the "map" according to the grid - but I haven't worked out how to create the grids dynamically yet

.... I'm also trying to test current Inkscape Python scripts against Python 3.5 so I can (try to) help future proof the Inkscape core :)
I have (automatic) tests within my IDE so that as soon as I open an existing Python script, it is tested against 2.7 and 3.5 so I can see where issues will arise, but since I'm only new to Python, I'm having to research the "fixes" to bring to code up to 3.5 compliance without breaking 2.7 compatibility

Off topic:
Ideally I would be better doing the tests in my Ubuntu box, but due to screen real estate it's easier to mock up in the Windows box (Ubuntu box has smaller screen) - plus my IDE is Windows only

User avatar
kstingel
Posts: 62
Joined: Fri Feb 12, 2016 3:27 pm

Re: Inkscape + Python, version usage

Postby kstingel » Wed May 18, 2016 9:41 am

Off topic:
On the debugging side ... I was able to resolve my Inkscape/Gimp error :) ... on Windows systems, ignore it as the extension isn't used

In Ubuntu-Inkscape it magically went away once I had both Gimp and Inkscape installed - so it's definitely a Windows issue which as yet I haven't been able to correct - and probably won't try to

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Inkscape + Python, version usage

Postby brynn » Wed May 18, 2016 12:58 pm

Oh ok. I didn't realize you're working on extensions. It seems Moini has given you the info you need, right?

User avatar
kstingel
Posts: 62
Joined: Fri Feb 12, 2016 3:27 pm

Re: Inkscape + Python, version usage

Postby kstingel » Sat Aug 13, 2016 7:54 pm

Have been away due to injury (somewhat better now)

Latest Python versions (as of 2016-08-13) are 2.7.12 and 3.5.2 respectively, latest Python within Inkscape still appears to be 2.7.x
presumably for compatibility reasons

For development, I have opted to go with creating virtual environments ... Ink27, Ink3 and InkBoth being for cp27, cp3x, and py2py3 respectively

I'm hoping, the use of virtual encapsulation will allow me to find (and possibly fix) any regressions during porting Inkscape from a Py27 base to a Py3 base

For any extensions I publish for general use, I will document which Python they have been written/tested against, so hopefully any developers using them will know where regressions may occur

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Inkscape + Python, version usage

Postby Moini » Sun Aug 14, 2016 12:28 am

Cool :) What do you mean by 'porting Inkscape from a Py27 base to a Py3 base'? It sounds a bit as if you plan to port the extensions that come with it and to update the compiling process / dependency list for Windows/Linux... But that's a lot of work, and will best be done in coordination with the Inkscape devs - so did I misunderstand?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
kstingel
Posts: 62
Joined: Fri Feb 12, 2016 3:27 pm

Re: Inkscape + Python, version usage

Postby kstingel » Sun Aug 14, 2016 2:42 am

Not planning to rewrite anything as such, but playing with future proofing the extensions I use ...
mainly by adding the "from __future__ import {package} and then reporting back what breaks :)
... I'm not advanced enough to do more than that yet

One thing I just noticed ... having just performed a clean install of Inkscape 0.91, the shipped Python version is Python 2.6.6

Should I run that version of Python (in addition to my others) or will 2.7.x be OK?

I have no problem installing the older version, as I would only be creating virtual environments against it, not actually using it in any production sense

User avatar
kstingel
Posts: 62
Joined: Fri Feb 12, 2016 3:27 pm

Re: Inkscape + Python, version usage

Postby kstingel » Sun Aug 14, 2016 2:44 am

To perform my clean install of Inkscape, I used the x64 package, just in case that makes a difference

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Inkscape + Python, version usage

Postby Moini » Sun Aug 14, 2016 11:51 am

I like the 'yet' :)

All I can say is that in the dependencies listing for the Linux Inkscape deb package I'm using, it says:
python:any (>= 2.7.1-0ubuntu2)
and that I've installed python 2.7.6 currently (and it works).

Also that the development libraries for Windows 64bit seem to have been updated to python 2.7.11 (for the next version):
http://bazaar.launchpad.net/~inkscape.d ... d:/python/

I don't know enough about the 2.x series differences to give useful advice, sorry.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

DedeBarre
Posts: 1
Joined: Wed Oct 05, 2016 3:43 am

Re: Inkscape + Python, version usage

Postby DedeBarre » Thu Oct 06, 2016 3:20 am

Hi...as per my knowledge Everything seems to work as expect Uniconvertor. The problem is that the package includes modules built with Python 2.6 that need to be recompiled with Python 2.7. And of course SK1 doesn't provide packages for recent Python versions.Uniconvertor is only used in a very limited number of cases, and maybe we could just drop it.

turn-key pcb


Return to “Programming”