Skip to content

Playing with on_device_unit_test_app #2046 #2073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b5f99e8
[recipes] Update Pillow to v7.0.0
opacam Feb 23, 2020
9eb5eb9
[recipes] Update freetype & add zlib support
opacam Feb 24, 2020
6137f31
[recipes] Update harfbuzz to v2.6.4
opacam Feb 24, 2020
e9a6f97
[testapp] Refactor (move) `PythonTestMixIn` into `tests.mixin`
opacam Dec 11, 2019
5aaf248
[testapp] Unify most of the test apps into one app
opacam Dec 15, 2019
5196451
[testapp] Make test app `on_device_unit_tests` the default...
opacam Dec 15, 2019
099b099
[testapp] Update docs
opacam Dec 15, 2019
692be94
[testapp] Enhance gh-actions with a matrix for our testapps
opacam Dec 18, 2019
86de274
[testapp] Fix typo errors and...
opacam Dec 29, 2019
f34566f
[testapp] Make a `flask` testapp...
opacam Dec 29, 2019
d86c2ff
Revert "[testapp] Make a `flask` testapp..."
opacam Dec 29, 2019
3dea1d1
[testapp] Remove `orientation` kwarg...
opacam Jan 2, 2020
ef50835
[testapp] Build test app for all archs
opacam Jan 6, 2020
cb17076
[testapp] Rename test app
opacam Jan 6, 2020
48a9475
[testapp] Fix a syntactical error at docstring
opacam Jan 18, 2020
b42643f
[testapp] Rename `setup_test_app.py` to `setup.py`
opacam Jan 18, 2020
9fca4b0
[testapp] Disable gh-actions `fail-fast`
opacam Feb 29, 2020
665be80
[testapp] Let's test `Pillow` recipe
opacam Feb 29, 2020
05ccb3a
Merge branch 'feature-update-pillow' into testing-testapps-rework
opacam Feb 29, 2020
7d61143
[archs] Add `-fPIC` to `CFLAGS` for Arch `x86_64`
opacam Mar 1, 2020
6666f8c
[testapp] Let's test `matplotlib` recipe
opacam Mar 1, 2020
25b3e3d
[recipes] Fix recipe `kiwisolver` (add `cppy`)
opacam Mar 1, 2020
5552fdc
[recipes] Fix `matplotlib` and update to `v3.1.3`
opacam Mar 1, 2020
4011073
[testapp] Add `KiwisolverTestCase`...
opacam Mar 1, 2020
f0bebfe
[testapp] Let's test `KiwisolverTestCase`
opacam Mar 1, 2020
a19ebe9
Merge branch 'hotfix-kiwisolver' into testing-testapps-rework
opacam Mar 1, 2020
185b660
Merge branch 'hotfix-matplotlib' into testing-testapps-rework
opacam Mar 1, 2020
e504d1b
[testapp] Let's be less demanding, remove `harfbuzz`
opacam Mar 1, 2020
3c60de3
Merge branch 'feature-update-freetype' into testing-testapps-rework
opacam Mar 1, 2020
489b7e9
[recipes] Fix misspelled word
opacam Mar 1, 2020
fef4a03
[recipes] Remove unneeded changes from the patch
opacam Mar 1, 2020
d47c04d
[recipes] Fix typo
opacam Mar 1, 2020
5032aa6
[testapp] Let's be brave now, re-add `harfbuzz`
opacam Mar 1, 2020
c0c3fa8
Merge branch 'hotfix-matplotlib' into testing-testapps-rework
opacam Mar 1, 2020
4182ad7
Merge branch 'feature-update-harfbuzz' into testing-testapps-rework
opacam Mar 1, 2020
fab33f5
[testapps] Remove `Pillow` and `harfbuzz`
opacam Mar 2, 2020
b2a7c05
[CI] Remove `matplotlib` from broken recipes
opacam Mar 2, 2020
484181f
[CI] Remove `matplotlib` from broken recipes
opacam Mar 4, 2020
32e6ccb
[recipes] Set library version dynamically for `*.pc.template`
opacam Mar 4, 2020
801ce4f
[recipes] Update `numpy` to v1.18.1 (add `cython` recipe)
opacam Mar 2, 2020
0b3cffc
[recipes] Move CI `numpy` tests to Python 3
opacam Mar 2, 2020
e473134
[recipes] Move CI `numpy` tests to Python 3 (linux)
opacam Mar 2, 2020
b943edc
Merge branch 'hotfix-matplotlib' into testing-testapps-rework
opacam Mar 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit tests & Build Testapp
name: Unit tests & build apps

