Skip to content

Commit d853e81

Browse files
authored
Merge branch 'master' into omemo_recipe
2 parents 8a376e3 + 3c3d5c4 commit d853e81

38 files changed

+803
-374
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77

88
before_install:
99
- sudo apt update -qq
10-
- sudo apt install -qq python2.7 python3
10+
- sudo apt install -qq --no-install-recommends python2.7 python3
1111
- sudo pip install tox>=2.0
1212
# https://github.com/travis-ci/travis-ci/issues/6069#issuecomment-266546552
1313
- git remote set-branches --add origin master
@@ -19,12 +19,12 @@ env:
1919
- ANDROID_NDK_HOME=/opt/android/android-ndk
2020
- CRYSTAX_NDK_HOME=/opt/android/crystax-ndk
2121
matrix:
22-
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME'
22+
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python3.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements sdl2,pyjnius,kivy,python3'
2323
# overrides requirements to skip `peewee` pure python module, see:
2424
# https://github.com/kivy/python-for-android/issues/1263#issuecomment-390421054
2525
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2_sqlite_openssl.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements sdl2,pyjnius,kivy,python2,openssl,requests,sqlite3,setuptools'
2626
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --bootstrap sdl2 --requirements python2,numpy'
27-
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python3.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $CRYSTAX_NDK_HOME --requirements python3crystax,setuptools,android,sdl2,pyjnius,kivy'
27+
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python3crystax.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $CRYSTAX_NDK_HOME --requirements python3crystax,setuptools,android,sdl2,pyjnius,kivy'
2828
# builds only the recipes that moved
2929
- COMMAND='. venv/bin/activate && ./ci/rebuild_updated_recipes.py'
3030

Dockerfile

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# Dockerfile with:
2-
# - Android build environment
3-
# - python-for-android dependencies
2+
# - Android build environment
3+
# - python-for-android dependencies
44
# Build with:
55
# docker build --tag=p4a .
66
# Run with:
77
# docker run p4a /bin/sh -c '. venv/bin/activate && p4a apk --help'
88
# Or for interactive shell:
99
# docker run -it --rm p4a
10-
#
11-
# TODO:
12-
# - delete archives to keep small the container small
13-
# - setup caching (for apt, pip, ndk, sdk and p4a recipes downloads)
1410
FROM ubuntu:18.04
1511

1612

@@ -27,35 +23,39 @@ ENV ANDROID_SDK_TOOLS_VERSION="3859397"
2723

2824
ENV ANDROID_HOME="/opt/android"
2925
ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk" \
30-
CRYSTAX_NDK_HOME="${ANDROID_HOME}/crystax-ndk" \
31-
ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk"
26+
CRYSTAX_NDK_HOME="${ANDROID_HOME}/crystax-ndk" \
27+
ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk"
3228
ENV ANDROID_NDK_HOME_V="${ANDROID_NDK_HOME}-r${ANDROID_NDK_VERSION}" \
33-
CRYSTAX_NDK_HOME_V="${CRYSTAX_NDK_HOME}-${CRYSTAX_NDK_VERSION}"
29+
CRYSTAX_NDK_HOME_V="${CRYSTAX_NDK_HOME}-${CRYSTAX_NDK_VERSION}"
3430
ENV ANDROID_NDK_ARCHIVE="android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip" \
35-
CRYSTAX_NDK_ARCHIVE="crystax-ndk-${CRYSTAX_NDK_VERSION}-linux-x86.tar.xz" \
36-
ANDROID_SDK_TOOLS_ARCHIVE="sdk-tools-linux-${ANDROID_SDK_TOOLS_VERSION}.zip"
31+
CRYSTAX_NDK_ARCHIVE="crystax-ndk-${CRYSTAX_NDK_VERSION}-linux-x86.tar.xz" \
32+
ANDROID_SDK_TOOLS_ARCHIVE="sdk-tools-linux-${ANDROID_SDK_TOOLS_VERSION}.zip"
3733
ENV ANDROID_NDK_DL_URL="https://dl.google.com/android/repository/${ANDROID_NDK_ARCHIVE}" \
38-
CRYSTAX_NDK_DL_URL="https://eu.crystax.net/download/${CRYSTAX_NDK_ARCHIVE}" \
39-
ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}"
34+
CRYSTAX_NDK_DL_URL="https://eu.crystax.net/download/${CRYSTAX_NDK_ARCHIVE}" \
35+
ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}"
4036

