Skip to content

Support multiarch in webview bootstrap #2596

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

Merged
merged 2 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
92 changes: 59 additions & 33 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ jobs:
flag-name: run-${{ matrix.os }}-${{ matrix.python-version }}

ubuntu_build_apk:
name: Unit test apk [ ${{ matrix.runs_on }} ]
name: Unit test apk [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
needs: [flake8]
runs-on: ${{ matrix.runs_on }}
continue-on-error: true
strategy:
matrix:
include:
- runs_on: ubuntu-latest
runs_on: [ubuntu-latest]
bootstrap:
- name: sdl2
target: testapps-with-numpy
- name: webview
target: testapps-webview
steps:
- name: Checkout python-for-android
uses: actions/checkout@v2
Expand All @@ -78,26 +83,33 @@ jobs:
- name: Build multi-arch apk Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
run: |
mkdir -p apks
make docker/run/make/with-artifact/apk/testapps-with-numpy
- name: Rename artifact to include the build platform name
make docker/run/make/with-artifact/apk/${{ matrix.bootstrap.target }}
- name: Rename apk artifact to include the build platform name
run: |
mv apks/${{ env.APK_ARTIFACT_FILENAME }} apks/${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
- uses: actions/upload-artifact@v1
mv apks/${{ env.APK_ARTIFACT_FILENAME }} apks/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
- name: Upload apk artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
path: apks
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
path: apks/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}

macos_build_apk:
name: Unit test apk [ ${{ matrix.runs_on }} ]
name: Unit test apk [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
needs: [flake8]
defaults:
run:
shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
runs-on: ${{ matrix.runs_on }}
continue-on-error: true
strategy:
matrix:
runs_on: [macos-latest, apple-silicon-m1]
bootstrap:
- name: sdl2
target: testapps-with-numpy
- name: webview
target: testapps-webview
include:
- runs_on: macos-latest
- runs_on: apple-silicon-m1
run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
env:
Expand Down Expand Up @@ -127,23 +139,29 @@ jobs:
run: |
source ci/osx_ci.sh
arm64_set_path_and_python_version 3.9.7
make testapps-with-numpy
- name: Rename artifact to include the build platform name
make ${{ matrix.bootstrap.target }}
- name: Rename apk artifact to include the build platform name
run: |
mv testapps/on_device_unit_tests/${{ env.APK_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
- uses: actions/upload-artifact@v1
mv testapps/on_device_unit_tests/${{ env.APK_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
- name: Upload apk artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
path: ${{ matrix.runs_on }}-${{ env.APK_ARTIFACT_FILENAME }}
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}
path: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}

ubuntu_build_aab:
name: Unit test aab [ ${{ matrix.runs_on }} ]
needs: [flake8]
runs-on: ${{ matrix.runs_on }}
continue-on-error: true
strategy:
matrix:
include:
- runs_on: ubuntu-latest
runs_on: [ubuntu-latest]
bootstrap:
- name: sdl2
target: testapps-with-numpy-aab
- name: webview
target: testapps-webview-aab
steps:
- name: Checkout python-for-android
uses: actions/checkout@v2
Expand All @@ -162,26 +180,33 @@ jobs:
- name: Build Android App Bundle Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
run: |
mkdir -p aabs
make docker/run/make/with-artifact/aab/testapps-with-numpy-aab
make docker/run/make/with-artifact/aab/${{ matrix.bootstrap.target }}
- name: Rename artifact to include the build platform name
run: |
mv aabs/${{ env.AAB_ARTIFACT_FILENAME }} aabs/${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
- uses: actions/upload-artifact@v1
mv aabs/${{ env.AAB_ARTIFACT_FILENAME }} aabs/${{ matrix.runs_on }}-${{ matrix.bootstrap.name}}-${{ env.AAB_ARTIFACT_FILENAME }}
- name: Upload apk artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
path: aabs
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name}}-${{ env.AAB_ARTIFACT_FILENAME }}
path: aabs/${{ matrix.runs_on }}-${{ matrix.bootstrap.name}}-${{ env.AAB_ARTIFACT_FILENAME }}

macos_build_aab:
name: Unit test aab [ ${{ matrix.runs_on }} ]
name: Unit test aab [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
needs: [flake8]
defaults:
run:
shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
runs-on: ${{ matrix.runs_on }}
continue-on-error: true
strategy:
matrix:
runs_on: [macos-latest, apple-silicon-m1]
bootstrap:
- name: sdl2
target: testapps-with-numpy-aab
- name: webview
target: testapps-webview-aab
include:
- runs_on: macos-latest
- runs_on: apple-silicon-m1
run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
env:
Expand All @@ -207,18 +232,19 @@ jobs:
source ci/osx_ci.sh
arm64_set_path_and_python_version 3.9.7
make --file ci/makefiles/osx.mk
- name: Build multi-arch aab Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
- name: Build multi-arch sdl2 aab Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
run: |
source ci/osx_ci.sh
arm64_set_path_and_python_version 3.9.7
make testapps-with-numpy-aab
- name: Rename artifact to include the build platform name
make ${{ matrix.bootstrap.target }}
- name: Rename sdl2 artifact to include the build platform name
run: |
mv testapps/on_device_unit_tests/${{ env.AAB_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
- uses: actions/upload-artifact@v1
mv testapps/on_device_unit_tests/${{ env.AAB_ARTIFACT_FILENAME }} ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}
- name: Upload sdl2 apk artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
path: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}
path: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}

ubuntu_rebuild_updated_recipes:
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ubuntu-latest ]
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ testapps-with-numpy-aab: virtualenv
--requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,urllib3,chardet,idna,sqlite3,setuptools,numpy \
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86 --release

testapps-webview: virtualenv
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
python setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--bootstrap webview \
--requirements sqlite3,libffi,openssl,pyjnius,flask,python3,genericndkbuild \
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86

testapps-webview-aab: virtualenv
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
python setup.py aab --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--bootstrap webview \
--requirements sqlite3,libffi,openssl,pyjnius,flask,python3,genericndkbuild \
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86 --release

testapps/%: virtualenv
$(eval $@_APP_ARCH := $(shell basename $*))
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
Expand Down
25 changes: 11 additions & 14 deletions pythonforandroid/bootstraps/webview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,28 @@ def assemble_distribution(self):
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

arch = self.ctx.archs[0]
if len(self.ctx.archs) > 1:
raise ValueError('built for more than one arch, but bootstrap cannot handle that yet')
info('Bootstrap running with arch {}'.format(arch))

with current_directory(self.dist_dir):
info('Copying python distribution')

self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
self.distribute_aars(arch)
self.distribute_javaclasses(self.ctx.javaclass_dir,
dest_dir=join("src", "main", "java"))

python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle')
ensure_dir(python_bundle_dir)
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
join(self.dist_dir, python_bundle_dir), arch)
for arch in self.ctx.archs:
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
self.distribute_aars(arch)

python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle')
ensure_dir(python_bundle_dir)
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
join(self.dist_dir, python_bundle_dir), arch)
if not self.ctx.with_debug_symbols:
self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)

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

if not self.ctx.with_debug_symbols:
self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super().assemble_distribution()


Expand Down