on: ['push', 'pull_request']

Expand Down Expand Up @@ -42,25 +42,26 @@ jobs:
make test

build:
name: Build testapp
name: Unit test apk
needs: [flake8]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build-arch: ['arm64-v8a', 'armeabi-v7a']
build-arch: ['arm64-v8a', 'armeabi-v7a', 'x86_64', 'x86']
steps:
- name: Checkout python-for-android
uses: actions/checkout@v2
- name: Pull docker image
run: |
make docker/pull
- name: Build apk for Python 3 ${{ matrix.build-arch }}
- name: Build apk python3 ${{ matrix.build-arch }}
run: |
mkdir -p apks
make docker/run/make/with-artifact/testapps/python3/${{ matrix.build-arch }}
- uses: actions/upload-artifact@v1
with:
name: bdisttest_python3_sqlite_openssl_googlendk__${{ matrix.build-arch }}-debug-1.1.apk
name: unit_tests_app__python3-${{ matrix.build-arch }}-debug-1.1.apk
path: apks

rebuild_updated_recipes:
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
after_success:
- coveralls
- &testapps
name: Python 3 arm64-v8a
name: Python 3 arm64-v8a (with numpy)
stage: build testapps
before_script: make docker/pull
script: make docker/run/make/testapps/python3/arm64-v8a
Expand All @@ -61,7 +61,7 @@ jobs:
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
script: make testapps/python3/armeabi-v7a PYTHON_WITH_VERSION=python3
- <<: *testapps
name: Python 2 armeabi-v7a (with numpy)
name: Python 2 armeabi-v7a
script: make docker/run/make/testapps/python2/armeabi-v7a
- <<: *testapps
name: Rebuild updated recipes
Expand Down
34 changes: 13 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,18 @@ rebuild_updated_recipes: virtualenv
ANDROID_SDK_HOME=$(ANDROID_SDK_HOME) ANDROID_NDK_HOME=$(ANDROID_NDK_HOME) \
$(PYTHON) ci/rebuild_updated_recipes.py

testapps/python2/armeabi-v7a: virtualenv
. $(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,numpy

testapps/python3/arm64-v8a: virtualenv
. $(ACTIVATE) && cd testapps/ && \
python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--arch=arm64-v8a

testapps/python3/armeabi-v7a: virtualenv
. $(ACTIVATE) && cd testapps/ && \
python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sqlite3,setuptools \
--arch=armeabi-v7a
testapps/python2/%: virtualenv
$(eval $@_APP_ARCH := $(shell basename $*))
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
python setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--requirements sdl2,pyjnius,kivy,python2,openssl,requests,sqlite3,setuptools,numpy \
--arch=$($@_APP_ARCH)

testapps/python3/%: virtualenv
$(eval $@_APP_ARCH := $(shell basename $*))
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
python setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--arch=$($@_APP_ARCH)

clean:
find . -type d -name "__pycache__" -exec rm -r {} +
Expand Down Expand Up @@ -77,14 +74,9 @@ docker/run/make/%: docker/build
docker run --rm --env-file=.env $(DOCKER_IMAGE) make $*

docker/run/make/with-artifact/%: docker/build
ifeq (,$(findstring python3,$($*)))
$(eval $@_APP_NAME := bdisttest_python3_sqlite_openssl_googlendk)
else
$(eval $@_APP_NAME := bdisttest_python2_sqlite_openssl)
endif
$(eval $@_APP_ARCH := $(shell basename $*))
docker run --name p4a-latest --env-file=.env $(DOCKER_IMAGE) make $*
docker cp p4a-latest:/home/user/app/testapps/$($@_APP_NAME)__$($@_APP_ARCH)-debug-1.1-.apk ./apks
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app__$($@_APP_ARCH)-debug-1.1-.apk ./apks
docker rm -fv p4a-latest

docker/run/shell: docker/build
Expand Down
2 changes: 0 additions & 2 deletions ci/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class TargetPython(Enum):
'websocket-client',
'zeroconf',
'zope',
'matplotlib', # https://github.com/kivy/python-for-android/issues/1900
])
BROKEN_RECIPES_PYTHON3 = set([
'brokenrecipe',
Expand All @@ -74,7 +73,6 @@ class TargetPython(Enum):
# mpmath package with a version >= 0.19 required
'sympy',
'vlc',
'matplotlib', # https://github.com/kivy/python-for-android/issues/1900
])

