|
| 1 | + |
| 2 | +Build options |
| 3 | +============= |
| 4 | + |
| 5 | +python-for-android provides several major choices for build |
| 6 | +components. This page describes the advantages and drawbacks, and |
| 7 | +extra technical details or requirements, in each case. |
| 8 | + |
| 9 | + |
| 10 | +Python version |
| 11 | +-------------- |
| 12 | + |
| 13 | +python-for-android now supports building APKs with either python2 or |
| 14 | +python3, but these have extra requirements or potential disadvantages |
| 15 | +as below. |
| 16 | + |
| 17 | + |
| 18 | +python2 |
| 19 | +~~~~~~~ |
| 20 | + |
| 21 | +Select this by adding it in your requirements, e.g. ``--requirements=python2``. |
| 22 | + |
| 23 | +This option builds Python 2.7.2 for your selected Android architecture, and |
| 24 | +includes it in the APK. There are no special requirements, all the |
| 25 | +building is done locally. |
| 26 | + |
| 27 | +The python2 build is also the way python-for-android originally |
| 28 | +worked, even in the old toolchain. |
| 29 | + |
| 30 | + |
| 31 | +python3 |
| 32 | +~~~~~~~ |
| 33 | + |
| 34 | +.. warning:: |
| 35 | + Python3 support is experimental, and some of these details |
| 36 | + may change as it is improved and fully stabilised. |
| 37 | + |
| 38 | +Select this by adding the ``python3crystax`` recipe to your |
| 39 | +requirements, e.g. ``--requirements=python3crystax``. |
| 40 | + |
| 41 | +This uses the prebuilt Python from the `CrystaX NDK |
| 42 | +<https://www.crystax.net/android/ndk>`__, a drop-in replacement for |
| 43 | +Google's official NDK which includes many improvements. As such, you |
| 44 | +*must* use the CrystaX NDK 10.3.0 or higher when building with |
| 45 | +python3. You can get it `here |
| 46 | +<https://www.crystax.net/en/download>`__. |
| 47 | + |
| 48 | +python3 inclusion should work fine, including all existing |
| 49 | +recipes, but internally this is handled quite differently to the |
| 50 | +locally built python2 so there may be bugs or surprising |
| 51 | +behaviours. If you come across any, feel free to `open an issue |
| 52 | +<https://github.com/kivy/python-for-android>`__. |
| 53 | + |
| 54 | +The experimental status also means that some features are missing and |
| 55 | +the build is not fully optimised so APKs are probably a little larger |
| 56 | +and slower than they need to be. This is currently being addressed, |
| 57 | +though it's not clear how the final result will compare to python2. |
| 58 | + |
| 59 | +Bootstrap |
| 60 | +--------- |
| 61 | + |
| 62 | +python-for-android supports multiple bootstraps, the Java and JNI code |
| 63 | +that starts the app and the python interpreter, then handles |
| 64 | +interactions with the Android OS. |
| 65 | + |
| 66 | +Currently the following bootstraps are supported, but we hope that it |
| 67 | +it should be easy to add others if your project has different |
| 68 | +requirements. `Let us know |
| 69 | +<https://groups.google.com/forum/#!forum/python-android>`__ if there |
| 70 | +are any improvements that would help here. |
| 71 | + |
| 72 | +sdl2 |
| 73 | +~~~~ |
| 74 | + |
| 75 | +You can use this with ``--bootstrap=sdl2``, or simply include the |
| 76 | +``sdl2`` recipe in your ``--requirements``. |
| 77 | + |
| 78 | +SDL2 is a popular cross-platform depelopment library, particularly for |
| 79 | +games. It has its own Android project support, which |
| 80 | +python-for-android uses as a bootstrap, and to which it adds the |
| 81 | +Python build and JNI code to start it. |
| 82 | + |
| 83 | +From the point of view of a Python program, SDL2 should behave as |
| 84 | +normal. For instance, you can build apps with Kivy, Vispy, or PySDL2 |
| 85 | +and have them work with this bootstrap. It should also be possible to |
| 86 | +use e.g. pygame_sdl2, but this would need a build recipe and doesn't |
| 87 | +yet have one. |
| 88 | + |
| 89 | +.. note:: |
| 90 | + The SDL2 bootstrap is newer, and does not support all the old |
| 91 | + features of the Pygame one. It is under active development to fix |
| 92 | + these omissions. |
| 93 | + |
| 94 | +pygame |
| 95 | +~~~~~~ |
| 96 | + |
| 97 | +You can use this with ``--bootstrap=pygame``, or simply include the |
| 98 | +``pygame`` recipe in your ``--requirements``. |
| 99 | + |
| 100 | +The pygame bootstrap is the original backend used by Kivy, and still |
| 101 | +works fine for use with Kivy apps. It may also work for pure pygame |
| 102 | +apps, but hasn't been developed with this in mind. |
| 103 | + |
| 104 | +This bootstrap will eventually be deprecated in favour of sdl2, but |
| 105 | +not before the sdl2 bootstrap includes all the features that would be |
| 106 | +lost. |
0 commit comments