Skip to content

Commit dd69749

Browse files
authored
Merge pull request #1955 from kivy/release-2019.08.09
Release 2019.08.09
2 parents ce9b571 + b1517a3 commit dd69749

File tree

78 files changed

+2109
-681
lines changed

Some content is hidden

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

78 files changed

+2109
-681
lines changed

.gitignore

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,19 @@ __pycache__/
2121

2222
#idea/pycharm
2323
.idea/
24-
.tox
24+
25+
# Unit test / coverage reports
26+
htmlcov/
27+
.tox/
28+
.coverage
29+
.coverage.*
30+
.cache
31+
coverage.xml
32+
*.cover
33+
.pytest_cache/
34+
35+
# testapp's build folder
36+
testapps/build/
37+
38+
# Dolphin (the KDE file manager autogenerates the file `.directory`)
39+
.directory

Dockerfile.py2

+7-10
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ RUN ${RETRY} curl --location --progress-bar --insecure \
5858
ENV ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk"
5959

6060
# get the latest version from https://developer.android.com/studio/index.html
61-
ENV ANDROID_SDK_TOOLS_VERSION="3859397"
62-
ENV ANDROID_SDK_BUILD_TOOLS_VERSION="26.0.2"
61+
ENV ANDROID_SDK_TOOLS_VERSION="4333796"
62+
ENV ANDROID_SDK_BUILD_TOOLS_VERSION="28.0.2"
6363
ENV ANDROID_SDK_TOOLS_ARCHIVE="sdk-tools-linux-${ANDROID_SDK_TOOLS_VERSION}.zip"
6464
ENV ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}"
6565

@@ -76,16 +76,14 @@ RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" \
7676
&& echo '### User Sources for Android SDK Manager' \
7777
> "${ANDROID_SDK_HOME}/.android/repositories.cfg"
7878

79-
# accept Android licenses (JDK necessary!)
79+
# Download and accept Android licenses (JDK necessary!)
8080
RUN ${RETRY} apt -y install -qq --no-install-recommends openjdk-8-jdk \
8181
&& apt -y autoremove
8282
RUN yes | "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" > /dev/null
83+
RUN yes | "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-27" > /dev/null
8384

84-
# download platforms, API, build tools
85-
RUN "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-19" && \
86-
"${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-27" && \
87-
"${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" && \
88-
chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
85+
# Set avdmanager permissions (executable)
86+
RUN chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
8987

9088

9189
ENV USER="user"
@@ -124,8 +122,6 @@ RUN usermod -append --groups sudo ${USER}
124122
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
125123

126124

127-
RUN pip install --upgrade cython==0.28.6
128-
129125
WORKDIR ${WORK_DIR}
130126
COPY --chown=user:user . ${WORK_DIR}
131127
RUN chown --recursive ${USER} ${ANDROID_SDK_HOME}
@@ -134,4 +130,5 @@ USER ${USER}
134130
# install python-for-android from current branch
135131
RUN virtualenv --python=python venv \
136132
&& . venv/bin/activate \
133+
&& pip install --upgrade cython==0.28.6 \
137134
&& pip install -e .

Dockerfile.py3

+10-11
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ RUN ${RETRY} curl --location --progress-bar --insecure \
5858
ENV ANDROID_SDK_HOME="${ANDROID_HOME}/android-sdk"
5959

6060
# get the latest version from https://developer.android.com/studio/index.html
61-
ENV ANDROID_SDK_TOOLS_VERSION="3859397"
62-
ENV ANDROID_SDK_BUILD_TOOLS_VERSION="26.0.2"
61+
ENV ANDROID_SDK_TOOLS_VERSION="4333796"
62+
ENV ANDROID_SDK_BUILD_TOOLS_VERSION="28.0.2"
6363
ENV ANDROID_SDK_TOOLS_ARCHIVE="sdk-tools-linux-${ANDROID_SDK_TOOLS_VERSION}.zip"
6464
ENV ANDROID_SDK_TOOLS_DL_URL="https://dl.google.com/android/repository/${ANDROID_SDK_TOOLS_ARCHIVE}"
6565

@@ -76,16 +76,14 @@ RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" \
7676
&& echo '### User Sources for Android SDK Manager' \
7777
> "${ANDROID_SDK_HOME}/.android/repositories.cfg"
7878

79-
# accept Android licenses (JDK necessary!)
79+
# Download and accept Android licenses (JDK necessary!)
8080
RUN ${RETRY} apt -y install -qq --no-install-recommends openjdk-8-jdk \
8181
&& apt -y autoremove
8282
RUN yes | "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" > /dev/null
83+
RUN yes | "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-27" > /dev/null
8384

84-
# download platforms, API, build tools
85-
RUN "${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-19" && \
86-
"${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "platforms;android-27" && \
87-
"${ANDROID_SDK_HOME}/tools/bin/sdkmanager" "build-tools;${ANDROID_SDK_BUILD_TOOLS_VERSION}" && \
88-
chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
85+
# Set avdmanager permissions (executable)
86+
RUN chmod +x "${ANDROID_SDK_HOME}/tools/bin/avdmanager"
8987

9088

9189
ENV USER="user"
@@ -96,7 +94,7 @@ ENV WORK_DIR="${HOME_DIR}" \
9694
# install system dependencies
9795
RUN ${RETRY} apt -y install -qq --no-install-recommends \
9896
python3 virtualenv python3-pip python3-venv \
99-
wget lbzip2 patch sudo \
97+
wget lbzip2 patch sudo python python-pip \
10098
&& apt -y autoremove
10199

102100
# build dependencies
@@ -124,8 +122,8 @@ RUN useradd --create-home --shell /bin/bash ${USER}
124122
RUN usermod -append --groups sudo ${USER}
125123
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
126124

127-
128-
RUN pip3 install --upgrade cython==0.28.6
125+
# install cython for python 2 (for python 3 it's inside the venv)
126+
RUN pip2 install --upgrade Cython==0.28.6
129127

130128
WORKDIR ${WORK_DIR}
131129
COPY --chown=user:user . ${WORK_DIR}
@@ -135,4 +133,5 @@ USER ${USER}
135133
# install python-for-android from current branch
136134
RUN virtualenv --python=python3 venv \
137135
&& . venv/bin/activate \
136+
&& pip3 install --upgrade Cython==0.28.6 \
138137
&& pip3 install -e .

ci/constants.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
class TargetPython(Enum):
55
python2 = 0
6-
python3crystax = 1
76
python3 = 2
87

98

@@ -22,7 +21,6 @@ class TargetPython(Enum):
2221
'ffpyplayer',
2322
'flask',
2423
'groestlcoin_hash',
25-
'hostpython3crystax',
2624
# https://github.com/kivy/python-for-android/issues/1354
2725
'kiwisolver',
2826
'libmysqlclient',
@@ -88,5 +86,5 @@ class TargetPython(Enum):
8886
# recipes that were already built will be skipped
8987
CORE_RECIPES = set([
9088
'pyjnius', 'kivy', 'openssl', 'requests', 'sqlite3', 'setuptools',
91-
'numpy', 'android', 'python2', 'python3',
89+
'numpy', 'android', 'hostpython2', 'hostpython3', 'python2', 'python3',
9290
])

ci/rebuild_updated_recipes.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from pythonforandroid.graph import get_recipe_order_and_bootstrap
2929
from pythonforandroid.toolchain import current_directory
3030
from pythonforandroid.util import BuildInterruptingException
31+
from pythonforandroid.recipe import Recipe
3132
from ci.constants import TargetPython, CORE_RECIPES, BROKEN_RECIPES
3233

3334

@@ -66,7 +67,7 @@ def build(target_python, requirements):
6667
# iterates to stream the output
6768
for line in sh.python(
6869
testapp, 'apk', '--sdk-dir', android_sdk_home,
69-
'--ndk-dir', android_ndk_home, '--bootstrap', 'sdl2', '--requirements',
70+
'--ndk-dir', android_ndk_home, '--requirements',
7071
requirements, _err_to_out=True, _iter=True):
7172
print(line)
7273

@@ -78,6 +79,18 @@ def main():
7879
recipes -= CORE_RECIPES
7980
logger.info('recipes to build: {}'.format(recipes))
8081
context = Context()
82+
83+
# removing the deleted recipes for the given target (if any)
84+
for recipe_name in recipes.copy():
85+
try:
86+
Recipe.get_recipe(recipe_name, context)
87+
except ValueError:
88+
# recipe doesn't exist, so probably we remove it
89+
recipes.remove(recipe_name)
90+
logger.warning(
91+
'removed {} from recipes because deleted'.format(recipe_name)
92+
)
93+
8194
# forces the default target
8295
recipes_and_target = recipes | set([target_python.name])
8396
try:

