[Mobile-sig] Recipe to cross-compile Python 3.4.2 for Android

Frank, Matthew I matthew.i.frank at intel.com
Mon Feb 2 19:22:35 CET 2015


I've posted my recipe (including necessary patches) for cross-compiling Python 3.4.2 for Android x86:

https://github.com/wandering-logic/android_x86_python-3.4

This is _not_ an App Framework.  This is the CPython interpreter running from the Android command line.  I originally did this work because I was working on performance analysis tools for Android operating systems developers.

I've only tested on x86 Android (and only on Android KitKat).  I work for Intel, so I have lots of resources for testing on x86, and none for testing on Arm.  Please share any info about your experiences on Arm processors: I'd like to make Python work for all variants of Android.

The patch on the site incorporates "fixes" for the following issues from the Python issue tracker:

20306: Lack of pw_gecos field in Android's struct passwd causes cross-compilation for the pwd module to fail
21668: The select and time modules uses libm functions without linking against it
16353: add function to os module for getting path to default shell
16255: subrocess.Popen needs /bin/sh but Android only has /system/bin/sh
22747: Interpreter fails in initialize on systems where HAVE_LANGINFO_H is undefined
20305: Android's incomplete locale.h implementation prevents cross-compilation

Plus several other problems that I haven't found reported to bugs.python.org.  (Having to do with problems with Android's support for gethostbyaddr_r() and wcsftime().)

(Note that by "fixes" I mean: I've done enough to get things compiling, linking and running, not necessarily changes that are appropriate to bring back to the Python code-base.)

The state of running the unit tests is:
328 tests passing.
22 tests failing.  (test_ctypes, test_threading, test_asyncio, test_bytes, test_capi, test_concurrent_futures, test_datetime, test_distutils, test_faulthandler, test_inspect, test_io, test_mmap, test_multiprocessing_main_handling, test_os, test_posix, test_posixpath, test_pwd, test_shutil, test_socket, test_subprocess, test_sys, test_unicode)
38 tests skipped.

Enjoy!  (And let me know if anything doesn't work!  (Or if you understand any of the test failures and have ideas about how those failures need to be addressed.))

-Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/mobile-sig/attachments/20150202/259a7e4b/attachment.html>


More information about the Mobile-sig mailing list