Skip to content

Feature Request: Add support for building Android wheels #810

Closed

Description

@ankith26

As per PEP 738, Android is an officially supported platform for Python. Python 3.14 releases includes official android embeddable packages.

It would be really appreciated if meson-python adds support for Android too, just as iOS support added recently.

Activity

  1. rgommers commented on Oct 31, 2025

    @rgommers
    Contributor

    @ankith26 thanks for the request. Could you add some details, like how it currently fails? And I assume there are Beeware patches that do make things work for meson-python that need upstreaming?

  2. ankith26 commented on Oct 31, 2025

    @ankith26
    Author

    For testing, I am using my very minimal sample/boilerplate repo (https://github.com/ankith26/python-c-extension-boilerplate).

    I am relying on cibuildwheel to set up the build environment and manage the build. I first setup android-sdk as outlined in https://cibuildwheel.pypa.io/en/stable/platforms/#android. The command I ran

    ANDROID_HOME="/home/ankith/mount2/softwares/android-sdk" CIBW_PLATFORM=android CIBW_BUILD="cp314-android_x86_64" cibuildwheel

    produces output

         _ _       _ _   _       _           _
     ___|_| |_ _ _|_| |_| |_ _ _| |_ ___ ___| |
    |  _| | . | | | | | . | | | |   | -_| -_| |
    |___|_|___|___|_|_|___|_____|_|_|___|___|_|
    
    cibuildwheel version 3.2.1
    
    Build options:
      platform: android
      allow_empty: False
      architectures: x86_64
      build_selector: 
        build_config: cp314-android_x86_64
        skip_config: 
        requires_python: >=3.8
        enable: []
      output_dir: /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate/wheelhouse
      package_dir: /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate
      test_selector: 
        skip_config:
      before_all: 
      before_build: 
      before_test: 
      build_frontend: build
      build_verbosity: 0
      config_settings: 
      container_engine: docker
      dependency_constraints: pinned
      environment: 
      manylinux_images: None
      musllinux_images: None
      pyodide_version: None
      repair_command: 
      test_command: 
      test_environment: 
      test_extras: 
      test_groups: 
      test_requires: 
      test_sources: 
      xbuild_tools: None
    
    Cache folder: /home/ankith/.cache/cibuildwheel
    
    Here we go!
    
    
    Building cp314-android_x86_64 wheel
    CPython 3.14 Android x86_64
    
    Installing target Python...
    
    
                                                                  ✓ 0.69s
    Setting up build environment...
    
    Creating python-build-standalone environment: version=3.14
    Detected platform: arch='x86_64', platform='unknown-linux', libc='gnu'
    Looking for file with pattern cpython-3.14.*-x86_64-unknown-linux-gnu-install_only.tar.gz
    Using python-build-standalone release: 20251010
    Using cached python_build_standalone: /home/ankith/.cache/cibuildwheel/cpython-3.14.0+20251010-x86_64-unknown-linux-gnu-install_only.tar.gz
    Found python executable: /tmp/cibw-run-qzzf88jt/cp314-android_x86_64/pbs/python/bin/python
    + /home/ankith/.pyenv/versions/3.14.0/bin/python3 -sS /home/ankith/.cache/cibuildwheel/virtualenv-20.35.2.pyz --activators= --no-periodic-update --pip=25.2 --no-setuptools --symlink-app-data --python /tmp/cibw-run-qzzf88jt/cp314-android_x86_64/pbs/python/bin/python3.14 /tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv
    created virtual environment CPython3.14.0.final.0-64 in 275ms
      creator CPython3Posix(dest=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv, clear=False, no_vcs_ignore=False, global=False)
      seeder FromAppData(download=False, pip=25.2, via=symlink, app_data_dir=/home/ankith/snap/code/211/.local/share/virtualenv)
        added seed packages: pip==25.2
    + which python
    + python --version
    Python 3.14.0
    + which pip
    + pip --version
    pip 25.2 from /tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv/lib/python3.14/site-packages/pip (python 3.14)
    + /tmp/cibw-run-qzzf88jt/cp314-android_x86_64/python/android.py env
    export AR=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
    export AS=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
    export CC=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang
    export CFLAGS='-D__BIONIC_NO_PAGE_SIZE_MACRO -I/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/python/prefix/include -DNDEBUG -O3 -Wall'
    export CIBW_HOST_TRIPLET=x86_64-linux-android
    export CMAKE_TOOLCHAIN_FILE=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/toolchain.cmake
    export CPU_COUNT=8
    export CXX=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang++
    export CXXFLAGS='-D__BIONIC_NO_PAGE_SIZE_MACRO -I/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/python/prefix/include -DNDEBUG -O3 -Wall'
    export LD=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
    export LDFLAGS='-Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,-z,max-page-size=16384 -Wl,--no-undefined -lm -L/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/python/prefix/lib'
    export NM=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm
    export PATH=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv/bin:/home/ankith/.pyenv/versions/3.14.0/bin:/home/ankith/.pyenv/libexec:/home/ankith/.pyenv/plugins/python-build/bin:/home/ankith/.pyenv/plugins/pyenv-virtualenv/bin:/home/ankith/.pyenv/plugins/pyenv-update/bin:/home/ankith/.pyenv/plugins/pyenv-doctor/bin:/home/ankith/.pyenv/shims:/home/ankith/.pyenv/bin:/home/ankith/.pyenv/bin:/home/ankith/.local/bin:/home/ankith/.pyenv/bin:/usr/share/pyenv/bin:/home/ankith/.local/bin:/usr/share/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/ankith/.vscode/extensions/ms-python.debugpy-2025.14.1-linux-x64/bundled/scripts/noConfigScripts
    export PIP_DISABLE_PIP_VERSION_CHECK=1
    export PKG_CONFIG='pkg-config --define-prefix'
    export PKG_CONFIG_LIBDIR=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/python/prefix/lib/pkgconfig
    export RANLIB=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
    export READELF=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf
    export STRIP=/home/ankith/mount2/softwares/android-sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
    export VIRTUAL_ENV=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv
    + pip install build -c file:///home/ankith/.pyenv/versions/3.14.0/lib/python3.14/site-packages/cibuildwheel/resources/constraints-python314.txt
    Collecting build
      Using cached build-1.3.0-py3-none-any.whl.metadata (5.6 kB)
    Collecting packaging>=19.1 (from build)
      Using cached packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
    Collecting pyproject_hooks (from build)
      Using cached pyproject_hooks-1.2.0-py3-none-any.whl.metadata (1.3 kB)
    Using cached build-1.3.0-py3-none-any.whl (23 kB)
    Using cached packaging-25.0-py3-none-any.whl (66 kB)
    Using cached pyproject_hooks-1.2.0-py3-none-any.whl (10 kB)
    Installing collected packages: pyproject_hooks, packaging, build
    Successfully installed build-1.3.0 packaging-25.0 pyproject_hooks-1.2.0
    + pip install meson-python
    Collecting meson-python
      Using cached meson_python-0.18.0-py3-none-any.whl.metadata (2.8 kB)
    Collecting meson>=1.2.3 (from meson-python)
      Using cached meson-1.9.1-py3-none-any.whl.metadata (1.8 kB)
    Requirement already satisfied: packaging>=23.2 in /tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv/lib/python3.14/site-packages (from meson-python) (25.0)
    Collecting pyproject-metadata>=0.9.0 (from meson-python)
      Using cached pyproject_metadata-0.9.1-py3-none-any.whl.metadata (7.0 kB)
    Using cached meson_python-0.18.0-py3-none-any.whl (28 kB)
    Using cached meson-1.9.1-py3-none-any.whl (1.0 MB)
    Using cached pyproject_metadata-0.9.1-py3-none-any.whl (18 kB)
    Installing collected packages: pyproject-metadata, meson, meson-python
    Successfully installed meson-1.9.1 meson-python-0.18.0 pyproject-metadata-0.9.1
    
                                                                  ✓ 6.02s
    Building wheel...
    
    + python -m build /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate --wheel --no-isolation --skip-dependency-check --outdir=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/built_wheel
    * Building wheel...
    + meson setup /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate/.mesonpy-n7htu2dp -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate/.mesonpy-n7htu2dp/meson-python-native-file.ini
    The Meson build system
    Version: 1.9.1
    Source dir: /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate
    Build dir: /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate/.mesonpy-n7htu2dp
    Build type: native build
    Project name: math_example
    Project version: 1.0.0
    
    ../meson.build:1:0: ERROR: Could not invoke sanity check executable: [Errno 2] No such file or directory: '/home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate/.mesonpy-n7htu2dp/meson-private/sanitycheckc.exe'.
    
    A full log can be found at /home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate/.mesonpy-n7htu2dp/meson-logs/meson-log.txt
    
    ERROR Backend subprocess exited when trying to invoke build_wheel
    
                                                                  ✕ 0.88s
    cibuildwheel: error: Command ['/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/venv/bin/python', '-m', 'build', '/home/ankith/mount/gitstuff/personal/ankith26/python-c-extension-boilerplate', '--wheel', '--no-isolation', '--skip-dependency-check', '--outdir=/tmp/cibw-run-qzzf88jt/cp314-android_x86_64/built_wheel'] failed with code 1. 
    

    From what I can tell, the native-file that meson-python is passing right now is not correct for android. I think that meson-python should prepare and pass an android cross file that uses the environment variables that cibuildwheel has already set.

  3. rgommers commented on Oct 31, 2025

    @rgommers
    Contributor

    Thanks @ankith26, that is helpful. Assuming it's similar to iOS in complexity, I don't see a problem with adding support.

    There are working NumPy and SciPy builds at https://chaquo.com/chaquopy/, so let's ask the expert where the relevant patches are - @mhsmith, could you comment on this?

  4. dnicolodi commented on Oct 31, 2025

    @dnicolodi
    Member

    This https://nibblestew.blogspot.com/2025/10/building-android-apps-with-native-code.html may be relevant. It seems that it could be possible to rely on meson env2mfile to generate a machine file.

  5. dnicolodi commented on Nov 2, 2025

    @dnicolodi
    Member

    There are working NumPy and SciPy builds at https://chaquo.com/chaquopy/,

    AFAICT, Chaquopy supports only "old" versions on NumPy and SciPy that use setuptools as build system.

  6. mhsmith commented on Nov 3, 2025

    @mhsmith
    Contributor

    That's correct: the patches are here, but I haven't tried to build anything for Android with Meson yet.

    Related:

  7. rgommers commented on Feb 8, 2026

    @rgommers
    Contributor

    The PR to implement support is pretty much ready: gh-824. I'm intending to merge that soon unless anyone sees a problem there, so please have a look.

  8. added this to the v0.20.0 milestone on Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions