Module with no python 2/3 compatible version
#1
I've been trying to update dependencies on my addons and came across something I couldn't figure a way around on my own. Specifically this is for the httplib2 module (source: https://github.com/httplib2/httplib2). 

It has two distinct version for either python 2 or python 3. They're the same version number, just different chunks of code depending on the platform you're on. How should I go about updating this for inclusion to the Kodi repo? If Kodi 19 is going to be strictly Python 3 could I just submit the Python 3 version directly to that repo so it's available there and everything below that would get the Python 2 version currently in the repo? 

Ideally loading the module and having it choose the correct 2 or 3 version depending on your python version would workbest. I'm unsure if this is possible. I tried detecting the version and loading the python2 or python3 folder via the __init__.py file but non of my imports resolved correctly so I didn't spend a lot of time on it. Any ideas here please let me know.
Reply
#2
Many projects switched to requests+cachecontrol or httplib2shim+urllib3 due to httplib2 being slow with py3 migration.
Reply
#3
Thanks for the info. The problem I'm having is httplib2 is a dependency of a dependency of a dependency. Not sure I want to take the time to update all sorts of 3rd party libraries. I found another of these types of issues yesterday regarding the pyyaml library as well. It seems to be a common practice to split development into python 2 and 3 compatible versions. I imagine when distributing in a more standard fashion people are just installing the right one via pip for the version they have. 

My use case is for Google Drive. I'm using the PyDrive library, which has dependencies on a few other libraries which need httplib2 and pyyaml. This is starting to get convoluted enough I might just drop support for Google Drive from my addon until Kodi is fully on python 3 and I can use full python 3 libraries.
Reply
#4
(2019-09-03, 18:15)robweber Wrote: Ideally loading the module and having it choose the correct 2 or 3 version depending on your python version would workbest. I'm unsure if this is possible.

In out project we do it in two ways:
1. we try to import modules exclusive to Python2.x if that fails we import Python3.x modules with simple

try:
    import urllib.parse as parse
except ImportError:
    import urlparse as parse

2. we check version_info like this sys.version_info[0] < 3

There are probably simpler methods but that work for us.
Proud developer for Shoko and Nakamori. Long time xbmc/kodi user. IT Freak at Monogatari.
Reply
#5
Thanks for the response. In this instance I'm not sure how to accomplish that. Here is my problem in a little more detail. 

My addon (Backup) is using the library Pydrive to access Google Drive. Pydrive would be a xbmc.python.module type extension point. Pydrive requires the Google API which in turn requires httplib2. You can see here how the dependencies within the addon.xml start to stack up. The GoogleAPI at the end of the chain needs httplib2. httplib2 has either a python 2 or 3 version, but not a cross compatible version. 

The imports in this case are exactly the same given that the classes haven't changed, just the underlying code to be either py2 or py3 compatible. Since Kodi is currently only allowing cross compatible addons and libraries into the repo I really can't request that either version of httplib2 be accepted since Leia version on py2 can't use the py3 version and future versions of Kodi on python 3 can't use the python 2 version. No matter what the GoogleAPI code is doing 

Code:
import httplib2

What would be kind of neat is a tag within the addon.xml that told Kodi what to load based on the Python version.

Code:
<extension point="xbmc.python.module" library="lib2" library3="lib3" />

The original library tag would be the default but if library3 existed it would load that for Python3 only. Given that this would be a new feature I don't see this happening. At this point I really think my only alternative is just to wait until Kodi is fully python 3 only and then just submit the python 3 version.
Reply
#6
Yeah I started looking at porting various addons yesterday and quickly came to the conclusion that many modules are not present/working with Python 3.  I think realistically it's going to be very hard to get very far with this until the main PR is merged and a bunch of common modules get some attention.  Even then I suspect I will just do new Python 3 versions rather than much about with 2/3 compatible ones as that seems a bit of a mess.
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#7
(2019-09-07, 01:29)bossanova808 Wrote: Yeah I started looking at porting various addons yesterday and quickly came to the conclusion that many modules are not present/working with Python 3.  I think realistically it's going to be very hard to get very far with this until the main PR is merged and a bunch of common modules get some attention.  Even then I suspect I will just do new Python 3 versions rather than much about with 2/3 compatible ones as that seems a bit of a mess.

Main Python 3 PR was merged Last night  Big Grin
Reply
#8
Exciting!  I'll need to find some time to port a while bunch of things to V3 now...
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply

Logout Mark Read Team Forum Stats Members Help
Module with no python 2/3 compatible version0