Author Topic: Porting pypinproc to support Python 3?  (Read 1140 times)

Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Porting pypinproc to support Python 3?
« on: December 16, 2015, 11:44:09 AM »
Hi Everyone,

We're getting ready to move the Mission Pinball Framework to Python 3. As part of that, we need to make some changes to pypinproc so that it will support Python 3 as well.

The good news is that an updated version of pypinproc will support both Python 2.x and 3.x, so it can be universal. Updating it seems pretty straightforward. (http://py3c.readthedocs.org/en/latest/guide-porting.html)

I'm posting here to ask whether anyone as done this yet, just to make sure we're not duplicating any effort. :)

If not, no prob. We'll do it and then it will be available if anyone else happens to want it.

Thanks!
Brian
Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

Steven

  • Wizard
  • *****
  • Posts: 467
    • View Profile
Re: Porting pypinproc to support Python 3?
« Reply #1 on: December 16, 2015, 12:06:01 PM »
Sound like a good plan to me  :)

Gerry Stellenberg

  • Administrator
  • *****
  • Posts: 2397
    • View Profile
    • PinballControllers.com
Re: Porting pypinproc to support Python 3?
« Reply #2 on: December 16, 2015, 12:28:48 PM »
Hi Brian,

I'm curious to know why you're moving the Python 3.  Are there particular features you need that 2.7 doesn't have?

Also, if you're going to jump into pypinproc, can I ask you to implement a pinproc_read_data function to allow pypinproc and python frameworks to call libpinproc's existing PRReadData function?  It should be pretty straightforward, but I can help you through any challenges as they arise.

- Gerry

Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Re: Porting pypinproc to support Python 3?
« Reply #3 on: December 16, 2015, 12:54:47 PM »
As to why Python 3, we don't have any single hard core reason that's any different than any of the millions of "Why Python 3" blog posts that are out there. Really just because Python 2 is done (apart from bug fixes and security fixes) and Python 3 is where the focus of the Python core developers is. So far the main reason people have for *not* going to Python 3 is that they have external libraries that don't support 3 yet (though Python 3 has been around for 8 years so really by now most stuff has been updated). In our case, we don't have any libraries that don't support Python 3 (except for pypinproc which we can update).

There are a million little reasons why 3 is nicer. The proper unicode support is getting to be a bigger thing for us as people start to use MPF in non-ASCII locales. The better exception handling is what I'm personally most excited about, and the proper coroutine implementation will be nice since we use a generator for that now.

Also the 2-to-3 migration tools are great and do pretty much everything we need. From a coding standing, 2 and 3 are similar enough that this is not a big effort.

All that said, the BIG reason for us is simple:

Previously we used Pygame as our multimedia library, but now we're moving to Kivy. (A bunch of reasons for that, but that's a different story.) Also we're changing out our YAML library from PyYAML to ruamel.yaml (a bunch of reasons for that too. :) .. so for the next release of MPF, we won't require Pygame and PyYAML and instead we'll require Kivy and ruamel.yaml, so MPF users will be making some supporting changes to their installs anyway.

So based on that, we decided it's sort of a "rip the band aid" kind of thing. Especially since MPF is still new (not on v1 yet) with with relatively few users. Based on the published roadmaps from the Python foundation, we know we'll have to move to Python 3 at some point, and since the move is easy and there's nothing stopping us now, we figured we'd just do it now while we're making these other foundation changes and just get it over with.

As for implementing the pinproc_read_data function, sure thing! The guy doing the updates to pypinproc (@Q-Dog in our forums) is an actual C developer, so I assume that will be simple for him, but I'll get you two in touch if he has any questions.
Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

jab

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Porting pypinproc to support Python 3?
« Reply #4 on: February 02, 2016, 07:18:05 AM »
Btw: If anybody is still interested: We implemented the pinproc_read_data and use it for I2C in MPF (so its actually working).


Jan

Gerry Stellenberg

  • Administrator
  • *****
  • Posts: 2397
    • View Profile
    • PinballControllers.com
Re: Porting pypinproc to support Python 3?
« Reply #5 on: February 02, 2016, 01:52:05 PM »
Thanks Jan,

That's a nice addition.  I'll see about getting it in the main pypinproc repo.

- Gerry