Skip to content

Commit 45b410e

Browse files
Merge branch 'kivy:develop' into develop
2 parents 89bb823 + 4241e2f commit 45b410e

34 files changed

Lines changed: 786 additions & 247 deletions

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Keep GitHub Actions up to date with GitHub's Dependabot...
2+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
4+
version: 2
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
groups:
9+
github-actions:
10+
patterns:
11+
- "*" # Group all Actions updates into a single larger pull request
12+
schedule:
13+
interval: weekly

.github/workflows/custom-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
runs-on: ${{ github.event.inputs.os }}
6161
steps:
6262
- name: Checkout python-for-android
63-
uses: actions/checkout@v4
63+
uses: actions/checkout@v6
6464
- name: Pull the python-for-android docker image
6565
run: make docker/pull
6666
- name: Build python-for-android docker image
@@ -85,7 +85,7 @@ jobs:
8585
if [ -f dist/${{ env.AAB_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAB_ARTIFACT_FILENAME }} dist/${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-${{ env.AAB_ARTIFACT_FILENAME }}; fi
8686
if [ -f dist/${{ env.AAR_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAR_ARTIFACT_FILENAME }} dist/${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-${{ env.AAR_ARTIFACT_FILENAME }}; fi
8787
- name: Upload artifacts
88-
uses: actions/upload-artifact@v4
88+
uses: actions/upload-artifact@v7
8989
with:
9090
name: ${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-artifacts
9191
path: dist

.github/workflows/docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
docker:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
17-
- uses: docker/setup-buildx-action@v3
16+
- uses: actions/checkout@v6
17+
- uses: docker/setup-buildx-action@v4
1818
- run: make docker/build
1919
- name: docker login
2020
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')

.github/workflows/push.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout python-for-android
22-
uses: actions/checkout@v5
22+
uses: actions/checkout@v6
2323
- name: Set up Python 3.x
2424
uses: actions/setup-python@v6
2525
with:
@@ -35,14 +35,14 @@ jobs:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Checkout python-for-android
38-
uses: actions/checkout@v5
38+
uses: actions/checkout@v6
3939
- name: Set up Java 17
40-
uses: actions/setup-java@v4
40+
uses: actions/setup-java@v5
4141
with:
4242
distribution: 'temurin'
4343
java-version: '17'
4444
- name: Set up Gradle
45-
uses: gradle/actions/setup-gradle@v4
45+
uses: gradle/actions/setup-gradle@v6
4646
- name: Run Spotless check
4747
working-directory: pythonforandroid/bootstraps
4848
run: ./common/build/gradlew spotlessCheck
@@ -58,7 +58,7 @@ jobs:
5858
os: [ubuntu-latest, macos-latest]
5959
steps:
6060
- name: Checkout python-for-android
61-
uses: actions/checkout@v5
61+
uses: actions/checkout@v6
6262
- name: Set up Python ${{ matrix.python-version }}
6363
uses: actions/setup-python@v6
6464
with:
@@ -106,7 +106,7 @@ jobs:
106106
remove-codeql: 'true'
107107
remove-docker-images: 'true'
108108
- name: Checkout python-for-android
109-
uses: actions/checkout@v5
109+
uses: actions/checkout@v6
110110
- name: Relocate Docker data directory
111111
run: |
112112
sudo systemctl stop docker
@@ -137,7 +137,7 @@ jobs:
137137
if [ -f dist/${{ env.AAB_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAB_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}; fi
138138
if [ -f dist/${{ env.AAR_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAR_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAR_ARTIFACT_FILENAME }}; fi
139139
- name: Upload artifacts
140-
uses: actions/upload-artifact@v4
140+
uses: actions/upload-artifact@v7
141141
with:
142142
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-artifacts
143143
path: dist
@@ -163,7 +163,7 @@ jobs:
163163
ANDROID_NDK_HOME: ${HOME}/.android/android-ndk
164164
steps:
165165
- name: Checkout python-for-android
166-
uses: actions/checkout@v5
166+
uses: actions/checkout@v6
167167
- name: Set up Python 3.x
168168
uses: actions/setup-python@v6
169169
with:
@@ -191,7 +191,7 @@ jobs:
191191
if [ -f dist/${{ env.APK_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.APK_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}; fi
192192
if [ -f dist/${{ env.AAB_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAB_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}; fi
193193
- name: Upload artifacts
194-
uses: actions/upload-artifact@v4
194+
uses: actions/upload-artifact@v7
195195
with:
196196
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-artifacts
197197
path: dist
@@ -202,9 +202,9 @@ jobs:
202202
runs-on: ubuntu-latest
203203

204204
steps:
205-
- uses: actions/checkout@v5
205+
- uses: actions/checkout@v6
206206
- name: Download Artifacts
207-
uses: actions/download-artifact@v5
207+
uses: actions/download-artifact@v8
208208
with:
209209
name: ubuntu-latest-sdl2-artifacts
210210
path: dist/
@@ -239,7 +239,7 @@ jobs:
239239
remove-codeql: 'true'
240240
remove-docker-images: 'true'
241241
- name: Checkout python-for-android (all-history)
242-
uses: actions/checkout@v5
242+
uses: actions/checkout@v6
243243
with:
244244
fetch-depth: 0
245245
- name: Relocate Docker data directory
@@ -276,7 +276,7 @@ jobs:
276276
REBUILD_UPDATED_RECIPES_EXTRA_ARGS: --arch=${{ matrix.android_arch }}
277277
steps:
278278
- name: Checkout python-for-android (all-history)
279-
uses: actions/checkout@v5
279+
uses: actions/checkout@v6
280280
with:
281281
fetch-depth: 0
282282
- name: Set up Python 3.x
@@ -308,7 +308,7 @@ jobs:
308308
documentation:
309309
runs-on: ubuntu-latest
310310
steps:
311-
- uses: actions/checkout@v5
311+
- uses: actions/checkout@v6
312312
- name: Requirements
313313
run: |
314314
python -m pip install --upgrade pip

.github/workflows/pypi-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ jobs:
55
pypi_release:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v4
8+
- uses: actions/checkout@v6
99
- name: Set up Python 3.x
10-
uses: actions/setup-python@v5
10+
uses: actions/setup-python@v6
1111
with:
1212
python-version: '3.x'
1313
- name: Install dependencies
@@ -19,7 +19,7 @@ jobs:
1919
twine check dist/*
2020
- name: Publish package
2121
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
22-
uses: pypa/gh-action-pypi-publish@v1.13.0
22+
uses: pypa/gh-action-pypi-publish@v1.14.0
2323
with:
2424
user: __token__
2525
password: ${{ secrets.pypi_password }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It supports multiple CPU architectures.
1919

2020
It supports apps developed with [Kivy framework](http://kivy.org), but was
2121
built to be flexible about the backend libraries (through "bootstraps"), and
22-
also supports [PySDL2](https://pypi.org/project/PySDL2/), and a
22+
also supports [PySDL2](https://pypi.org/project/PySDL2/), [PySDL3](https://github.com/Aermoss/PySDL3) and a
2323
[WebView](https://developer.android.com/reference/android/webkit/WebView) with
2424
a Python web server.
2525

pythonforandroid/build.py

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import re
1212
import shutil
1313
import subprocess
14+
import sys
1415

1516
import sh
1617

@@ -21,7 +22,7 @@
2122
from pythonforandroid.archs import ArchARM, ArchARMv7_a, ArchAarch_64, Archx86, Archx86_64
2223
from pythonforandroid.logger import (info, warning, info_notify, info_main, shprint, Out_Style, Out_Fore)
2324
from pythonforandroid.pythonpackage import get_package_name
24-
from pythonforandroid.recipe import CythonRecipe, Recipe
25+
from pythonforandroid.recipe import CythonRecipe, Recipe, PyProjectRecipe
2526
from pythonforandroid.recommendations import (
2627
check_ndk_version, check_target_api, check_ndk_api,
2728
RECOMMENDED_NDK_API, RECOMMENDED_TARGET_API)
@@ -101,6 +102,14 @@ class Context:
101102

102103
java_build_tool = 'auto'
103104

105+
skip_prebuilt = False
106+
107+
extra_index_urls = []
108+
109+
use_prebuilt_version_for = []
110+
111+
save_wheel_dir = ''
112+
104113
@property
105114
def packages_path(self):
106115
'''Where packages are downloaded before being unpacked'''
@@ -503,6 +512,10 @@ def build_recipes(build_order, python_modules, ctx, project_dir,
503512
recipe.prepare_build_dir(arch.arch)
504513

505514
info_main('# Prebuilding recipes')
515+
# ensure we have `ctx.python_recipe` and `ctx.hostpython`
516+
Recipe.get_recipe("python3", ctx).prebuild_arch(arch)
517+
ctx.hostpython = Recipe.get_recipe("hostpython3", ctx).python_exe
518+
506519
# 2) prebuild packages
507520
for recipe in recipes:
508521
info_main('Prebuilding {} for {}'.format(recipe.name, arch.arch))
@@ -667,7 +680,17 @@ def is_wheel_platform_independent(whl_name):
667680
return all(tag.platform == "any" for tag in tags)
668681

669682

670-
def process_python_modules(ctx, modules):
683+
def is_wheel_compatible(whl_name, arch, ctx):
684+
name, version, build, tags = parse_wheel_filename(whl_name)
685+
supported_tags = PyProjectRecipe.get_wheel_platform_tags(arch.arch, ctx)
686+
supported_tags.append("any")
687+
result = all(tag.platform in supported_tags for tag in tags)
688+
if not result:
689+
warning(f"Incompatible module : {whl_name}")
690+
return result
691+
692+
693+
def process_python_modules(ctx, modules, arch):
671694
"""Use pip --dry-run to resolve dependencies and filter for pure-Python packages
672695
"""
673696
modules = list(modules)
@@ -702,22 +725,37 @@ def process_python_modules(ctx, modules):
702725

703726
# setup hostpython recipe
704727
env = environ.copy()
728+
host_recipe = None
705729
try:
706730
host_recipe = Recipe.get_recipe("hostpython3", ctx)
707-
_python_path = host_recipe.get_path_to_python()
708-
libdir = glob.glob(join(_python_path, "build", "lib*"))
709-
env['PYTHONPATH'] = host_recipe.site_dir + ":" + join(
710-
_python_path, "Modules") + ":" + (libdir[0] if libdir else "")
711731
pip = host_recipe.pip
712732
except Exception:
713-
# hostpython3 non available so we use system pip (like in tests)
733+
# hostpython3 is unavailable, so fall back to system pip
714734
pip = sh.Command("pip")
715735

736+
# add platform tags
737+
platforms = []
738+
tags = PyProjectRecipe.get_wheel_platform_tags(arch.arch, ctx)
739+
for tag in tags:
740+
platforms.append(f"--platform={tag}")
741+
742+
if host_recipe is not None:
743+
platforms.extend(["--python-version", host_recipe.version])
744+
else:
745+
# use the version of the currently running Python interpreter
746+
current_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
747+
platforms.extend(["--python-version", current_version])
748+
749+
indices = []
750+
# add extra index urls
751+
for index in ctx.extra_index_urls:
752+
indices.extend(["--extra-index-url", index])
716753
try:
717754
shprint(
718755
pip, 'install', *modules,
719756
'--dry-run', '--break-system-packages', '--ignore-installed',
720-
'--report', path, '-q', _env=env
757+
'--disable-pip-version-check', '--only-binary=:all:',
758+
'--report', path, '-q', *platforms, *indices, _env=env
721759
)
722760
except Exception as e:
723761
warning(f"Auto module resolution failed: {e}")
@@ -751,7 +789,9 @@ def process_python_modules(ctx, modules):
751789
filename = basename(module["download_info"]["url"])
752790
pure_python = True
753791

754-
if (filename.endswith(".whl") and not is_wheel_platform_independent(filename)):
792+
if (
793+
filename.endswith(".whl") and not is_wheel_compatible(filename, arch, ctx)
794+
):
755795
any_not_pure_python = True
756796
pure_python = False
757797

@@ -769,7 +809,7 @@ def process_python_modules(ctx, modules):
769809
)
770810

771811
if pure_python:
772-
processed_modules.append(f"{mname}=={mver}")
812+
processed_modules.append(module["download_info"]["url"])
773813
info(" ")
774814

775815
if any_not_pure_python:
@@ -793,7 +833,7 @@ def run_pymodules_install(ctx, arch, modules, project_dir=None,
793833

794834
info('*** PYTHON PACKAGE / PROJECT INSTALL STAGE FOR ARCH: {} ***'.format(arch))
795835

796-
modules = process_python_modules(ctx, modules)
836+
modules = process_python_modules(ctx, modules, arch)
797837

798838
modules = [m for m in modules if ctx.not_has_package(m, arch)]
799839

pythonforandroid/logger.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ def shprint(command, *args, **kwargs):
135135
kwargs["_out_bufsize"] = 1
136136
kwargs["_err_to_out"] = True
137137
kwargs["_bg"] = True
138+
139+
# silent mode
140+
silent = kwargs.get("silent", False)
141+
kwargs.pop("silent", False)
142+
if silent:
143+
kwargs["_out"] = None
144+
138145
is_critical = kwargs.pop('_critical', False)
139146
tail_n = kwargs.pop('_tail', None)
140147
full_debug = False
@@ -190,6 +197,11 @@ def shprint(command, *args, **kwargs):
190197
Err_Style.RESET_ALL, ' ', width=(columns - 1)))
191198
stdout.flush()
192199
except sh.ErrorReturnCode as err:
200+
if silent:
201+
if is_critical:
202+
exit(1)
203+
else:
204+
raise
193205
if need_closing_newline:
194206
stdout.write('{}\r{:>{width}}\r'.format(
195207
Err_Style.RESET_ALL, ' ', width=(columns - 1)))

0 commit comments

Comments
 (0)