python2 is EOL this year. (1 Jan 2020) I’ve been looking at some of the python2 code on my emonpi and porting it to python3. It’s pretty simple stuff: put parentheses around print calls, don’t mix tabs and spaces, use new library names, etc.
I’ve put my changes on github. I would really appreciate if someone could test them:
If nobody objects I will make a pull request next week.
At the moment I only want to publish my LCD script changes. I have changes to the other bits in the pipeline nearly ready for public consumption but my time is limited!
Please be gentle.
Thanks @bwduncan for the offer, yes happy to receive a pull request, it may take us a while to merge (it will probably make sense to consider as part of a future image release) but would certainly be useful to understand more about what is involved.
Did anything more happen with regard to porting emon* to python3?
Hi @djh good timing, I’ve just come back to look at this. I think it’s possible to make it run on 2 and 3 simultaneously, then drop 2 support later on, without the code ending up too ugly. Hopefully I’ll be publishing my commits in the next week. Bruce
Thanks for the fast response, Bruce. Good to hear you’re on the case. FWIW, the clock at https://pythonclock.org/ now shows only 25 days support left for python2.
My understanding is that most distros will remove support for python2 on that date, including removing python2 apps from the repositories, so updating any system that hasn’t been converted to python3 after that date will be a game of chance. I expect you know this already but maybe some others aren’t aware.
I’ve done a bit of digging as I think this cliff edge is unlikely.
AIUI (e.g. https://bdmpublications.com/debian-ubuntu-remove-python-2-packages/), it will not be included in future releases, not that it will be removed from current releases.
So no, I do not expect a cliff edge of the packages being deleted from existing installations.
BUT, if you have something that says definitively they will remove the python 2 packages from existing repositories, I’d like to see it . I’ve got a little python script running on a Jessie device that I really just want to leave alone (no security issues).
I was going to ask the same question:
Apparently (As I am not a s/w person) there is a migration program that converts the code & alerts code that requires changes.
I am particularly interested in the EmonESP code.
Also wish to thank all the developers for their hard work.
Everyone have a Happy New Year!
…From Sunny & unfortunately Burning Australia.
The issue is, that program is really not that good.
I’ve been running the beta emonhub here for a number of weeks now with no discernable issues. Hopefully in the new year we can migrate it and persuade @bwduncan to have a look at the other bits of Python in the code base.
That isn’t Python (AFAIK).
Yeah 2to3 is a good place to start but it misses a lot of the nuance, for example the change from bytes to UTF-8, lazy iterators. Without a test suite (which is difficult for a project so focussed on the real world, not judging) it’s really difficult to be confident about the migration. @borpin has been very helpful with testing, but we do have a wide selection of hardware out there.