Skip to content

Commit b7146e8

Browse files
authored
Support multiarch in webview bootstrap (#2596)
* Support multiarch in webview bootstrap This is essentially exactly the same as what the sdl2 bootstrap is doing. * Add webview app make targets and artifact builds This should help exercise the webview bootstrap in CI and allow testing a webview app using the built artifacts.
1 parent 71c237f commit b7146e8

File tree

3 files changed

+84
-47
lines changed

3 files changed

+84
-47
lines changed

.github/workflows/push.yml

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,18 @@ jobs:
5353
flag-name: run-${{ matrix.os }}-${{ matrix.python-version }}
5454

5555
ubuntu_build_apk:
56-
name: Unit test apk [ ${{ matrix.runs_on }} ]
56+
name: Unit test apk [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
5757
needs: [flake8]
5858
runs-on: ${{ matrix.runs_on }}
59+
continue-on-error: true
5960
strategy:
6061
matrix:
61-
include:
62-
- runs_on: ubuntu-latest
62+
runs_on: [ubuntu-latest]
63+
bootstrap:
64+
- name: sdl2
65+
target: testapps-with-numpy
66+
- name: webview
67+
target: testapps-webview
6368
steps:
6469
- name: Checkout python-for-android
6570
uses: actions/checkout@v2
@@ -78,26 +83,33 @@ jobs:
7883
- name: Build multi-arch apk Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
7984
run: |
8085
mkdir -p apks
81-
make docker/run/make/with-artifact/apk/testapps-with-numpy
82-
- name: Rename artifact to include the build platform name
86+
make docker/run/make/with-artifact/apk/${{ matrix.bootstrap.target }}
87+
- name: Rename apk artifact to include the build platform name
8388
run: |
84-
mv apks/${{ env.APK_ARTIFACT_FILENAME }} apks/${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
85-
- uses: actions/upload-artifact@v1
89+
mv apks/${{ env.APK_ARTIFACT_FILENAME }} apks/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
90+
- name: Upload apk artifact
91+
uses: actions/upload-artifact@v1
8692
with:
87-
name: ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
88-
path: apks
93+
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
94+
path: apks/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
8995

9096
macos_build_apk:
91-
name: Unit test apk [ ${{ matrix.runs_on }} ]
97+
name: Unit test apk [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
9298
needs: [flake8]
9399
defaults:
94100
run:
95101
shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
96102
runs-on: ${{ matrix.runs_on }}
103+
continue-on-error: true
97104
strategy:
98105
matrix:
106+
runs_on: [macos-latest, apple-silicon-m1]
107+
bootstrap:
108+
- name: sdl2
109+
target: testapps-with-numpy
110+
- name: webview
111+
target: testapps-webview
99112
include:
100-
- runs_on: macos-latest
101113
- runs_on: apple-silicon-m1
102114
run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
103115
env:
@@ -127,23 +139,29 @@ jobs:
127139
run: |
128140
source ci/osx_ci.sh
129141
arm64_set_path_and_python_version 3.9.7
130-
make testapps-with-numpy
131-
- name: Rename artifact to include the build platform name
142+
make ${{ matrix.bootstrap.target }}
143+
- name: Rename apk artifact to include the build platform name
132144
run: |
133-
mv testapps/on_device_unit_tests/${{ env.APK_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
134-
- uses: actions/upload-artifact@v1
145+
mv testapps/on_device_unit_tests/${{ env.APK_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
146+
- name: Upload apk artifact
147+
uses: actions/upload-artifact@v1
135148
with:
136-
name: ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
137-
path: ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
149+
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
150+
path: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
138151

139152
ubuntu_build_aab:
140153
name: Unit test aab [ ${{ matrix.runs_on }} ]
141154
needs: [flake8]
142155
runs-on: ${{ matrix.runs_on }}
156+
continue-on-error: true
143157
strategy:
144158
matrix:
145-
include:
146-
- runs_on: ubuntu-latest
159+
runs_on: [ubuntu-latest]
160+
bootstrap:
161+
- name: sdl2
162+
target: testapps-with-numpy-aab
163+
- name: webview
164+
target: testapps-webview-aab
147165
steps:
148166
- name: Checkout python-for-android
149167
uses: actions/checkout@v2
@@ -162,26 +180,33 @@ jobs:
162180
- name: Build Android App Bundle Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
163181
run: |
164182
mkdir -p aabs
165-
make docker/run/make/with-artifact/aab/testapps-with-numpy-aab
183+
make docker/run/make/with-artifact/aab/${{ matrix.bootstrap.target }}
166184
- name: Rename artifact to include the build platform name
167185
run: |
168-
mv aabs/${{ env.AAB_ARTIFACT_FILENAME }} aabs/${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
169-
- uses: actions/upload-artifact@v1
186+
mv aabs/${{ env.AAB_ARTIFACT_FILENAME }} aabs/${{ matrix.runs_on }}-${{ matrix.bootstrap.name}}-${{ env.AAB_ARTIFACT_FILENAME }}
187+
- name: Upload apk artifact
188+
uses: actions/upload-artifact@v1
170189
with:
171-
name: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
172-
path: aabs
190+
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name}}-${{ env.AAB_ARTIFACT_FILENAME }}
191+
path: aabs/${{ matrix.runs_on }}-${{ matrix.bootstrap.name}}-${{ env.AAB_ARTIFACT_FILENAME }}
173192

174193
macos_build_aab:
175-
name: Unit test aab [ ${{ matrix.runs_on }} ]
194+
name: Unit test aab [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
176195
needs: [flake8]
177196
defaults:
178197
run:
179198
shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
180199
runs-on: ${{ matrix.runs_on }}
200+
continue-on-error: true
181201
strategy:
182202
matrix:
203+
runs_on: [macos-latest, apple-silicon-m1]
204+
bootstrap:
205+
- name: sdl2
206+
target: testapps-with-numpy-aab
207+
- name: webview
208+
target: testapps-webview-aab
183209
include:
184-
- runs_on: macos-latest
185210
- runs_on: apple-silicon-m1
186211
run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
187212
env:
@@ -207,18 +232,19 @@ jobs:
207232
source ci/osx_ci.sh
208233
arm64_set_path_and_python_version 3.9.7
209234
make --file ci/makefiles/osx.mk
210-
- name: Build multi-arch aab Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
235+
- name: Build multi-arch sdl2 aab Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
211236
run: |
212237
source ci/osx_ci.sh
213238
arm64_set_path_and_python_version 3.9.7
214-
make testapps-with-numpy-aab
215-
- name: Rename artifact to include the build platform name
239+
make ${{ matrix.bootstrap.target }}
240+
- name: Rename sdl2 artifact to include the build platform name
216241
run: |
217-
mv testapps/on_device_unit_tests/${{ env.AAB_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
218-
- uses: actions/upload-artifact@v1
242+
mv testapps/on_device_unit_tests/${{ env.AAB_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}
243+
- name: Upload sdl2 apk artifact
244+
uses: actions/upload-artifact@v1
219245
with:
220-
name: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
221-
path: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
246+
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}
247+
path: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}
222248

223249
ubuntu_rebuild_updated_recipes:
224250
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ubuntu-latest ]

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ testapps-with-numpy-aab: virtualenv
4747
--requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,urllib3,chardet,idna,sqlite3,setuptools,numpy \
4848
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86 --release
4949

50+
testapps-webview: virtualenv
51+
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
52+
python setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
53+
--bootstrap webview \
54+
--requirements sqlite3,libffi,openssl,pyjnius,flask,python3,genericndkbuild \
55+
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86
56+
57+
testapps-webview-aab: virtualenv
58+
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
59+
python setup.py aab --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
60+
--bootstrap webview \
61+
--requirements sqlite3,libffi,openssl,pyjnius,flask,python3,genericndkbuild \
62+
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86 --release
63+
5064
testapps/%: virtualenv
5165
$(eval $@_APP_ARCH := $(shell basename $*))
5266
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \

pythonforandroid/bootstraps/webview/__init__.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,28 @@ def assemble_distribution(self):
2121
with open('local.properties', 'w') as fileh:
2222
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))
2323

24-
arch = self.ctx.archs[0]
25-
if len(self.ctx.archs) > 1:
26-
raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
27-
info('Bootstrap running with arch {}'.format(arch))
28-
2924
with current_directory(self.dist_dir):
3025
info('Copying python distribution')
3126

32-
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
33-
self.distribute_aars(arch)
3427
self.distribute_javaclasses(self.ctx.javaclass_dir,
3528
dest_dir=join("src", "main", "java"))
3629

37-
python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle')
38-
ensure_dir(python_bundle_dir)
39-
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
40-
join(self.dist_dir, python_bundle_dir), arch)
30+
for arch in self.ctx.archs:
31+
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
32+
self.distribute_aars(arch)
33+
34+
python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle')
35+
ensure_dir(python_bundle_dir)
36+
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
37+
join(self.dist_dir, python_bundle_dir), arch)
38+
if not self.ctx.with_debug_symbols:
39+
self.strip_libraries(arch)
40+
self.fry_eggs(site_packages_dir)
4141

4242
if 'sqlite3' not in self.ctx.recipe_build_order:
4343
with open('blacklist.txt', 'a') as fileh:
4444
fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')
4545

46-
if not self.ctx.with_debug_symbols:
47-
self.strip_libraries(arch)
48-
self.fry_eggs(site_packages_dir)
4946
super().assemble_distribution()
5047

5148

0 commit comments

Comments
 (0)