cpython icon indicating copy to clipboard operation
cpython copied to clipboard

.pc for Android contains invalid syntax

Open lazka opened this issue 3 months ago • 4 comments

Bug report

Bug description:

Looking at the Android build here: https://www.python.org/downloads/android/

The .pc files look like this:

# See: man pkg-config
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Python
Description: Build a C extension for Python
Requires:
Version: 3.14
Libs.private: -ldl  -llog
Libs: -L${libdir} $(BLDLIBRARY)
Cflags: -I${includedir}/python3.14

The "Libs:" line contains some autotools internals instead of the library name resulting in linker errors like:

cannot find $(BLDLIBRARY): No such file or directory

Might be related to #115780

Disclaimer: The main reason I'm reporting this is that it also breaks the Cygwin build in the same way, but that's not a supported platform, so this is the next best thing. i.e. I've not actually tested on Android.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

lazka avatar Sep 11 '25 15:09 lazka

cc @mhsmith

StanFromIreland avatar Sep 11 '25 15:09 StanFromIreland

Thanks for the report. I guess $(BLDLIBRARY) should probably be replaced with -lpython3.14. However, I'm not currently aware of anyone who uses the .pc file on Android, so I won't pick this up this myself just now.

mhsmith avatar Sep 12 '25 16:09 mhsmith

Fair enough, I've hackily worked this around downstream now.

lazka avatar Sep 12 '25 17:09 lazka

This affects any package using Meson, which uses pkgconfig to detect Python, so I'll implement a fix.

Example error:

FAILED: numpy/_core/_struct_ufunc_tests.cpython-313-aarch64-linux-android.so 
/Users/msmith/Library/Android/sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang  -o numpy/_core/_struct_ufunc_tests.cpython-313-aarch64-linux-android.so numpy/_core/_struct_ufunc_tests.cpython-313-aarch64-linux-android.so.p/src_umath__struct_ufunc_tests.c.o -L/private/var/folders/2t/th8vxc813_gcch7lkh1sbbmc0000gp/T/cibw-run-5ef4oo3_/cp313-android_arm64_v8a/python/prefix/lib -I/private/var/folders/2t/th8vxc813_gcch7lkh1sbbmc0000gp/T/cibw-run-5ef4oo3_/cp313-android_arm64_v8a/python/prefix/include -Wl,--as-needed -Wl,--allow-shlib-undefined -Wl,-O1 -shared -fPIC -lm -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,-z,max-page-size=16384 -Wl,--no-undefined -D__BIONIC_NO_PAGE_SIZE_MACRO -DNDEBUG -O3 -Wall '$(BLDLIBRARY)'
clang: error: no such file or directory: '$(BLDLIBRARY)'

mhsmith avatar Dec 16 '25 11:12 mhsmith