Skip to content

Commit 2ebea90

Browse files
authored
Update: numpy, pandas, sdl2 to newer versions which support ndk28c (kivy#3164)
1 parent a8f2ca1 commit 2ebea90

File tree

16 files changed

+55
-36
lines changed

16 files changed

+55
-36
lines changed

ci/makefiles/android.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Downloads and installs the Android SDK depending on supplied platform: darwin or linux
22

33
# Those android NDK/SDK variables can be override when running the file
4-
ANDROID_NDK_VERSION ?= 25b
4+
ANDROID_NDK_VERSION ?= 28c
55
ANDROID_NDK_VERSION_LEGACY ?= 21e
66
ANDROID_SDK_TOOLS_VERSION ?= 6514223
77
ANDROID_SDK_BUILD_TOOLS_VERSION ?= 29.0.3
88
ANDROID_HOME ?= $(HOME)/.android
9-
ANDROID_API_LEVEL ?= 35
9+
ANDROID_API_LEVEL ?= 36
1010

1111
# per OS dictionary-like
1212
UNAME_S := $(shell uname -s)

doc/source/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ named ``tools``, and you will need to run extra commands to install
119119
the SDK packages needed.
120120

121121
For Android NDK, note that modern releases will only work on a 64-bit
122-
operating system. **The minimal, and recommended, NDK version to use is r25b:**
122+
operating system. **The minimal, and recommended, NDK version to use is r28c:**
123123

124124
- `Go to ndk downloads page <https://developer.android.com/ndk/downloads/>`_
125125
- Windows users should create a virtual machine with an GNU Linux os
@@ -154,7 +154,7 @@ variables necessary for building on android::
154154
# Adjust the paths!
155155
export ANDROIDSDK="$HOME/Documents/android-sdk-27"
156156
export ANDROIDNDK="$HOME/Documents/android-ndk-r23b"
157-
export ANDROIDAPI="27" # Target API version of your application
157+
export ANDROIDAPI="36" # Target API version of your application
158158
export NDKAPI="21" # Minimum supported API version of your application
159159
export ANDROIDNDKVER="r10e" # Version of the NDK you installed
160160

doc/source/testing_pull_requests.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Using python-for-android commands directly from the pull request files
118118
--requirements=sdl2,pyjnius,kivy,python3,pycryptodome \
119119
--ndk-dir=/media/DEVEL/Android/android-ndk-r20 \
120120
--sdk-dir=/media/DEVEL/Android/android-sdk-linux \
121-
--android-api=27 \
121+
--android-api=36 \
122122
--arch=arm64-v8a \
123123
--permission=VIBRATE \
124124
--debug
@@ -175,7 +175,7 @@ Installing python-for-android using the github's branch of the pull request
175175
python3 setup.py apk \
176176
--ndk-dir=/media/DEVEL/Android/android-ndk-r20 \
177177
--sdk-dir=/media/DEVEL/Android/android-sdk-linux \
178-
--android-api=27 \
178+
--android-api=36 \
179179
--arch=arm64-v8a \
180180
--debug
181181

pythonforandroid/recipe.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ class Recipe(metaclass=RecipeMeta):
155155
starting from NDK r18 the `gnustl_shared` lib has been deprecated.
156156
'''
157157

158+
min_ndk_api_support = 20
159+
'''
160+
Minimum ndk api recipe will support.
161+
'''
162+
158163
def get_stl_library(self, arch):
159164
return join(
160165
arch.ndk_lib_dir,
@@ -375,6 +380,9 @@ def get_recipe_dir(self):
375380
# Public Recipe API to be subclassed if needed
376381

377382
def download_if_necessary(self):
383+
if self.ctx.ndk_api < self.min_ndk_api_support:
384+
error(f"In order to build '{self.name}', you must set minimum ndk api (minapi) to `{self.min_ndk_api_support}`.\n")
385+
exit(1)
378386
info_main('Downloading {}'.format(self.name))
379387
user_dir = environ.get('P4A_{}_DIR'.format(self.name.lower()))
380388
if user_dir is not None:

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from pythonforandroid.recipe import Recipe, MesonRecipe
2-
from pythonforandroid.logger import error
32
from os.path import join
43
import shutil
54

65
NUMPY_NDK_MESSAGE = "In order to build numpy, you must set minimum ndk api (minapi) to `24`.\n"
76

87

98
class NumpyRecipe(MesonRecipe):
10-
version = 'v1.26.5'
9+
version = 'v2.3.0'
1110
url = 'git+https://github.com/numpy/numpy'
12-
hostpython_prerequisites = ["Cython>=3.0.6"] # meson does not detects venv's cython
11+
hostpython_prerequisites = ["Cython>=3.0.6", "numpy"] # meson does not detects venv's cython
1312
extra_build_args = ['-Csetup-args=-Dblas=none', '-Csetup-args=-Dlapack=none']
1413
need_stl_shared = True
14+
min_ndk_api_support = 24
1515

1616
def get_recipe_meson_options(self, arch):
1717
options = super().get_recipe_meson_options(arch)
@@ -36,13 +36,6 @@ def get_recipe_env(self, arch, **kwargs):
3636
"python3", self.ctx).get_build_dir(arch.arch), "android-build", "python")
3737
return env
3838

39-
def download_if_necessary(self):
40-
# NumPy requires complex math functions which were added in api 24
41-
if self.ctx.ndk_api < 24:
42-
error(NUMPY_NDK_MESSAGE)
43-
exit(1)
44-
super().download_if_necessary()
45-
4639
def build_arch(self, arch):
4740
super().build_arch(arch)
4841
self.restore_hostpython_prerequisites(["cython"])

pythonforandroid/recipes/pandas/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44

55
class PandasRecipe(MesonRecipe):
6-
version = 'v2.2.1'
7-
url = 'git+https://github.com/pandas-dev/pandas' # noqa
6+
version = 'v2.3.0'
7+
url = 'git+https://github.com/pandas-dev/pandas'
88
depends = ['numpy', 'libbz2', 'liblzma']
9-
hostpython_prerequisites = ["Cython~=3.0.5"] # meson does not detects venv's cython
9+
hostpython_prerequisites = ["Cython<4.0.0a0", "versioneer", "numpy"] # meson does not detects venv's cython
1010
patches = ['fix_numpy_includes.patch']
1111
python_depends = ['python-dateutil', 'pytz']
1212
need_stl_shared = True
@@ -17,7 +17,7 @@ def get_recipe_env(self, arch, **kwargs):
1717
# because we need some includes generated at numpy's compile time
1818

1919
env['NUMPY_INCLUDES'] = join(
20-
self.ctx.get_python_install_dir(arch.arch), "numpy/core/include",
20+
self.ctx.get_python_install_dir(arch.arch), "numpy/_core/include",
2121
)
2222
env["PYTHON_INCLUDE_DIR"] = self.ctx.python_recipe.include_root(arch)
2323

pythonforandroid/recipes/python3/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ class Python3Recipe(TargetPythonRecipe):
146146
'''The directories from site packages dir that we don't want to be included
147147
in our python bundle.'''
148148

149+
site_packages_excluded_dir_exceptions = [
150+
# 'numpy' is excluded here because importing with `import numpy as np`
151+
# can fail if the `tests` directory inside the numpy package is excluded.
152+
'numpy',
153+
]
154+
'''Directories from `site_packages_dir_blacklist` will not be excluded
155+
if the full path contains any of these exceptions.'''
156+
149157
site_packages_filen_blacklist = [
150158
'*.py'
151159
]
@@ -419,7 +427,8 @@ def create_python_bundle(self, dirn, arch):
419427
with current_directory(self.ctx.get_python_install_dir(arch.arch)):
420428
filens = list(walk_valid_filens(
421429
'.', self.site_packages_dir_blacklist,
422-
self.site_packages_filen_blacklist))
430+
self.site_packages_filen_blacklist,
431+
excluded_dir_exceptions=self.site_packages_excluded_dir_exceptions))
423432
info("Copy {} files into the site-packages".format(len(filens)))
424433
for filen in filens:
425434
info(" - copy {}".format(filen))

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77

88
class LibSDL2Recipe(BootstrapNDKRecipe):
9-
version = "2.28.5"
9+
version = "2.30.11"
1010
url = "https://github.com/libsdl-org/SDL/releases/download/release-{version}/SDL2-{version}.tar.gz"
11-
md5sum = 'a344eb827a03045c9b399e99af4af13d'
11+
md5sum = 'bea190b480f6df249db29eb3bacfe41e'
1212

1313
conflicts = ['sdl3']
1414

pythonforandroid/recommendations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
MAX_NDK_VERSION = 25
1414

1515
# DO NOT CHANGE LINE FORMAT: buildozer parses the existence of a RECOMMENDED_NDK_VERSION
16-
RECOMMENDED_NDK_VERSION = "25b"
16+
RECOMMENDED_NDK_VERSION = "28c"
1717

1818
NDK_DOWNLOAD_URL = "https://developer.android.com/ndk/downloads/"
1919

pythonforandroid/util.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def temp_directory():
4848
temp_dir, Err_Fore.RESET)))
4949

5050

51-
def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns):
51+
def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns, excluded_dir_exceptions=None):
5252
"""Recursively walks all the files and directories in ``dirn``,
5353
ignoring directories that match any pattern in ``invalid_dirns``
5454
and files that patch any pattern in ``invalid_filens``.
@@ -60,15 +60,22 @@ def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns):
6060
6161
File and directory paths are evaluated as full paths relative to ``dirn``.
6262
63+
If ``excluded_dir_exceptions`` is given, any directory path that contains
64+
any of those strings will *not* exclude subdirectories matching
65+
``invalid_dir_names``.
6366
"""
6467

68+
excluded_dir_exceptions = [] if excluded_dir_exceptions is None else excluded_dir_exceptions
69+
6570
for dirn, subdirs, filens in walk(base_dir):
71+
allow_invalid_dirs = any(ex in dirn for ex in excluded_dir_exceptions)
6672

6773
# Remove invalid subdirs so that they will not be walked
68-
for i in reversed(range(len(subdirs))):
69-
subdir = subdirs[i]
70-
if subdir in invalid_dir_names:
71-
subdirs.pop(i)
74+
if not allow_invalid_dirs:
75+
for i in reversed(range(len(subdirs))):
76+
subdir = subdirs[i]
77+
if subdir in invalid_dir_names:
78+
subdirs.pop(i)
7279

7380
for filen in filens:
7481
for pattern in invalid_file_patterns:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy