8000 Merge branch 'master' into stable · bahawk/python-for-android@73a6ae8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 73a6ae8

Browse files
committed
Merge branch 'master' into stable
2 parents 726ddeb + d1c44c7 commit 73a6ae8

File tree

136 files changed

+2894
-2455
lines changed
  • concurrency
  • launcher
  • libsdl/app
  • renpy/android
  • jniLibs
  • libs
  • res
  • org/kivy/android
  • templates
  • service_only
  • webview
  • recipes
  • tools
  • testapps
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    136 files changed

    +2894
    -2455
    lines changed

    doc/source/old_toolchain/index.rst

    Lines changed: 4 addi 10000 tions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,6 +7,10 @@ using distribute.sh and build.py. This it entirely superseded by the
    77
    new toolchain, you do not need to read it unless using this old
    88
    method.
    99

    10+
    .. warning:: The old toolchain is deprecated and no longer
    11+
    supported. You should instead use the :doc:`current version
    12+
    <../quickstart>`.
    13+
    1014
    Python for android is a project to create your own Python distribution
    1115
    including the modules you want, and create an apk including python, libs, and
    1216
    your application.

    doc/source/quickstart.rst

    Lines changed: 25 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -84,23 +84,45 @@ Installing Android SDK
    8484

    8585
    You need to download and unpack the Android SDK and NDK to a directory (let's say $HOME/Documents/):
    8686

    87-
    - `Android SDK <https://developer.android.com/sdk/index.html#Other>`_
    87+
    - `Android SDK <https://developer.android.com/studio/index.html>`_
    8888
    - `Android NDK <https://developer.android.com/ndk/downloads/index.html>`_
    8989

    90+
    For the Android SDK, you can download 'just the command line
    91+
    tools'. When you have extracted these you'll see only a directory
    92+
    named ``tools``, and you will need to run extra commands to install
    93+
    the SDK packages needed.
    94+
    95+
    For Android NDK, note that modern releases will only work on a 64-bit
    96+
    operating system. If you are using a 32-bit distribution (or hardware),
    97+
    the latest useable NDK version is r10e, which can be downloaded here:
    98+
    99+
    - `Legacy 32-bit Linux NDK r10e <http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin>`_
    100+
    101+
    First, install a platform to target (you can also replace ``19`` with
    102+
    a different platform number, this will be used again later)::
    103+
    104+
    $SDK_DIR/tools/bin/sdkmanager "platforms;android-19"
    105+
    106+
    Second, install the build-tools. You can use
    107+
    ``$SDK_DIR/tools/bin/sdkmanager --list`` to see all the
    108+
    possibilities, but 26.0.2 is the latest version at the time of writing::
    109+
    110+
    $SDK_DIR/tools/bin/sdkmanager "build-tools;26.0.2"
    111+
    90112
    Then, you can edit your ``~/.bashrc`` or other favorite shell to include new environment variables necessary for building on android::
    91113

    92114
    # Adjust the paths!
    93115
    export ANDROIDSDK="$HOME/Documents/android-sdk-21"
    94116
    export ANDROIDNDK="$HOME/Documents/android-ndk-r10e"
    95-
    export ANDROIDAPI="14" # Minimum API version your application require
    117+
    export ANDROIDAPI="19" # Minimum API version your application require
    96118
    export ANDROIDNDKVER="r10e" # Version of the NDK you installed
    97119

    98120
    You have the possibility to configure on any command the PATH to the SDK, NDK and Android API using:
    99121

    100122
    - :code:`--sdk_dir PATH` as an equivalent of `$ANDROIDSDK`
    101123
    - :code:`--ndk_dir PATH` as an equivalent of `$ANDROIDNDK`
    102124
    - :code:`--android_api VERSION` as an equivalent of `$ANDROIDAPI`
    103-
    - :code:`--ndk_ver PATH` as an equivalent of `$ANDROIDNDKVER`
    125+
    - :code:`--ndk_version PATH` as an equivalent of `$ANDROIDNDKVER`
    104126

    105127

    106128
    Usage

    doc/source/services.rst

    Lines changed: 7 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -80,8 +80,10 @@ Services support a range of options and interactions not yet
    8080
    documented here but all accessible via calling other methods of the
    8181
    ``service`` reference.
    8282

    83-
    .. note:: The app root directory for Python imports will be in the app
    84-
    root folder even if the service file is in a subfolder. To import from
    85-
    your service folder you must use e.g. ``import service.module``
    86-
    instead of ``import module``, if the service file is in the
    87-
    ``service/`` folder.
    83+
    .. note::
    84+
    85+
    The app root directory for Python imports will be in the app
    86+
    root folder even if the service file is in a subfolder. To import from
    87+
    your service folder you must use e.g. ``import service.module``
    88+
    instead of ``import module``, if the service file is in the
    89+
    ``service/`` folder.

    doc/source/troubleshooting.rst

    Lines changed: 18 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -160,3 +160,21 @@ This error appears in the logcat log if you try to access
    160160
    ``org.renpy.android.PythonActivity`` from within the new toolchain. To
    161161
    fix it, change your code to reference
    162162
    ``org.kivy.android.PythonActivity`` instead.
    163+
    164+
    websocket-client: if you see errors relating to 'SSL not available'
    165+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    166+
    Ensure you have the package backports.ssl-match-hostname in the buildozer requirements, since Kivy targets python 2.7.x
    167+
    168+
    You may also need sslopt={"cert_reqs": ssl.CERT_NONE} as a parameter to ws.run_forever() if you get an error relating to host verification
    169+
    170+
    Requested API target 19 is not available, install it with the SDK android tool
    171+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    172+
    173+
    This means that your SDK is missing the required platform tools. You
    174+
    need to install the ``platforms;android-19`` package in your SDK,
    175+
    using the ``android`` or ``sdkmanager`` tools (depending on SDK
    176+
    version).
    177+
    178+
    If using buildozer this should be done automatically, but as a
    179+
    workaround you can run these from
    180+
    ``~/.buildozer/android/platform/android-sdk-20/tools/android``.

    pythonforandroid/__init__.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,2 +1,2 @@
    11

    2-
    __version__ = '0.5.2'
    2+
    __version__ = '0.6.0'

    pythonforandroid/archs.py

    Lines changed: 25 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,4 +1,4 @@
    1-
    from os.path import (join, dirname)
    1+
    from os.path import (exists, join, dirname)
    22
    from os import environ, uname
    33
    import sys
    44
    from distutils.spawn import find_executable
    @@ -33,13 +33,32 @@ def include_dirs(self):
    3333
    def get_env(self, with_flags_in_cc=True):
    3434
    env = {}
    3535

    36-
    env["CFLAGS"] = " ".join([
    37-
    "-DANDROID", "-mandroid", "-fomit-frame-pointer",
    38-
    "--sysroot", self.ctx.ndk_platform])
    36+
    env['CFLAGS'] = ' '.join([
    37+
    '-DANDROID', '-mandroid', '-fomit-frame-pointer'
    38+
    ' -D__ANDROID_API__={}'.format(self.ctx._android_api),
    39+
    ])
    40+
    env['LDFLAGS'] = ' '
    41+
    42+
    sysroot = join(self.ctx._ndk_dir, 'sysroot')
    43+
    if exists(sysroot):
    44+
    # post-15 NDK per
    45+
    # https://android.googlesource.com/platform/ndk/+/ndk-r15-release/docs/UnifiedHeaders.md
    46+
    env['CFLAGS'] += ' -isystem {}/sysroot/usr/include/{}'.format(
    47+
    self.ctx.ndk_dir, self.ctx.toolchain_prefix)
    48+
    else:
    49+
    sysroot = self.ctx.ndk_platform
    50+
    env['CFLAGS'] += ' -I{}'.format(self.ctx.ndk_platform)
    51+
    env['CFLAGS'] += ' -isysroot {} '.format(sysroot)
    52+
    env['CFLAGS'] += '-I' + join(self.ctx.get_python_install_dir(),
    53+
    'include/python{}'.format(
    54+
    self.ctx.python_recipe.version[0:3])
    55+
    )
    56+
    57+
    env['LDFLAGS'] += '--sysroot {} '.format(self.ctx.ndk_platform)
    3958

    4059
    env["CXXFLAGS"] = env["CFLAGS"]
    4160

    42-
    env["LDFLAGS"] = " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)])
    61+
    env["LDFLAGS"] += " ".join(['-lm', '-L' + self.ctx.get_libs_dir(self.arch)])
    4362

    4463
    if self.ctx.ndk == 'crystax':
    4564
    env['LDFLAGS'] += ' -L{}/sources/crystax/libs/{} -lcrystax'.format(self.ctx.ndk_dir, self.arch)
    @@ -102,7 +121,7 @@ def get_env(self, with_flags_in_cc=True):
    102121

    103122
    hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)
    104123

    105-
    # AND: This hardcodes python version 2.7, needs fixing
    124+
    # This hardcodes python version 2.7, needs fixing
    106125
    env['BUILDLIB_PATH'] = join(
    107126
    hostpython_recipe.get_build_dir(self.arch),
    108127
    'build', 'lib.linux-{}-2.7'.format(uname()[-1]))

    pythonforandroid/bootstrap.py

    Lines changed: 6 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,7 +6,7 @@
    66
    import importlib
    77

    88
    from pythonforandroid.logger import (warning, shprint, info, logger,
    9-
    debug)
    9+
    debug, error)
    1010
    from pythonforandroid.util import (current_directory, ensure_dir,
    1111
    temp_directory, which)
    1212
    from pythonforandroid.recipe import Recipe
    @@ -178,8 +178,6 @@ def get_bootstrap(cls, name, ctx):
    178178
    This is the only way you should access a bootstrap class, as
    179179
    it sets the bootstrap directory correctly.
    180180
    '''
    181-
    # AND: This method will need to check user dirs, and access
    182-
    # bootstraps in a slightly different way
    183181
    if name is None:
    184182
    return None
    185183
    if not hasattr(cls, 'bootstraps'):
    @@ -195,20 +193,21 @@ def get_bootstrap(cls, name, ctx):
    195193
    bootstrap.ctx = ctx
    196194
    return bootstrap
    197195

    198-
    def distribute_libs(self, arch, src_dirs, wildcard='*'):
    196+
    def distribute_libs(self, arch, src_dirs, wildcard='*', dest_dir="libs"):
    199197
    '''Copy existing arch libs from build dirs to current dist dir.'''
    200198
    info('Copying libs')
    201-
    tgt_dir = join('libs', arch.arch)
    199+
    tgt_dir = join(dest_dir, arch.arch)
    202200
    ensure_dir(tgt_dir)
    203201
    for src_dir in src_dirs:
    204202
    for lib in glob.glob(join(src_dir, wildcard)):
    205203
    shprint(sh.cp, '-a', lib, tgt_dir)
    206204

    207-
    def distribute_javaclasses(self, javaclass_dir):
    205+
    def distribute_javaclasses(self, javaclass_dir, dest_dir="src"):
    208206
    '''Copy existing javaclasses from build dir to current dist dir.'''
    209207
    info('Copying java files')
    208+
    ensure_dir(dest_dir)
    210209
    for filename in glob.glob(javaclass_dir):
    211-
    shprint(sh.cp, '-a', filename, 'src')
    210+
    shprint(sh.cp, '-a', filename, dest_dir)
    212211

    213212
    def distribute_aars(self, arch):
    214213
    '''Process existing .aar bundles and copy to current dist dir.'''

    pythonforandroid/bootstraps/pygame/__init__.py

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -46,7 +46,6 @@ def run_distribute(self):
    4646

    4747
    info('Copying python distribution')
    4848
    hostpython = sh.Command(self.ctx.hostpython)
    49-
    # AND: This *doesn't* need to be in arm env?
    5049
    try:
    5150
    shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
    5251
    _tail=10, _filterout="^Listing")
    @@ -64,7 +63,6 @@ def run_distribute(self):
    6463
    shprint(sh.cp, '-a', join('python-install', 'lib'), 'private')
    6564
    shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))
    6665

    67-
    # AND: Copylibs stuff should go here
    6866
    shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
    6967
    shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))
    7068

    0 commit comments

    Comments
     (0)
    0