Open
Description
WSL2 on Windows 11
Ubuntu 22.04.5 LTS
Buildozer 1.5.1.dev0
$LEGACY_NDK: android-ndk-r21e with fortran addons
Relevant configuration lines for buildozer.spec:
requirements = python3,kivy,scipy
android.minapi = 24
android.archs = arm64-v8a
p4a.branch = develop
log_level = 2
Minimal Kivy test:
import kivy
import scipy
from kivy.app import App
from kivy.uix.button import Button
def callback(instance):
scipy.show_config()
class MyApp(App):
def build(self):
btn1 = Button(text='SciPy show config', size=(100, 50))
btn1.bind(on_press=callback)
return btn1
if __name__ == '__main__':
MyApp().run()
Issue:
buildozer -v android debug
finished with the error: 'int_t' is not a type identifier
[INFO]: Building scipy for arm64-v8a
[INFO]: scipy apparently isn't already in site-packages
[DEBUG]: -> running pip install numpy --target /home/mrisco/kivy/test_scipy/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages --python-version 3.11.5 --only-binary=:all: --upgrade
[DEBUG]: Collecting numpy
[DEBUG]: Using cached numpy-2.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (62 kB)
[DEBUG]: Using cached numpy-2.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 MB)
[DEBUG]: Installing collected packages: numpy
[DEBUG]: Successfully installed numpy-2.2.3
[INFO]: Building compiled components in scipy
[INFO]: -> directory context /home/mrisco/kivy/test_scipy/.buildozer/android/platform/build-arm64-v8a/build/other_builds/scipy/arm64-v8a__ndk_target_24/scipy
[DEBUG]: -> running python3 setup.py build_ext -v -j 12
[DEBUG]: /home/mrisco/kivy/test_scipy/.buildozer/android/platform/build-arm64-v8a/build/other_builds/scipy/arm64-v8a__ndk_target_24/scipy/setup.py:136: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
[DEBUG]: from distutils.command.sdist import sdist
[DEBUG]: /home/mrisco/kivy/test_scipy/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/_distutils_hack/__init__.py:11: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
[DEBUG]: warnings.warn(
[DEBUG]: /home/mrisco/kivy/test_scipy/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/_distutils_hack/__init__.py:26: UserWarning: Setuptools is replacing distutils.
[DEBUG]: warnings.warn("Setuptools is replacing distutils.")
[DEBUG]: /home/mrisco/kivy/test_scipy/.buildozer/android/platform/build-arm64-v8a/build/other_builds/scipy/arm64-v8a__ndk_target_24/scipy/setup.py:519: DeprecationWarning:
[DEBUG]:
[DEBUG]: `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
[DEBUG]: of the deprecation of `distutils` itself. It will be removed for
[DEBUG]: Python >= 3.12. For older Python versions it will remain present.
[DEBUG]: It is recommended to use `setuptools < 60.0` for those Python versions.
[DEBUG]: For more details, see:
[DEBUG]: https://numpy.org/devdocs/reference/distutils_status_migration.html
[DEBUG]:
[DEBUG]:
[DEBUG]: from numpy.distutils.core import setup
[DEBUG]: Cythonizing sources
[DEBUG]: Running scipy/stats/_generate_pyx.py
[DEBUG]: Running scipy/linalg/_generate_pyx.py
[DEBUG]: Running scipy/special/_generate_pyx.py
[DEBUG]: Processing scipy/ndimage/src/_cytest.pyx
[DEBUG]: Processing scipy/ndimage/src/_ni_label.pyx
[DEBUG]: Processing scipy/stats/_stats.pyx
[DEBUG]: Processing scipy/stats/_biasedurn.pyx
[DEBUG]: Processing scipy/stats/_qmc_cy.pyx
[DEBUG]: Processing scipy/stats/_sobol.pyx
[DEBUG]: Processing scipy/stats/_unuran/unuran_wrapper.pyx
[DEBUG]: Processing scipy/stats/_levy_stable/levyst.pyx
[DEBUG]: Processing scipy/stats/_boost/src/skewnorm_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/beta_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/binom_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/invgauss_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/ncx2_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/hypergeom_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/nbinom_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/ncf_ufunc.pyx
[DEBUG]: Processing scipy/stats/_boost/src/nct_ufunc.pyx
[DEBUG]: Processing scipy/stats/_rcont/rcont.pyx
[DEBUG]: Processing scipy/sparse/_csparsetools.pyx.in
[DEBUG]:
[DEBUG]: Error compiling Cython file:
[DEBUG]: ------------------------------------------------------------
[DEBUG]: ...
[DEBUG]: needs_self_labeling = True
[DEBUG]:
[DEBUG]: # Take neighbor labels
[DEBUG]: PyArray_ITER_RESET(itstruct)
[DEBUG]: for ni in range(num_neighbors):
[DEBUG]: neighbor_use_prev = (<np.int_t *> PyArray_ITER_DATA(itstruct))[0]
[DEBUG]: ^
[DEBUG]: ------------------------------------------------------------
[DEBUG]:
[DEBUG]: _ni_label.pyx:329:42: 'int_t' is not a type identifier
Activity
mriscoc commentedon Mar 7, 2025
Current recipe uses SciPy maintenance/1.11.3:
python-for-android/pythonforandroid/recipes/scipy/__init__.py
Lines 18 to 20 in 9b0eed1
which uses a deprecated Numpy type np.int_t:
https://github.com/scipy/scipy/blob/1d3a067c2ccd0a6efddeb3194163aa9a3879d26e/scipy/ndimage/src/_ni_label.pyx#L328-L331
That was fixed in the SciPy version 1.12.0:
https://github.com/scipy/scipy/blob/4edfcaa3ce8a387450b6efce968572def71be089/scipy/ndimage/src/_ni_label.pyx#L328-L331
But the 1.12.0 release doesn't have the file /tools/cythonize.py
So I tried again with an old version of SciPy, I saw the PR scipy/scipy#19320 about fixing the Cython version in 1.11.3 and releasing a final 1.11.4 version before the 1.12.0 release, using that version in the recipe also gave the original error.
mriscoc commentedon Mar 25, 2025
Is there anything that I can do to fix this recipe? The same error is produced with current development branch.
AndreMiras commentedon Mar 25, 2025
I took a stab at it last summer and it was highly painful, hopefully things got better with recent releases, I don't know.
But basically you can start writing a recipe, try to build, fix the build errors by updating the recipe, rebuild...iterate until you have them all fixed.
Then do the same for the runtime errors.
You could probably start with:
Then the workflow I'm using to rebuild is:
In fact I often build from the repository docker image, this is the way I like the best, but you can also build from your host.
In case you want to give it a try from the container, this is how:
Good luck! 🏃
T-Dynamos commentedon Mar 27, 2025
Ok I went through all the pain, here you go: https://github.com/T-Dynamos/python-for-android/tree/scipy_update
You need to set ndk version to
r27c
(in spec) and ndk api to 24 (minapi).Only works for 64 bit arches.
Here is my test:
Apk size was
53MB
Test code:
Will open PR soon when will get more time (needs cleaning).
mriscoc commentedon Mar 27, 2025
Oh thanks, that was quick! I just managed to build the configuration.
T-Dynamos commentedon Mar 27, 2025
But unfortunately, updating ndk to27c
doesn't allows SDL to build.I had to pull trick for that:1. build with only python3 and kivy (in requirements) with ndk25b
2. change ndk to27c
with scipy and numpy in requirementsthen it should work.Edit: NVM fixed in latest commit.
mriscoc commentedon Mar 27, 2025
@T-Dynamos
I'm getting this error with your fix:
By changing the line 11 of pythonforandroid/recipes/sdl2/init.py to
fix that.
But I got a new error:
That can be fixed by removing the references to .git folder in the meson.patch file: