Skip to content
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

SciPy recipe fails with current development branch of P4A #3116

Open
mriscoc opened this issue Mar 5, 2025 · 1 comment
Open

SciPy recipe fails with current development branch of P4A #3116

mriscoc opened this issue Mar 5, 2025 · 1 comment
Labels

Comments

@mriscoc
Copy link
Contributor

mriscoc commented Mar 5, 2025

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
@kuzeyron kuzeyron added the recipe label Mar 5, 2025
@mriscoc
Copy link
Contributor Author

mriscoc commented Mar 7, 2025

Current recipe uses SciPy maintenance/1.11.3:

version = 'maintenance/1.11.x'
url = 'git+https://github.com/scipy/scipy.git'
git_commit = 'b430bf54b5064465983813e2cfef3fcb86c3df07' # version 1.11.3

which uses a deprecated Numpy type np.int_t:
https://github.com/scipy/scipy/blob/1d3a067c2ccd0a6efddeb3194163aa9a3879d26e/scipy/ndimage/src/_ni_label.pyx#L328-L331

                for ni in range(num_neighbors):
                    neighbor_use_prev = (<np.int_t *> PyArray_ITER_DATA(itstruct))[0]
                    neighbor_use_adjacent = (<np.int_t *> (<char *> PyArray_ITER_DATA(itstruct) + ss))[0]
                    neighbor_use_next = (<np.int_t *> (<char *> PyArray_ITER_DATA(itstruct) + 2 * ss))[0]

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

                for ni in range(num_neighbors):
                    neighbor_use_prev = (<np.npy_bool *> PyArray_ITER_DATA(itstruct))[0]
                    neighbor_use_adjacent = (<np.npy_bool *> (<char *> PyArray_ITER_DATA(itstruct) + ss))[0]
                    neighbor_use_next = (<np.npy_bool *> (<char *> PyArray_ITER_DATA(itstruct) + 2 * ss))[0]

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants