pyp5js icon indicating copy to clipboard operation
pyp5js copied to clipboard

Tool to convert Python Mode .pyde code for use with pyp5js

Open villares opened this issue 6 years ago • 5 comments

This is a proof of concept, running inside Processing IDE, that converts simple 'single tab' code for use with pyp5js: https://gist.github.com/villares/1b14997beef52de34069b91752faef40

@berinhard suggested some CL ideas: $ pyp5js from_processing /path/to/sketch.pyde or $ pyp5js from_processing /path/to/sketch.pyde -s my_new_sketch (the last one would update a sketch with the converted code)

villares avatar May 27 '19 12:05 villares

@villares I was thinking if, by doing that, we're not giving ourselves some problems in the future... I'm basing my thought on your experience with you recent port from Pyprocessing to pyp5js.

You had some issues with how Py2 handles numbers division differently from Py3, since py2 returns an integer while py3 returns a float as explained by the following snippet:

[bernardo@macalandia ~]$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
>>> type(3 / 3)
<class 'float'>

[bernardo@macalandia ~]$ python2
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
>>> type(2 / 2)
<type 'int'>

And this is just one of the many differences between the python versions...

So, I think we have to assume that there could be other errors from this same nature when porting sketches and we have to take under consideration that, maybe, the people porting them aren't that familiar with such Python's versions details. Given that, I think it's very possible and reasonable for them to open issues on pyp5js that aren't related with the lib, but with the change on the python version.

Speaking as the project maintainer, this could be a little bit overwhelming for me if it really happens. So, I'll put that on hold for now until we have more port examples and until we can confirm that these issues with the version update are indeed happening.

berinhard avatar May 28 '19 11:05 berinhard

Well, ok...

Or implement as an undocumented feature ;)

And make it print a BIG warning: EXPERIMENTAL! You are converting incompatible Python 2 code. DO NOT EXPECT THIS TO WORK

On Tue, 28 May 2019, 08:55 Bernardo Fontes, [email protected] wrote:

@villares https://github.com/villares I was thinking if, by doing that, we're not giving ourselves some problems in the future... I'm basing my thought on your experience with you recent port https://twitter.com/villares/status/1133164823632580608 from Pyprocessing to pyp5js.

You had some issues with how Py2 handles numbers division differently from Py3, since py2 returns an integer while py3 returns a float as explained by the following snippet:

[bernardo@macalandia ~]$ python3 Python 3.6.7 (default, Oct 22 2018, 11:32:17)

type(3 / 3) <class 'float'>

[bernardo@macalandia ~]$ python2 Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)

type(2 / 2) <type 'int'>

And this is just one of the many differences between the python versions...

So, I think we have to assume that there could be other errors from this same nature when porting sketches and we have to take under consideration that, maybe, the people porting them aren't that familiar with such Python's versions details. Given that, I think it's very possible and reasonable for them to open issues on pyp5js that aren't related with the lib, but with the change on the python version.

Speaking as the project maintainer, this could be a little bit overwhelming for me if it really happens. So, I'll put that on hold for now until we have more port examples and until we can confirm that these issues with the version update are indeed happening.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/berinhard/pyp5js/issues/45?email_source=notifications&email_token=AA4GADCBGWFUNCP2VBS5AZLPXUMUDA5CNFSM4HP3SZX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWL4IQA#issuecomment-496485440, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4GADBDGXXLUDM6LL3YJZLPXUMUDANCNFSM4HP3SZXQ .

villares avatar May 28 '19 12:05 villares

@villares I had a few second thoughts on that! Now I really agree with this tool as a somehing to bring more people to use and to try pyp5js by just "translating" theirs pyde files. Sorry for not being that open in the first time.

Anyway, what do you think about this one? What do you think about something like:

$ pyp5js convert_pyde /home/bernardo/sketchbooks/sketch/sketch.pyde

berinhard avatar Sep 15 '19 22:09 berinhard

Hey, if you could provide me an entry point where my converter should run...

Or maybe, better, If I implement an independent convert_pyde.py you can validate and couch me on best practices?

villares avatar Oct 30 '19 02:10 villares

Sure! Feel free to implement a convert_pyde.py script. Maybe you can add it to the pyp5js/pre_compile/ dir and open a PR so we can discuss on the top of it.

berinhard avatar Oct 30 '19 20:10 berinhard