BROKEN_RECIPES = {
Expand Down
7 changes: 2 additions & 5 deletions ci/rebuild_updated_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ def build(target_python, requirements):
"""
if not requirements:
return
testapp = 'setup_testapp_python2.py'
android_sdk_home = os.environ['ANDROID_SDK_HOME']
android_ndk_home = os.environ['ANDROID_NDK_HOME']
if target_python == TargetPython.python3:
testapp = 'setup_testapp_python3_sqlite_openssl.py'
requirements.add(target_python.name)
requirements = ','.join(requirements)
logger.info('requirements: {}'.format(requirements))
with current_directory('testapps/'):
with current_directory('testapps/on_device_unit_tests/'):
# iterates to stream the output
for line in sh.python(
testapp, 'apk', '--sdk-dir', android_sdk_home,
'setup.py', 'apk', '--sdk-dir', android_sdk_home,
'--ndk-dir', android_ndk_home, '--requirements',
requirements, _err_to_out=True, _iter=True):
print(line)
Expand Down
28 changes: 14 additions & 14 deletions doc/source/testing_pull_requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,31 @@ Using python-for-android commands directly from the pull request files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Enter inside the directory of the cloned repository in the above
step and run p4a command with proper args, eg::
step and run p4a command with proper args, eg (to test an modified
`pycryptodome` recipe)::

.. codeblock:: bash

cd p4a-feature-fix-numpy
PYTHONPATH=. python3 -m pythonforandroid.toolchain apk \
--private=testapps/testapp_sqlite_openssl \
--dist-name=dist_test_app_python3_libs \
--private=testapps/on_device_unit_tests/test_app \
--dist-name=dist_unit_tests_app_pycryptodome \
--package=org.kivy \
--name=test_app_python3_sqlite_openssl \
--name=unit_tests_app_pycryptodome \
--version=0.1 \
--requirements=requests,peewee,sdl2,pyjnius,kivy,python3 \
--requirements=sdl2,pyjnius,kivy,python3,pycryptodome \
--ndk-dir=/media/DEVEL/Android/android-ndk-r20 \
--sdk-dir=/media/DEVEL/Android/android-sdk-linux \
--android-api=27 \
--arch=arm64-v8a \
--permission=INTERNET \
--permission=VIBRATE \
--debug

Things that you should know:


- The example above will build an testapp we will make use of the files of
the testapp named `testapp_sqlite_openssl.py` but we don't use the setup
- The example above will build an test app we will make use of the files of
the `on device unit tests` test app but we don't use the setup
file to build it so we must tell python-for-android what we want via
arguments
- be sure to at least edit the following arguments when running the above
Expand Down Expand Up @@ -159,19 +160,19 @@ Installing python-for-android using the github's branch of the pull request
cd p4a-feature-fix-numpy
pip3 install . --upgrade --user

- Now, go inside the `testapps` directory (we assume that you still are inside
the cloned repository)::
- Now, go inside the `testapps/on_device_unit_tests` directory (we assume that
you still are inside the cloned repository)::

.. codeblock:: bash

cd testapps
cd testapps/on_device_unit_tests

- Run the build of the apk via the freshly installed copy of python-for-android
by running a similar command than below::

.. code-block:: bash

python3 setup_testapp_python3_sqlite_openssl.py apk \
python3 setup.py apk \
--ndk-dir=/media/DEVEL/Android/android-ndk-r20 \
--sdk-dir=/media/DEVEL/Android/android-sdk-linux \
--android-api=27 \
Expand All @@ -182,8 +183,7 @@ Installing python-for-android using the github's branch of the pull request
Things that you should know:

- In the example above, we override some variables that are set in
`setup_testapp_python3_sqlite_openssl.py`, you could also override them
by editing this file
`setup.py`, you could also override them by editing this file
- be sure to at least edit the following arguments when running the above
command, since the default set in there it's unlikely that match your
installation:
Expand Down
1 change: 1 addition & 0 deletions pythonforandroid/archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class Archx86_64(Arch):
'-mpopcnt',
'-m64',
'-mtune=intel',
'-fPIC',
]


Expand Down
17 changes: 17 additions & 0 deletions pythonforandroid/recipes/cppy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pythonforandroid.recipe import PythonRecipe


class CppyRecipe(PythonRecipe):
site_packages_name = 'cppy'

# Pin to commit: `Nucleic migration and project documentation`,
# because the official releases are too old, at time of writing
version = '4e0b956'
url = 'https://github.com/nucleic/cppy/archive/{version}.zip'
call_hostpython_via_targetpython = False
# to be detected by the matplotlib install script
install_in_hostpython = True
depends = ['setuptools']


recipe = CppyRecipe()
14 changes: 14 additions & 0 deletions pythonforandroid/recipes/cython/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pythonforandroid.recipe import CompiledComponentsPythonRecipe


class CythonRecipe(CompiledComponentsPythonRecipe):

version = '0.29.15'
url = 'https://github.com/cython/cython/archive/{version}.tar.gz'
site_packages_name = 'cython'
depends = ['setuptools']
call_hostpython_via_targetpython = False
install_in_hostpython = True


recipe = CythonRecipe()
33 changes: 25 additions & 8 deletions pythonforandroid/recipes/freetype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FreetypeRecipe(Recipe):
https://sourceforge.net/projects/freetype/files/freetype2/2.5.3/
"""

version = '2.5.5'
version = '2.10.1'
url = 'http://download.savannah.gnu.org/releases/freetype/freetype-{version}.tar.gz' # noqa
built_libraries = {'libfreetype.so': 'objs/.libs'}

Expand All @@ -35,9 +35,6 @@ def get_recipe_env(self, arch=None, with_harfbuzz=False):
'harfbuzz', self.ctx
).get_build_dir(arch.arch)
freetype_install = join(self.get_build_dir(arch.arch), 'install')
env['CFLAGS'] = ' '.join(
[env['CFLAGS'], '-DFT_CONFIG_OPTION_USE_HARFBUZZ']
)

