[Python-Dev] Exposing the Android platform existence to Python modules

Phil Thompson phil at riverbankcomputing.com
Sat Aug 2 09:53:35 CEST 2014


On 02/08/2014 4:34 am, Guido van Rossum wrote:
> Or SL4A? (https://github.com/damonkohler/sl4a)
> 
> 
> On Fri, Aug 1, 2014 at 8:06 PM, Steven D'Aprano <steve at pearwood.info> 
> wrote:
> 
>> On Sat, Aug 02, 2014 at 05:53:45AM +0400, Akira Li wrote:
>> 
>> > Python uses os.name, sys.platform, and various functions from `platform`
>> > module to provide version info:
>> [...]
>> > If Android is posixy enough (would `posix` module work on Android?)
>> > then os.name could be left 'posix'.
>> 
>> Does anyone know what kivy does when running under Android?

I don't think either do anything.

As the OP said, porting Python to Android is mainly about dealing with a 
C stdlib that is limited in places. Therefore there might be the odd 
missing function or attribute in the Python stdlib - just the same as 
can happen with other platforms.

To me the issue is whether, for a particular value of sys.platform, the 
programmer can expect a particular Python stdlib API. If so then Android 
needs a different value for sys.platform.

On the other hand if the programmer should not expect to make such an 
assumption, and should instead allow for the absence of certain 
functions (but which ones?), then the existing value of 'linux' should 
be fine.

Another option I don't think I've seen suggested, given the recommended 
way of testing for Linux is to use sys.platform.startswith('linux'), is 
to use a value of 'linux-android'.

Phil


More information about the Python-Dev mailing list