Skip to content

update: numpy, pandas, sdl2 #3164

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions ci/makefiles/android.mk
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Downloads and installs the Android SDK depending on supplied platform: darwin or linux

# Those android NDK/SDK variables can be override when running the file
ANDROID_NDK_VERSION ?= 25b
ANDROID_NDK_VERSION ?= 27c
ANDROID_NDK_VERSION_LEGACY ?= 21e
ANDROID_SDK_TOOLS_VERSION ?= 6514223
ANDROID_SDK_BUILD_TOOLS_VERSION ?= 29.0.3
ANDROID_HOME ?= $(HOME)/.android
ANDROID_API_LEVEL ?= 27
ANDROID_API_LEVEL ?= 33

# per OS dictionary-like
UNAME_S := $(shell uname -s)
Expand Down
4 changes: 2 additions & 2 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ named ``tools``, and you will need to run extra commands to install
the SDK packages needed.

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

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

Expand Down
4 changes: 2 additions & 2 deletions doc/source/testing_pull_requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Using python-for-android commands directly from the pull request files
--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 \
--android-api=33 \
--arch=arm64-v8a \
--permission=VIBRATE \
--debug
Expand Down Expand Up @@ -175,7 +175,7 @@ Installing python-for-android using the github's branch of the pull request
python3 setup.py apk \
--ndk-dir=/media/DEVEL/Android/android-ndk-r20 \
--sdk-dir=/media/DEVEL/Android/android-sdk-linux \
--android-api=27 \
--android-api=33 \
--arch=arm64-v8a \
--debug

