Hi folks,

I’m working on porting CPython to the Android platform, and while making decent 
progress, I’m currently stuck at a higher-level issue than adding #ifdefs for 
__ANDROID__ to C extension modules.

The idea is, not only CPython extension modules have some assumptions that 
don’t seem to fit Android’s mold, some default Python-written modules do as 
well. However, whereas CPython extensions can trivially check if we’re building 
for Android by checking the __ANDROID__ compiler macro, Python modules can do 
no such check, and are left wondering how to figure out if the platform they 
are currently running on is an Android one. To my knowledge there is no 
reliable way to detect if one is using Android as a vehicle for their journey 
using any other way.

Now, the main question is: what would be the best way to ‘expose’ the 
indication that Android is being ran on to Python-living modules? My own 
thought was to add sys.getlinuxuserland(), or platform.linux_userland(), in 
similar vein to sys.getwindowsversion() and platform.linux_distribution(), 
which could return information about the userland of running CPython instance, 
instead of knowing merely the kernel and the distribution.

This way, code could trivially check if it ran on the GNU(+associates) 
userland, or under a BSD-ish userland, or Android… and adjust its behaviour 
accordingly.

I would be delighted to hear comments on this proposal, or better yet, 
alternative solutions. :)

Kind regards,
Shiz

P.S.: I am well aware that Android might as well never be officially supported 
in CPython. In that case, consider this a thought experiment of how it /would/ 
be handled. :)

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to