chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
748 stars 127 forks source link

Problem building Python 3.12 #1143

Open FeodorFitsner opened 2 months ago

FeodorFitsner commented 2 months ago

I'm trying to create a CI job to build Pythons using the scripts in target directory.

The build is running on Ubuntu 20.04 with pre-installed Python 3.12.2 as a "build" Python.

Build branch is based on 15.0.1 tag.

For the start I'm trying to build and package Python 3.12.0 just for arm64-v8a: https://github.com/chaquo/chaquopy/compare/master...flet-dev:chaquopy:build-python?expand=1#diff-570ac28988193a9cde9b77463ab795712f39c5ee1a90076eaffae6a04c98bd96

Here's CI build results: https://ci.appveyor.com/project/flet-dev/chaquopy/builds/49666447#L7491

It yields the following error while building Python:

ld: error: unable to find library -lpython3.12
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:2960: Modules/array.cpython-312.so] Error 1

Could you please advice what I'm doing wrong? Thank you!

mhsmith commented 2 months ago

Thanks; I can reproduce this too, with a parallel build on a 2-core Linux machine.

This is caused by a missing Makefile dependency: it's trying to build the array module before building libpython. This should have been fixed by python_for_build_deps.patch, which I see is being applied in the log (search for "Makefile.pre.in"). But that patch doesn't have the intended effect on Python 3.12.

As noted in 4fd0ae2292aa79bff013dda2b68553ff022eeb25, this should be fixed by backporting the build system improvements I made to Python 3.13 in the upstream CPython repository. Meanwhile, you can work around it by doing a non-parallel build – remove -j $CPU_COUNT from the bottom of python/build.sh.

And by the way, since the Python build doesn't use for-each-abi.sh, if you want to build it for just one ABI then you'll have to edit build-and-package.sh.

FeodorFitsner commented 2 months ago

Thank you for the fast reply!

Indeed, it could be successfully built now without -j option: https://ci.appveyor.com/project/flet-dev/chaquopy/builds/49667256

mhsmith commented 2 months ago

By the way, you can get Chaquopy's pre-built Python packages from Maven Central.

FeodorFitsner commented 2 months ago

Thank you!