doc/source/apis.rst

+54
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,60 @@ Working on Android
55
This page gives details on accessing Android APIs and managing other
66
interactions on Android.
77

8+
Storage paths
9+
-------------
10+
11+
If you want to store and retrieve data, you shouldn't just save to
12+
the current directory, and not hardcode `/sdcard/` or some other
13+
path either - it might differ per device.
14+
15+
Instead, the `android` module which you can add to your `--requirements`
16+
allows you to query the most commonly required paths::
17+
18+
from android.storage import app_storage_path
19+
settings_path = app_storage_path()
20+
21+
from android.storage import primary_external_storage_path
22+
primary_ext_storage = primary_external_storage_path()
23+
24+
from android.storage import secondary_external_storage_path
25+
secondary_ext_storage = secondary_external_storage_path()
26+
27+
`app_storage_path()` gives you Android's so-called "internal storage"
28+
which is specific to your app and cannot seen by others or the user.
29+
It compares best to the AppData directory on Windows.
30+
31+
`primary_external_storage_path()` returns Android's so-called
32+
"primary external storage", often found at `/sdcard/` and potentially
33+
accessible to any other app.
34+
It compares best to the Documents directory on Windows.
35+
Requires `Permission.WRITE_EXTERNAL_STORAGE` to read and write to.
36+
37+
`secondary_external_storage_path()` returns Android's so-called
38+
"secondary external storage", often found at `/storage/External_SD/`.
39+
It compares best to an external disk plugged to a Desktop PC, and can
40+
after a device restart become inaccessible if removed.
41+
Requires `Permission.WRITE_EXTERNAL_STORAGE` to read and write to.
42+
43+
.. warning::
44+
Even if `secondary_external_storage_path` returns a path
45+
the external sd card may still not be present.
46+
Only non-empty contents or a successful write indicate that it is.
47+
48+
Read more on all the different storage types and what to use them for
49+
in the Android documentation:
50+
51+
https://developer.android.com/training/data-storage/files
52+
53+
A note on permissions
54+
~~~~~~~~~~~~~~~~~~~~~
55+
56+
Only the internal storage is always accessible with no additional
57+
permissions. For both primary and secondary external storage, you need
58+
to obtain `Permission.WRITE_EXTERNAL_STORAGE` **and the user may deny it.**
59+
Also, if you get it, both forms of external storage may only allow
60+
your app to write to the common pre-existing folders like "Music",
61+
"Documents", and so on. (see the Android Docs linked above for details)
862

963
Runtime permissions
1064
-------------------

doc/source/buildoptions.rst

+6-17
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,14 @@ e.g. ``--requirements=python3``.
3333

3434

3535
CrystaX python3
36-
###############
36+
~~~~~~~~~~~~~~~
3737

38-
.. warning:: python-for-android originally supported Python 3 using the CrystaX
39-
NDK. This support is now being phased out as CrystaX is no longer
40-
actively developed.
38+
python-for-android no longer supports building for Python 3 using the CrystaX
39+
NDK. Instead, use the python3 recipe, which can be built using the normal
40+
Google NDK.
4141

42-
.. note:: You must manually download the `CrystaX NDK
43-
<https://www.crystax.net/android/ndk>`__ and tell
44-
python-for-android to use it with ``--ndk-dir /path/to/NDK``.
45-
46-
Select this by adding the ``python3crystax`` recipe to your
47-
requirements, e.g. ``--requirements=python3crystax``.
48-
49-
This uses the prebuilt Python from the `CrystaX NDK
50-
<https://www.crystax.net/android/ndk>`__, a drop-in replacement for
51-
Google's official NDK which includes many improvements. You
52-
*must* use the CrystaX NDK 10.3.0 or higher when building with
53-
python3. You can get it `here
54-
<https://www.crystax.net/en/download>`__.
42+
.. note:: The last python-for-android version supporting CrystaX was `0.7.0.
43+
<https://github.com/kivy/python-for-android/archive/0.7.0.zip>`__
5544

5645
.. _bootstrap_build_options:
5746

0 commit comments

Comments
 (0)