4137
# install system dependencies
4238
RUN apt update -qq && apt install -qq --yes --no-install-recommends \
43-
python virtualenv python-pip wget curl lbzip2 patch bsdtar sudo && \
39+
python virtualenv python-pip wget curl lbzip2 patch bsdtar sudo && \
4440
rm -rf /var/lib/apt/lists/*
4541

4642
# build dependencies
4743
# https://buildozer.readthedocs.io/en/latest/installation.html#android-on-ubuntu-16-04-64bit
48-
RUN dpkg --add-architecture i386 && apt update -qq && apt install -qq --yes --no-install-recommends \
49-
build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 \
50-
libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev \
51-
openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 && \
44+
RUN dpkg --add-architecture i386 && apt update -qq && apt install -qq --yes --no-install-recommends \
45+
build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 \
46+
libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev \
47+
openjdk-8-jdk zip unzip zlib1g-dev zlib1g:i386
48+
49+
# specific recipes dependencies (e.g. libffi requires autoreconf binary)
50+
RUN apt install -qq --yes --no-install-recommends \
51+
autoconf automake cmake gettext libltdl-dev libtool pkg-config && \
5252
rm -rf /var/lib/apt/lists/*
5353

5454
# download and install Android NDK
5555
RUN curl --location --progress-bar "${ANDROID_NDK_DL_URL}" --output "${ANDROID_NDK_ARCHIVE}" && \
5656
mkdir --parents "${ANDROID_NDK_HOME_V}" && \
5757
unzip -q "${ANDROID_NDK_ARCHIVE}" -d "${ANDROID_HOME}" && \
58-
ln -sfn "${ANDROID_NDK_HOME_V}" "${ANDROID_NDK_HOME}" && \
58+
ln -sfn "${ANDROID_NDK_HOME_V}" "${ANDROID_NDK_HOME}" && \
5959
rm -rf "${ANDROID_NDK_ARCHIVE}"
6060

6161
# download and install CrystaX NDK
@@ -70,7 +70,7 @@ RUN curl --location --progress-bar "${CRYSTAX_NDK_DL_URL}" --output "${CRYSTAX_N
7070
--exclude=crystax-ndk-${CRYSTAX_NDK_VERSION}/toolchains/llvm-* \
7171
--exclude=crystax-ndk-${CRYSTAX_NDK_VERSION}/toolchains/aarch64-* \
7272
--exclude=crystax-ndk-${CRYSTAX_NDK_VERSION}/toolchains/mips64el-* && \
73-
ln -sfn "${CRYSTAX_NDK_HOME_V}" "${CRYSTAX_NDK_HOME}" && \
73+
ln -sfn "${CRYSTAX_NDK_HOME_V}" "${CRYSTAX_NDK_HOME}" && \
7474
rm -rf "${CRYSTAX_NDK_ARCHIVE}"
7575

7676
# download and install Android SDK
@@ -81,9 +81,10 @@ RUN curl --location --progress-bar "${ANDROID_SDK_TOOLS_DL_URL}" --output "${AND
8181

8282
# update Android SDK, install Android API, Build Tools...
8383
RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" && \
84-
echo '### User Sources for Android SDK Manager' > "${ANDROID_SDK_HOME}/.android/repositories.cfg"
84+
echo '### User Sources for Android SDK Manager' > "${ANDROID_SDK_HOME}/.android/repositories.cfg"
8585
RUN yes | "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" --licenses
8686
RUN "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-19" && \
87+
"${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-27" && \
8788
"${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;26.0.2" && \
8889
chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
8990

@@ -92,7 +93,7 @@ RUN useradd --create-home --shell /bin/bash ${USER}
9293
# with sudo access and no password
9394
RUN usermod -append --groups sudo ${USER}
9495
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
95-
RUN pip install --quiet --upgrade cython==0.21
96+
RUN pip install --quiet --upgrade cython==0.28.6
9697
WORKDIR ${WORK_DIR}
9798
COPY . ${WORK_DIR}
9899
# user needs ownership/write access to these directories

ci/constants.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,23 @@ class TargetPython(Enum):
2929
# https://github.com/kivy/python-for-android/issues/1354
3030
'kivent_core', 'kivent_cymunk', 'kivent_particles', 'kivent_polygen',
3131
'kiwisolver',
32-
# system dependencies autoconf, libtool
33-
'libexpat',
34-
'libgeos',
3532
# https://github.com/kivy/python-for-android/issues/1399
3633
'libglob',
37-
# system dependencies cmake and compile error
3834
'libmysqlclient',
3935
'libsecp256k1',
4036
'libtribler',
41-
# system dependencies gettext, pkg-config
42-
'libzbar',
4337
'ndghttpsclient',
4438
'm2crypto',
4539
'netifaces',
4640
'Pillow',
47-
# requires autoconf system dependency on host
48-
# https://api.travis-ci.org/v3/job/450538715/log.txt
41+
# depends on cffi that still seems to have compilation issues
4942
'protobuf_cpp',
5043
'xeddsa',
5144
'x3dh',
5245
'pynacl',
5346
'doubleratchet',
5447
'omemo',
48+
'cryptography',
5549
# https://github.com/kivy/python-for-android/issues/1405
5650
'psycopg2',
5751
'pygame',
@@ -69,16 +63,7 @@ class TargetPython(Enum):
6963
'zope',
7064
])
7165
BROKEN_RECIPES_PYTHON3_CRYSTAX = set([
72-
# not yet python3crystax compatible
73-
'apsw', 'atom', 'boost', 'brokenrecipe', 'cdecimal', 'cherrypy',
74-
'coverage', 'dateutil', 'enaml', 'ethash', 'kiwisolver', 'libgeos',
75-
'libnacl', 'libsodium', 'libtorrent', 'libtribler', 'libzbar', 'libzmq',
76-
'm2crypto', 'mysqldb', 'ndghttpsclient', 'pil', 'pycrypto', 'pyethereum',
77-
'pygame', 'pyleveldb', 'pyproj', 'pyzmq', 'regex', 'shapely',
78-
'simple-crypt', 'twsisted', 'vispy', 'websocket-client', 'zbar',
79-
'zeroconf', 'zope',
80-
# https://github.com/kivy/python-for-android/issues/550
81-
'audiostream',
66+
'brokenrecipe',
8267
# enum34 is not compatible with Python 3.6 standard library
8368
# https://stackoverflow.com/a/45716067/185510
8469
'enum34',
@@ -97,8 +82,6 @@ class TargetPython(Enum):
9782
'icu',
9883
# https://github.com/kivy/python-for-android/issues/1354
9984
'kivent_core', 'kivent_cymunk', 'kivent_particles', 'kivent_polygen',
100-
# system dependencies autoconf, libtool
101-
'libexpat',
10285
# https://github.com/kivy/python-for-android/issues/1405
10386
'libpq', 'psycopg2',
10487
'netifaces',

doc/source/buildoptions.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ This option builds Python 2.7.2 for your selected Android
1717
architecture. There are no special requirements, all the building is
1818
done locally.
1919

20-
The python2 build is also the way python-for-android originally
21-
worked, even in the old toolchain.
22-
2320

2421
python3
2522
~~~~~~~
2623

27-
.. warning::
28-
Python3 support is experimental, and some of these details
29-
may change as it is improved and fully stabilised.
24+
Python3 is supported in two ways. The default method uses CPython 3.7+
25+
and works with any recent version of the Android NDK.
26+
27+
Select Python 3 by adding it to your requirements,
28+
e.g. ``--requirements=python3``.
29+
30+
31+
CrystaX python3
32+
###############
33+
34+
.. warning:: python-for-android originally supported Python 3 using the CrystaX
35+
NDK. This support is now being phased out as CrystaX is no longer
36+
actively developed.
3037

3138
.. note:: You must manually download the `CrystaX NDK
3239
<https://www.crystax.net/android/ndk>`__ and tell
@@ -42,11 +49,6 @@ Google's official NDK which includes many improvements. You
4249
python3. You can get it `here
4350
<https://www.crystax.net/en/download>`__.
4451

45-
The python3crystax build is handled quite differently to python2 so
46-
there may be bugs or surprising behaviours. If you come across any,
47-
feel free to `open an issue
48-
<https://github.com/kivy/python-for-android>`__.
49-
5052
.. _bootstrap_build_options:
5153

5254
Bootstrap options

doc/source/quickstart.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,17 @@ Then, you can edit your ``~/.bashrc`` or other favorite shell to include new env
114114
# Adjust the paths!
115115
export ANDROIDSDK="$HOME/Documents/android-sdk-21"
116116
export ANDROIDNDK="$HOME/Documents/android-ndk-r10e"
117-
export ANDROIDAPI="19" # Target API version of your application
117+
export ANDROIDAPI="26" # Target API version of your application
118+
export NDKAPI="19" # Minimum supported API version of your application
118119
export ANDROIDNDKVER="r10e" # Version of the NDK you installed
119120

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

122-
- :code:`--sdk_dir PATH` as an equivalent of `$ANDROIDSDK`
123-
- :code:`--ndk_dir PATH` as an equivalent of `$ANDROIDNDK`
124-
- :code:`--android_api VERSION` as an equivalent of `$ANDROIDAPI`
125-
- :code:`--ndk_version VERSION` as an equivalent of `$ANDROIDNDKVER`
123+
- :code:`--sdk-dir PATH` as an equivalent of `$ANDROIDSDK`
124+
- :code:`--ndk-dir PATH` as an equivalent of `$ANDROIDNDK`
125+
- :code:`--android-api VERSION` as an equivalent of `$ANDROIDAPI`
126+
- :code:`--ndk-api VERSION` as an equivalent of `$NDKAPI`
127+
- :code:`--ndk-version VERSION` as an equivalent of `$ANDROIDNDKVER`
126128

127129

128130
Usage

pythonforandroid/archs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_env(self, with_flags_in_cc=True):
3535

3636
env['CFLAGS'] = ' '.join([
3737
'-DANDROID', '-mandroid', '-fomit-frame-pointer'
38-
' -D__ANDROID_API__={}'.format(self.ctx._android_api),
38+
' -D__ANDROID_API__={}'.format(self.ctx.ndk_api),
3939
])
4040
env['LDFLAGS'] = ' '
4141

@@ -133,6 +133,7 @@ def get_env(self, with_flags_in_cc=True):
133133
env['PATH'] = environ['PATH']
134134

135135
env['ARCH'] = self.arch
136+
env['NDK_API'] = 'android-{}'.format(str(self.ctx.ndk_api))
136137

137138
if self.ctx.python_recipe and self.ctx.python_recipe.from_crystax:
138139
env['CRYSTAX_PYTHON_VERSION'] = self.ctx.python_recipe.version

pythonforandroid/bootstrap.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from os import listdir
33
import sh
44
import glob
5-
import json
65
import importlib
76

87
from pythonforandroid.logger import (warning, shprint, info, logger,
@@ -102,21 +101,10 @@ def prepare_build_dir(self):
102101
fileh.write('target=android-{}'.format(self.ctx.android_api))
103102

104103
def prepare_dist_dir(self, name):
105-
# self.dist_dir = self.get_dist_dir(name)
106104
ensure_dir(self.dist_dir)
107105

108106
def run_distribute(self):
109-
# print('Default bootstrap being used doesn\'t know how '
110-
# 'to distribute...failing.')
111-
# exit(1)
112-
with current_directory(self.dist_dir):
113-
info('Saving distribution info')
114-
with open('dist_info.json', 'w') as fileh:
115-
json.dump({'dist_name': self.ctx.dist_name,
116-
'bootstrap': self.ctx.bootstrap.name,
117-
'archs': [arch.arch for arch in self.ctx.archs],
118-
'recipes': self.ctx.recipe_build_order + self.ctx.python_modules},
119-
fileh)
107+
self.distribution.save_info(self.dist_dir)
120108

121109
@classmethod
122110
def list_bootstraps(cls):
@@ -254,9 +242,15 @@ def strip_libraries(self, arch):
254242
warning('Can\'t find strip in PATH...')
255243
return
256244
strip = sh.Command(strip)
257-
filens = shprint(sh.find, join(self.dist_dir, 'private'),
258-
join(self.dist_dir, 'libs'),
259-
'-iname', '*.so', _env=env).stdout.decode('utf-8')
245+
246+
if self.ctx.python_recipe.name == 'python2':
247+
filens = shprint(sh.find, join(self.dist_dir, 'private'),
248+
join(self.dist_dir, 'libs'),
249+
'-iname', '*.so', _env=env).stdout.decode('utf-8')
250+
else:
251+
filens = shprint(sh.find, join(self.dist_dir, '_python_bundle', '_python_bundle', 'modules'),
252+
join(self.dist_dir, 'libs'),
253+
'-iname', '*.so', _env=env).stdout.decode('utf-8')
260254
logger.info('Stripping libraries in private dir')
261255
for filen in filens.split('\n'):
262256
try:

0 commit comments

Comments
 (0)