Expand Down
8 changes: 8 additions & 0 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class Recipe(metaclass=RecipeMeta):
starting from NDK r18 the `gnustl_shared` lib has been deprecated.
'''

min_ndk_api_support = 20
'''
Minimum ndk api recipe will support.
'''

def get_stl_library(self, arch):
return join(
arch.ndk_lib_dir,
Expand Down Expand Up @@ -375,6 +380,9 @@ def get_recipe_dir(self):
# Public Recipe API to be subclassed if needed

def download_if_necessary(self):
if self.ctx.ndk_api < self.min_ndk_api_support:
error(f"In order to build '{self.name}', you must set minimum ndk api (minapi) to `{self.min_ndk_api_support}`.\n")
exit(1)
Comment on lines 382 to +385
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, shouldn't we leverage pythonforandroid/recommendations.py?
Maybe @misl6 has better insights

info_main('Downloading {}'.format(self.name))
user_dir = environ.get('P4A_{}_DIR'.format(self.name.lower()))
if user_dir is not None:
Expand Down
13 changes: 3 additions & 10 deletions pythonforandroid/recipes/numpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from pythonforandroid.recipe import Recipe, MesonRecipe
from pythonforandroid.logger import error
from os.path import join
import shutil

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


class NumpyRecipe(MesonRecipe):
version = 'v1.26.5'
version = 'v2.3.0'
url = 'git+https://github.com/numpy/numpy'
hostpython_prerequisites = ["Cython>=3.0.6"] # meson does not detects venv's cython
hostpython_prerequisites = ["Cython==3.0.6"] # meson does not detects venv's cython
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to be that restrictive? Maybe it doesn't work with too recents Cython versions, but in this case maybe we should use a range at least

extra_build_args = ['-Csetup-args=-Dblas=none', '-Csetup-args=-Dlapack=none']
need_stl_shared = True
min_ndk_api_support = 24

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

def download_if_necessary(self):
# NumPy requires complex math functions which were added in api 24
if self.ctx.ndk_api < 24:
error(NUMPY_NDK_MESSAGE)
exit(1)
super().download_if_necessary()
Comment on lines -39 to -44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh OK I see what you did there by moving it to recipe.py
@misl6 would have better insights, but I'd be tempted to keep it in this recipe only for this PR unless we have a clearly cleaner approach, what do you guys think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because it was also required in scipy recipe.


def build_arch(self, arch):
super().build_arch(arch)
self.restore_hostpython_prerequisites(["cython"])
Expand Down
8 changes: 4 additions & 4 deletions pythonforandroid/recipes/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@


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

env['NUMPY_INCLUDES'] = join(
self.ctx.get_python_install_dir(arch.arch), "numpy/core/include",
self.ctx.get_python_install_dir(arch.arch), "numpy/_core/include",
)
env["PYTHON_INCLUDE_DIR"] = self.ctx.python_recipe.include_root(arch)

Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class Python3Recipe(TargetPythonRecipe):

site_packages_dir_blacklist = {
'__pycache__',
'tests'
}
'''The directories from site packages dir that we don't want to be included
in our python bundle.'''
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


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

conflicts = ['sdl3']

Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
MAX_NDK_VERSION = 25

# DO NOT CHANGE LINE FORMAT: buildozer parses the existence of a RECOMMENDED_NDK_VERSION
RECOMMENDED_NDK_VERSION = "25b"
RECOMMENDED_NDK_VERSION = "27c"

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

Expand Down
6 changes: 3 additions & 3 deletions testapps/on_device_unit_tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'requirements':
'sqlite3,libffi,openssl,pyjnius,kivy,python3,requests,urllib3,'
'chardet,idna',
'android-api': 27,
'android-api': 33,
'ndk-api': 24,
'dist-name': 'bdist_unit_tests_app',
'arch': 'armeabi-v7a',
Expand All @@ -56,7 +56,7 @@
'requirements':
'sqlite3,libffi,openssl,pyjnius,kivy,python3,requests,urllib3,'
'chardet,idna',
'android-api': 27,
'android-api': 33,
'ndk-api': 24,
'dist-name': 'bdist_unit_tests_app',
'arch': 'armeabi-v7a',
Expand All @@ -68,7 +68,7 @@
'aar':
{
'requirements' : 'python3',
'android-api': 27,
'android-api': 33,
'ndk-api': 24,
'dist-name': 'bdist_unit_tests_app',
'arch': 'arm64-v8a',
Expand Down
2 changes: 1 addition & 1 deletion testapps/setup_testapp_python3_sqlite_openssl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages

options = {'apk': {'requirements': 'requests,peewee,sdl2,pyjnius,kivy,python3',
'android-api': 27,
'android-api': 33,
'ndk-api': 21,
'bootstrap': 'sdl2',
'dist-name': 'bdisttest_python3_sqlite_openssl_googlendk',
Expand Down
2 changes: 1 addition & 1 deletion testapps/setup_vispy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
options = {'apk': {'debug': None,
'requirements': 'python3,vispy',
'blacklist-requirements': 'openssl,sqlite3',
'android-api': 27,
'android-api': 33,
'ndk-api': 21,
'bootstrap': 'empty',
'ndk-dir': '/home/asandy/android/android-ndk-r17c',
Expand Down
2 changes: 1 addition & 1 deletion testapps/testlauncherreboot_setup/sdl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# 'cymunk,lxml,pil,openssl,pyopenssl,'
# 'twisted,audiostream,ffmpeg,numpy'

'android-api': 27,
'android-api': 33,
'ndk-api': 21,
'dist-name': 'bdisttest_python3launcher_sdl2_googlendk',
'name': 'TestLauncherPy3-sdl2',
Expand Down
2 changes: 1 addition & 1 deletion tests/recipes/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_get_recipe_env(
self.ctx.recipe_build_order
)
numpy_includes = join(
self.ctx.get_python_install_dir(self.arch.arch), "numpy/core/include",
self.ctx.get_python_install_dir(self.arch.arch), "numpy/_core/include",
)
env = self.recipe.get_recipe_env(self.arch)
self.assertIn(numpy_includes, env["NUMPY_INCLUDES"])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def test_download_if_necessary(self):
"""
# download should happen as the environment variable is not set
recipe = DummyRecipe()
recipe.ctx = Context()
recipe.ctx._ndk_api = 36
with mock.patch.object(Recipe, 'download') as m_download:
recipe.download_if_necessary()
assert m_download.call_args_list == [mock.call()]
Expand Down
Loading