env['HARFBUZZ_CFLAGS'] = '-I{harfbuzz} -I{harfbuzz}/src'.format(
harfbuzz=harfbuzz_build
Expand All @@ -48,6 +45,19 @@ def get_recipe_env(self, arch=None, with_harfbuzz=False):
freetype=freetype_install, harfbuzz=harfbuzz_build
)
)

# android's zlib support
zlib_lib_path = join(self.ctx.ndk_platform, 'usr', 'lib')
zlib_includes = join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include')

def add_flag_if_not_added(flag, env_key):
if flag not in env[env_key]:
env[env_key] += flag

add_flag_if_not_added(' -I' + zlib_includes, 'CFLAGS')
add_flag_if_not_added(' -L' + zlib_lib_path, 'LDFLAGS')
add_flag_if_not_added(' -lz', 'LDLIBS')

return env

def build_arch(self, arch, with_harfbuzz=False):
Expand All @@ -66,14 +76,17 @@ def build_arch(self, arch, with_harfbuzz=False):
config_args = {
'--host={}'.format(arch.command_prefix),
'--prefix={}'.format(prefix_path),
'--without-zlib',
'--without-bzip2',
'--with-png=no',
}
if not harfbuzz_in_recipes:
info('Build freetype (without harfbuzz)')
config_args = config_args.union(
{'--disable-static', '--enable-shared', '--with-harfbuzz=no'}
{'--disable-static',
'--enable-shared',
'--with-harfbuzz=no',
'--with-zlib=yes',
}
)
elif not with_harfbuzz:
info('Build freetype for First time (without harfbuzz)')
Expand All @@ -82,12 +95,16 @@ def build_arch(self, arch, with_harfbuzz=False):
# symbols/functions, so we avoid to have two freetype shared
# libraries which will be confusing and harder to link with them
config_args = config_args.union(
{'--disable-shared', '--with-harfbuzz=no'}
{'--disable-shared', '--with-harfbuzz=no', '--with-zlib=no'}
)
else:
info('Build freetype for Second time (with harfbuzz)')
config_args = config_args.union(
{'--disable-static', '--enable-shared', '--with-harfbuzz=yes'}
{'--disable-static',
'--enable-shared',
'--with-harfbuzz=yes',
'--with-zlib=yes',
}
)
info('Configure args are:\n\t-{}'.format('\n\t-'.join(config_args)))

