bpo-32637: Set sys.platform to "android" on Android by vstinner · Pull Request #5288 · python/cpython
Most likely at least MACHDEP should be modified, too.
>>> sysconfig.get_config_var('CFLAGS')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/local/tmp/python3/usr/lib/python3.7/sysconfig.py", line 595, in get_config_var
return get_config_vars().get(name)
File "/data/local/tmp/python3/usr/lib/python3.7/sysconfig.py", line 544, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/data/local/tmp/python3/usr/lib/python3.7/sysconfig.py", line 415, in _init_posix
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_android_'
In my build tree, there's build/target/python/usr/lib/python3.7/_sysconfigdata_m_linux_.py but no build/target/python/usr/lib/python3.7/_sysconfigdata_m_android_.py. If I understand the build process correctly, _sysconfigdata file is generated via $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars call in Makefile.pre.in, and PYTHON_FOR_BUILD uses MACHDEP via _PYTHON_SYSCONFIGDATA_NAME:
| PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$interp |
Note that this is tested with my building scripts at https://github.com/yan12125/python3-android/ using NDK r16b, not xdegaye's scripts. I tested ARM64, android-21 API on my ASUS ZE500KL phone.