Bug 387433 - Scripter plugin requires Python 3.5
Summary: Scripter plugin requires Python 3.5
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (other bugs)
Version First Reported In: 4.0 pre-alpha
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-29 10:48 UTC by Brendan
Modified: 2017-12-05 21:51 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Update to python scripter plugin to allow it to run under python 3.4 (1.25 KB, patch)
2017-11-29 10:54 UTC, Brendan
Details
Update to debugger.py in python scripter plugin to allow use under Python versions prior to 3.5 (1.21 KB, patch)
2017-11-29 11:42 UTC, Brendan
Details
Update to debugger.py in python scripter plugin to allow use under Python versions prior to 3.5 (1.26 KB, patch)
2017-11-30 13:37 UTC, Brendan
Details
Update to debugger.py in python scripter plugin to allow use under Python versions prior to 3.5 (1.27 KB, patch)
2017-11-30 22:10 UTC, Brendan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brendan 2017-11-29 10:48:01 UTC
The scripter plugin requires Python 3.5 (uses async def/await). Python 3.5 is not backwards compatible with Python 3.4 and aborts the scipter plugin during krita startup on systems with earlier versions of Python 3. 

Python 3.5 is not available* for install on my distro (OpenSuSE Leap 42.3). This plugin can be modified to run on earlier versions of Python 3 by using @asyncio.coroutine/yield.  

File to change: 
inst/share/krita/pykrita/scripter/debugger_scripter/debugger.py
Diff:
>diff debugger.py debugger_new.py 
77c77,79
<     async def display(self):
---
> 
>     @asyncio.coroutine
>     def display(self):
82c84
<                 await asyncio.sleep(0.3)
---
>                 yield asyncio.sleep(0.3)
89,90c91,93
<     async def start(self):
<         await self.display()
---
>     @asyncio.coroutine
>     def start(self):
>         yield self.display()
92c95,96
<     async def step(self):
---
>     @asyncio.coroutine
>     def step(self):
94c98
<         await self.display()
---
>         yield self.display()
96c100,101
<     async def stop(self):
---
>     @asyncio.coroutine
>     def stop(self):
99c104
<         await self.display()
---
>         yield self.display()




* it can be installed, but it breaks a lot of other installed packages.
Comment 1 Halla Rempt 2017-11-29 10:49:25 UTC
Can you please attach the diff (in unified diff format) to the report so I can apply it and push?
Comment 2 Brendan 2017-11-29 10:54:09 UTC
Created attachment 109114 [details]
Update to python scripter plugin to allow it to run under python 3.4

Patch attached.
Comment 3 Halla Rempt 2017-11-29 10:58:03 UTC
Comment on attachment 109114 [details]
Update to python scripter plugin to allow it to run under python 3.4

Um... It doesn't apply?
Comment 4 Brendan 2017-11-29 11:14:59 UTC
(In reply to Boudewijn Rempt from comment #3)
> Comment on attachment 109114 [details]
> Update to python scripter plugin to allow it to run under python 3.4
> 
> Um... It doesn't apply?

My patchy grasp of patching?
My version is 4.0.0-pre-alpha (git dd1c4cb)
I have also run diff in a separate directory, do I need to run it from the inst directory and include the directory structure?
Comment 5 Brendan 2017-11-29 11:42:28 UTC
Created attachment 109115 [details]
Update to debugger.py in python scripter plugin to allow use under Python versions prior to 3.5

Don't know what the story is with the earlier patch - stray carriage return somewhere affecting the numbering?

~/krita/inst/share/krita/pykrita/scripter/debugger_scripter> diff -u debugger.py debugger_new.py > debugger_python3.4b.patch
~/krita/inst/share/krita/pykrita/scripter/debugger_scripter> cp debugger.py debugger_bak.py
~/krita/inst/share/krita/pykrita/scripter/debugger_scripter> patch < debugger_python3.4b.patch 
patching file debugger.py
~/krita/inst/share/krita/pykrita/scripter/debugger_scripter> diff debugger.py debugger_new.py 
~/krita/inst/share/krita/pykrita/scripter/debugger_scripter>

If this doesn't work, please point me to the phabricator (I can't find my way around it) for debugger.py and I'll diff against that.
Comment 6 Halla Rempt 2017-11-29 11:52:50 UTC
Tt would be easier to just change the original file and provide
the output of "git diff"
Comment 7 Brendan 2017-11-30 04:24:22 UTC
(In reply to Boudewijn Rempt from comment #6)
> Tt would be easier to just change the original file and provide
> the output of "git diff"

Can you give me the link to the right git repository? I can never find the 4.0 version.
Comment 8 Brendan 2017-11-30 13:37:08 UTC
Created attachment 109129 [details]
Update to debugger.py in python scripter plugin to allow use under Python versions prior to 3.5

I have downloaded krita 4.0.0 alpha 2 tarball and worked from it. There is an additional carriage return which has probably thrown off earlier patches.
Comment 9 Brendan 2017-11-30 22:10:15 UTC
Created attachment 109137 [details]
Update to debugger.py in python scripter plugin to allow use under Python versions prior to 3.5

yield causes errors, updated to use yield from
Comment 10 Halla Rempt 2017-12-01 10:25:06 UTC
The git source for Krita is here: https://phabricator.kde.org/source/krita/ :-) Sorry for the late reply, I've been sick for a couple of days.
Comment 11 wolthera 2017-12-04 20:10:41 UTC
Hey Brendan, I managed to apply your patch. :)

One thing though: next time don't rename files, the rename had gotten into the patch. :(

How would you like to be known in the commit message?
Comment 12 Brendan 2017-12-05 02:36:14 UTC
(In reply to wolthera from comment #11)
> Hey Brendan, I managed to apply your patch. :)


Woohoo! The most recent one, with yield from I hope.

> One thing though: next time don't rename files, the rename had gotten into
> the patch. :(

Sorry. I was working from a tarball bc I wasn't sure how phabricator worked/what fork had the most recent versions in it. 

There is another python 3.4 incompatibility in the way that scripter loads the scripts (using module_from_spec) bug report to be filed soon. I'm proposing to add a new file to deal with that rather than include compatibility code in runner.py 
 
> How would you like to be known in the commit message?

(In reply to wolthera from comment #11)
> Hey Brendan, I managed to apply your patch. :)
> 
> One thing though: next time don't rename files, the rename had gotten into
> the patch. :(
> 
> How would you like to be known in the commit message?
Comment 13 wolthera 2017-12-05 09:56:00 UTC
... So... How would you like to be known in the commit message?
Comment 14 wolthera 2017-12-05 21:51:54 UTC
Git commit b360e236011bffa0cc5032d49262a49ef2e073fc by Wolthera van Hövell tot Westerflier, on behalf of Brendan Scott.
Committed on 05/12/2017 at 21:51.
Pushed by woltherav into branch 'master'.
Related: bug 3, bug 5

Thanks Brendan Scott for the patch!

M  +12   -8    plugins/extensions/pykrita/plugin/plugins/scripter/debugger_scripter/debugger.py

https://commits.kde.org/krita/b360e236011bffa0cc5032d49262a49ef2e073fc