-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Guido van Rossum wrote: > sys.platform is for a broad indication of the OS kernel. It can be > used to distinguish Windows, Mac and Linux (and BSD, Solaris etc.). > Since Android is Linux it should have the same sys.platform as other > Linux systems ('linux2'). If you want to know whether a specific > syscall is there, check for the presence of the method in the os > module. > > The platform module is suitable for additional vendor-specific info > about the platform, and I'd hope that there's something there that > indicates Android. Again, what values does the platform module return > on SL4A or Kivy, which have already ported Python to Android? In > particular, I'd expect platform.linux_distribution() to return a > clue that it's Android. There should also be clues in > /etc/lsb-release (assuming Android supports it :-). > > -- --Guido van Rossum (python.org/~guido <http://python.org/~guido>)
To the best of my knowledge, Kivy and Py4A/SL4A don't modify that code at all, so it just returns 'linux2'. In addition, they don't modify platform.py either, so platform.linux_distribution() returns empty values. My patchset[1] currently contains patches that both set sys.platform to 'linux-android' and modifies platform.linux_distribution() to parse and return a proper value for Android systems: >>> import sys, platform sys.platform 'linux-android' >>> platform.linux_distribution() ('Android', '4.4.2', 'Blur_Version.174.44.9.falcon_umts.EURetail.en.EU') The sys.platform thing was mainly done out of curiosity on its possibility after Phil bringing it up. My main issue with leaving Android detection to checking platform.linux_distribution() is that it feels like a bit of a wonky thing for core Python modules to rely on to change behaviour where needed on Android (as well as introducing a dependency cycle between subprocess and platform right now). I'd also like to note that I wouldn't agree with following too many of Kivy/Py4A/SL4A's design decisions on this, as they seem mostly absent. - From what I've read, their patches mostly seem geared towards getting Python to run on Android, not necessarily integrating it well or fixing all inconsistencies. This also leads to things like subprocess.Popen() indeed breaking with shell=True[2]. Kind regards, Shiz [1]: https://github.com/rave-engine/python3-android/tree/master/src [2]: http://grokbase.com/t/gg/python-for-android/1343rm7q1w/py4a-subprocess-popen-oserror-errno-8-exec-format-error -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQQcBAEBCgAGBQJT3TiVAAoJEICfd9ZVuxW+X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iXDHPGxGyuxDW+bDhLfb4giOc9Gx9Wabi3IqGjqHfDfXC1MQY+K M9T3izX7Zvbf2g2+oxh9qftX4rGMsNe1uuS9b8Ym8Eupwv4NyHUbZx2e1glHTDJ0 u5Vt/DZqWHZPaoNT100vqfWKXlZC+BeFY+MB0k5ozBlhhdMMkST3ZVw8tve2WJCO fwb7hbhCJ3X7J9hBzq1giljgPJuWbUadYnVa8RulLDSlXQw/yh/8jkPShTc47row oZfxalB/0qwC+I8kWxb2Ln5LbAxqNhkahALPLSVQ/Mx/+6/shoVNQJTGc1FXn20= =nA+h -----END PGP SIGNATURE----- _______________________________________________ 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