kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.34k stars 1.85k forks source link

kiwisolver build fails, and depreciation warning #3056

Open RobertFlatt opened 2 months ago

RobertFlatt commented 2 months ago

Checklist

Description

Kiwisolver build fails with include error.

Also a depreciation warning for next month!

Logs

Error:

creating build
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/kiwisolver
copying py/kiwisolver/exceptions.py -> build/lib.linux-x86_64-cpython-311/kiwisolver
copying py/kiwisolver/__init__.py -> build/lib.linux-x86_64-cpython-311/kiwisolver
copying py/kiwisolver/_cext.pyi -> build/lib.linux-x86_64-cpython-311/kiwisolver
copying py/kiwisolver/py.typed -> build/lib.linux-x86_64-cpython-311/kiwisolver
running build_ext
building 'kiwisolver._cext' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/py
creating build/temp.linux-x86_64-cpython-311/py/src
/home/bobf/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -DANDROID -I/home/bobf/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -I/home/bobf/ex/rtest/.buildozer/android/platform/build-arm64-v8a/build/python-installs/myapp/arm64-v8a/include/python3.1 -fPIC -I/tmp/build-env-dyupwo5o/lib/python3.11/site-packages/cppy/include -I. -I/tmp/build-env-dyupwo5o/include -I/usr/local/include/python3.11 -c py/src/constraint.cpp -o build/temp.linux-x86_64-cpython-311/py/src/constraint.o -std=c++11
In file included from py/src/constraint.cpp:10:
In file included from /tmp/build-env-dyupwo5o/lib/python3.11/site-packages/cppy/include/cppy/cppy.h:16:
/tmp/build-env-dyupwo5o/lib/python3.11/site-packages/cppy/include/cppy/defines.h:10:10: fatal error: 'Python.h' file not found
#include <Python.h>
         ^~~~~~~~~~
1 error generated.
error: command '/home/bobf/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++' failed with exit code 1

Depreciation warning

/tmp/build-env-dyupwo5o/lib/python3.11/site-packages/setuptools_scm/git.py:167: UserWarning: "/home/bobf/ex/rtest/.buildozer/android/platform/build-arm64-v8a/build/other_builds/kiwisolver/arm64-v8a__ndk_target_21/kiwisolver" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
/tmp/build-env-dyupwo5o/lib/python3.11/site-packages/setuptools/dist.py:450: SetuptoolsDeprecationWarning: Invalid dash-separated options
!!

        ********************************************************************************
        Usage of dash-separated 'plat-name' will not be supported in future
        versions. Please use the underscore name 'plat_name' instead.

        By 2024-Sep-26, you need to update your project and remove deprecated calls
        or your builds will no longer be supported.

        See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
        ********************************************************************************
vabt-igd commented 2 months ago

I am currently experiencing exactly the same issue. I have a feeling that this is something to do with the latest python updates being distributed via the system updater in Ubuntu (22.04 and 24.04), as this problem has only been occurring for the last two weeks and has never happened before.

RobertFlatt commented 2 months ago

@T-Dynamos Any suggestions?

RobertFlatt commented 2 months ago

@vabt-igd This now builds for me (Ubuntu 22.04), what is your experience?

vabt-igd commented 2 months ago

Unfortunately, I'm still running into the same issue. Did you change anything about your setup? I'm using p4a develop with python 3.11.

As far as I can see, there has not been any commit activity on the develop branch of p4a and cppy as well as kiwisolver versions are pinned within the corresponding recipes.

RobertFlatt commented 2 months ago

I did an apt update/upgrade. I'd be interested to know if that helps you.

I took looked for p4a develop changes but didn't see anything significant.

vabt-igd commented 2 months ago

Unfortunately, it does not. I even tested it on a fresh Ubuntu 22.04 vm with no luck… Strange issue!

RobertFlatt commented 2 months ago

Yes it is. Things magically fixing themselves on one system but not on another is always a bit concerning.

FYI my system Python is 3.10.12 and p4a is using 3.11 internally.

vabt-igd commented 2 months ago

I tried py 3.10 to 3.12 without any differences regarding the kiwisolver issue. Did you install any additional packages/modules that may symlink to the python header file Python.h?

vabt-igd commented 1 month ago

So, I managed to fix the build on my Ubuntu 22.04.4 LTS using Python 3.11.10 (probably Python 3.10 as well, but haven't tested it), p4a develop and custom recipes for cppy and kiwisolver. On Python 3.12 the build still fails.

The custom recipes look as follows:

cppy:

from pythonforandroid.recipe import PythonRecipe

class CppyRecipe(PythonRecipe):
    site_packages_name = "cppy"
    version = "1.2.1"
    url = "https://github.com/nucleic/cppy/archive/{version}.zip"
    call_hostpython_via_targetpython = False
    install_in_hostpython = True
    depends = ["setuptools"]

recipe = CppyRecipe()

Although preferable, I could not get this recipe to properly compile using the PyProjectRecipe...

kiwisolver:

from pythonforandroid.recipe import PyProjectRecipe

class KiwiSolverRecipe(PyProjectRecipe):
    site_packages_name = "kiwisolver"
    version = "1.4.7"
    url = "git+https://github.com/nucleic/kiwi.git"
    depends = ["cppy"]
    hostpython_prerequisites = ["cppy>=1.2.0"]
    need_stl_shared = True

recipe = KiwiSolverRecipe()

I don't think this is worth a PR as there is probably something broken deeper in the build chain either locally on my VMs or in the dev-branch...