Time to upgrade Kodi to Python 3.x interpreter version such as Python 3.3?
#16
(2016-12-14, 00:40)ronie Wrote: well, it's not like they're gonna keep 2.7 on life support forever.
addon breakage will have to happen sooner or later.
i doubt it's going to hurt any less if we postpone the switch for another four years.

I understand... speaking in the short term python +3 doesn't bring any benefits that outway the work needed to upgrade.

Python +3 is filled with micro changes, a lot of commonly used functions are deprecated. Off the top of my head one you like to use @ronie "has_key" was removed in favor of "in".
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Twitter | Help?
Reply
#17
moving to python3 and adding addon signing would get rid of most pirate addon box sellers, would be huge benefit for Kodi.
Reply
#18
what has addon signing to do with python3?
Reply
#19
addon breakage is minor compared to the fact that python3 has largely changed the way you do cpython modules. it would be an involved rewrite. every project (3-4) at work where i have had to do this, i have gone through the pain of switching to ctypes type bindings because of issues in the new cpython stuff.
Reply
#20
(2016-12-14, 01:10)Lunatixz Wrote:
(2016-12-14, 00:40)ronie Wrote: well, it's not like they're gonna keep 2.7 on life support forever.
addon breakage will have to happen sooner or later.
i doubt it's going to hurt any less if we postpone the switch for another four years.

I understand... speaking in the short term python +3 doesn't bring any benefits that outway the work needed to upgrade.

Python +3 is filled with micro changes, a lot of commonly used functions are deprecated. Off the top of my head one you like to use @ronie "has_key" was removed in favor of "in".

has_key was depreciated before Python 3. But yes, there are a lot of breaking changes. And Kodi-Python API modules need to be revised too so they correctly support Python 3 features, starting from clear separation between "text" and "byte" strings.
Reply
#21
(2016-12-14, 11:41)ironic_monkey Wrote: addon breakage is minor compared to the fact that python3 has largely changed the way you do cpython modules. it would be an involved rewrite. every project (3-4) at work where i have had to do this, i have gone through the pain of switching to ctypes type bindings because of issues in the new cpython stuff.

Personally, I prefer abstraction via Boost.Python that allow to write stuff in modern C++ without worrying about low level. Pybind11 even better in all respects, but it does not support Python 2.6 which is used on some platforms in Kodi 16 and below.
Reply
#22
personally i never consider a solution involving boost acceptable Wink reason is boost is a portability nightmare and i have to deal with exotic (hpc) platforms. but yeah, that's another way to go about it.
Reply
#23
Don't know about Kodi's core interface to Python, but as plain Python scripting language goes it should today be much smoother to upgrade to Python 3 and stay backwards compatible with Python 2 as there is now a new compatibility package that should make running Python 2 scripts under Python 3 easier.

Checkout: http://python-future.org/overview.html
Quote:python-future is the missing compatibility layer between Python 2 and Python 3. It allows you to use a single, clean Python 3.x-compatible codebase to support both Python 2 and Python 3 with minimal overhead.

It provides future and past packages with backports and forward ports of features from Python 3 and 2. It also comes with futurize and pasteurize, customized 2to3-based scripts that helps you to convert either Py2 or Py3 code easily to support both Python 2 and 3 in a single clean Py3-style codebase, module by module.

Notable projects that use python-future for Python 2/3 compatibility are Mezzanine and ObsPy.
As before it was adviced that if you upgraded to Python 3.x interpreter then you could still keep some backwards compatibility with Python 2.7 if you use the "six compatibility package" (for reference see http://packages.python.org/six/ ).

Now however the Python interpreter developers have made a new compatibility package that is called "python-future" (and it is also refered to as "future compatibility package"), so please see:

http://python-future.org/index.html ( and the actual package on GitHub https://github.com/PythonCharmers/python-future )

This "future compatibility package" is still in beta and doesn't support as many versions of Python as the six (it only goes back as far as Python 2.6, while six supports Python 2.4), but allows Python 2 compatible code to be written in a style that is closer to idiomatic Python 3 (for example, it includes an actual Python 2 compatible implementation of the Python 3 bytes type, rather than relying on the Python 2.x 8-bit string type that exposes a slightly different API).

Recommmed that you read both https://wiki.python.org/moin/Python2orPython3 and http://python-future.org/index.html

It suggest that much modern Python code should run largely unmodified on Python 3 using this "future compatibility package".
Reply
#24
(2016-12-15, 01:56)Hedda Wrote: Don't know about Kodi's core interface to Python, but as plain Python scripting language goes it should today be much smoother to upgrade to Python 3 and stay backwards compatible with Python 2 as there is now a new compatibility package that should make running Python 2 scripts under Python 3 easier.

My non-Kodi Python projects are either Python 3 or universal Py2/3 so I know well that converting Py2 code to Py3 is not that difficult even without helper tools like six. After all, we are not talking about large enterprise legacy codebase here. Code compatibility inspection in the free PyCharm community really helps, BTW.

However, such converting will require additional efforts from addon developers many of whom are just hobbyists that write addons in their free time. And I suspect that there must be a number of useful abandoned addons that "just work" but they will never be upgraded because, well, they are abandoned. Yes, helper tools for Py2->3 conversion exist, but they are not "one click" solutions and still need to be implemented manually.

Yes, I like Python 3 more and support for it in Kodi would be "nice to have" but I agree with Lunatixz here: theoretical benefits do not outweigh a lot of work needed to be done both by Kodi core developers and by addon developers. At least right now.
Reply



Logout Mark Read Team Forum Stats Members Help
Time to upgrade Kodi to Python 3.x interpreter version such as Python 3.3?1
This forum uses Lukasz Tkacz MyBB addons.