Expand Down
10 changes: 6 additions & 4 deletions pythonforandroid/recipes/harfbuzz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class HarfbuzzRecipe(Recipe):
https://sourceforge.net/projects/freetype/files/freetype2/2.5.3/
"""

version = '0.9.40'
url = 'http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-{version}.tar.bz2' # noqa
version = '2.6.4'
url = 'http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-{version}.tar.xz' # noqa
opt_depends = ['freetype']
built_libraries = {'libharfbuzz.so': 'src/.libs'}

Expand Down Expand Up @@ -50,15 +50,17 @@ def build_arch(self, arch):
configure = sh.Command('./configure')
shprint(
configure,
'--without-icu',
'--host={}'.format(arch.command_prefix),
'--prefix={}'.format(self.get_build_dir(arch.arch)),
'--with-freetype={}'.format(
'yes'
if 'freetype' in self.ctx.recipe_build_order
else 'no'
),
'--without-glib',
'--with-icu=no',
'--with-cairo=no',
'--with-fontconfig=no',
'--with-glib=no',
_env=env,
)
shprint(sh.make, '-j', str(cpu_count()), _env=env)
Expand Down
25 changes: 22 additions & 3 deletions pythonforandroid/recipes/kiwisolver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@

class KiwiSolverRecipe(CppCompiledComponentsPythonRecipe):
site_packages_name = 'kiwisolver'
version = '0.1.3'
url = 'https://github.com/nucleic/kiwi/archive/master.zip'
depends = ['setuptools']
# Pin to commit `docs: attempt to fix doc building`, the latest one
# at the time of writing, just to be sure that we have te most up to date
# version, but it should be pinned to an official release once the c++
# changes that we want to include are merged to master branch
# Note: the commit we want to include is
# `Cppy use update and c++11 compatibility` (4858730)
version = '0846189'
url = 'https://github.com/nucleic/kiwi/archive/{version}.zip'
depends = ['cppy']

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super().get_recipe_env(arch, with_flags_in_cc)
if self.need_stl_shared:
# kiwisolver compile flags does not honor the standard flags:
# `CPPFLAGS` and `LDLIBS`, so we put in `CFLAGS` and `LDFLAGS` to
# correctly link with the `c++_shared` library
env['CFLAGS'] += f' -I{self.stl_include_dir}'
env['CFLAGS'] += ' -frtti -fexceptions'

env['LDFLAGS'] += f' -L{self.get_stl_lib_dir(arch)}'
env['LDFLAGS'] += f' -l{self.stl_lib_name}'
return env


recipe = KiwiSolverRecipe()
Loading