Issue while compiling pydantic-core for Chaquopy
Hi, I am trying to make pydantic-core to work with Chaquopy. I am progressing, but I face an issue I do not understand.
Maybe you have some clues on what I am facing.
I am adding the;logs of the error here
It looks like some API relative to pyDateTime are not found:
Compiling pydantic-core v2.27.2 (/Work/Inno/sandbox/pr/chaquopy/server/pypi/packages/pydantic-core/build/2.27.2/cp311-cp311-android_24_x86_64/src)
error[E0432]: unresolved imports pyo3::types::PyDate, pyo3::types::PyDateTime, pyo3::types::PyDelta, pyo3::types::PyDeltaAccess, pyo3::types::PyTime, pyo3::types::PyTzInfo
--> src/input/datetime.rs:6:19
|
6 | use pyo3::types::{PyDate, PyDateTime, PyDelta, PyDeltaAccess, PyDict, PyTime, PyTzInfo};
| ^^^^^^ ^^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^ ^^^^^^^^ no PyTzInfo in types
| | | | | |
| | | | | no PyTime in types
| | | | | help: a similar name exists in the module: PyType
| | | | no PyDeltaAccess in types
| | | no PyDelta in types
| | no PyDateTime in types
| no PyDate in types
Thanks a lot for your consideration.
It sounds like for some reason the abi3 PyO3 features are enabled. Can you please go into more detail about how you are configuring the build?
Yes, you are right, for chaquopy, we need to support multiple python version, so I have to add the abi3_py11 option. Patch I am working on is here: https://github.com/FCare/chaquopy/blob/pydantic-core/server/pypi/packages/pydantic-core/patches/pyo3_no_interpreter.patch
Does that mean that pydantic-core is not compatible with abi3 option anymore?
Thanks a lot for your support :-)
Does that mean that pydantic-core is not compatible with abi3 option anymore?
PyO3 has never exposed the datetime types with abi3 (their C API is not available on the limited API), so I don't think this would have ever worked.
If you are patching, you could modify pydantic-core in your patch to internally just use dynamic Python calls for these, which would be a performance hit. PyO3 does so internally for the chrono feature if you build for abi3, for example.
Ok thanks, I will give it a try.
I was suspecting issue with performance here, but that might be acceptable.
I am studying for this problem,I did not use the abi3 to build,here I successfully build pydantic-core for Chaquopy:
https://github.com/ririv/android-wheels
but when I run it in the Chaquopy,a new problem has been encountered.
The log is below.
2025-10-28 11:18:54.586 26803-26803 android.console com.sgm.agentandroid.console I Late-enabling -Xcheck:jni
2025-10-28 11:18:55.173 26803-26803 android.console com.sgm.agentandroid.console I Using CollectorTypeCMC GC.
2025-10-28 11:18:55.674 26803-26803 nativeloader com.sgm.agentandroid.console D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok
2025-10-28 11:18:56.677 26803-26803 nativeloader com.sgm.agentandroid.console D Configuring clns-7 for other apk /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/lib/arm64:/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.sgm.agentandroid.console
2025-10-28 11:18:56.699 26803-26803 android.console com.sgm.agentandroid.console I AssetManager2(0xb4000070332b0358) locale list changing from [] to [en-US]
2025-10-28 11:18:57.144 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V Currently set values for:
2025-10-28 11:18:57.144 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V angle_gl_driver_selection_pkgs=[]
2025-10-28 11:18:57.144 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V angle_gl_driver_selection_values=[]
2025-10-28 11:18:57.144 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V com.sgm.agentandroid.console is not listed in per-application setting
2025-10-28 11:18:57.145 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V ANGLE allowlist from config:
2025-10-28 11:18:57.145 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V com.sgm.agentandroid.console is not listed in ANGLE allowlist or settings, returning default
2025-10-28 11:18:57.145 26803-26803 GraphicsEnvironment com.sgm.agentandroid.console V Neither updatable production driver nor prerelease driver is supported.
2025-10-28 11:18:57.450 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libcrypto_chaquopy.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.451 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libssl_chaquopy.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.452 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libsqlite3_chaquopy.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.460 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libcrypto_python.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.464 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libssl_python.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.465 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libsqlite3_python.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.476 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libpython3.13.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.477 26803-26803 nativeloader com.sgm.agentandroid.console D Load /data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!/lib/arm64-v8a/libchaquopy_java.so using class loader ns clns-7 (caller=/data/app/~~zuLaxlR3yLl6ai0xxwBuRw==/com.sgm.agentandroid.console-HlKHjENnRAeRlCCX-hC43w==/base.apk!classes7.dex): ok
2025-10-28 11:18:57.464 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:890): avc: denied { read } for name="overcommit_memory" dev="proc" ino=128925 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:proc_overcommit_memory:s0 tclass=file permissive=0 app=com.sgm.agentandroid.console
2025-10-28 11:18:57.560 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:891): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/zlib.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362698 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:57.660 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:892): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/java/chaquopy.so" dev="dm-54" ino=368655 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:57.676 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:893): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/_ctypes.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362702 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:57.684 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:894): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/_struct.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362116 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:58.004 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:895): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/_bz2.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362526 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:58.036 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:896): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/_lzma.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362513 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:58.080 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:897): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/_datetime.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362393 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:58.112 26803-26803 android.console com.sgm.agentandroid.console W type=1400 audit(0.0:898): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/bootstrap-native/arm64-v8a/_opcode.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=362695 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:58.455 26803-26803 Choreographer com.sgm.agentandroid.console I Skipped 67 frames! The application may be doing too much work on its main thread.
2025-10-28 11:18:58.471 26803-26803 android.console com.sgm.agentandroid.console I AssetManager2(0xb400007033376a58) locale list changing from [] to [en-US]
2025-10-28 11:18:58.510 26803-26803 AppCompatDelegate com.sgm.agentandroid.console D Checking for metadata for AppLocalesMetadataHolderService : Service not found
2025-10-28 11:18:58.510 26803-26803 android.console com.sgm.agentandroid.console I AssetManager2(0xb400007033378998) locale list changing from [] to [en-US]
2025-10-28 11:18:58.668 26803-26803 CompatChangeReporter com.sgm.agentandroid.console D Compat change id reported: 377864165; UID 10218; state: ENABLED
2025-10-28 11:18:58.672 26803-26803 DesktopModeFlags com.sgm.agentandroid.console D Toggle override initialized to: OVERRIDE_UNSET
2025-10-28 11:18:58.714 26803-26803 android.console com.sgm.agentandroid.console I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed
2025-10-28 11:18:58.714 26803-26803 android.console com.sgm.agentandroid.console I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed
2025-10-28 11:18:59.047 26803-26803 HWUI com.sgm.agentandroid.console W Image decoding logging dropped!
2025-10-28 11:18:59.048 26803-26803 HWUI com.sgm.agentandroid.console W Image decoding logging dropped!
2025-10-28 11:18:59.048 26803-26803 HWUI com.sgm.agentandroid.console W Image decoding logging dropped!
2025-10-28 11:18:59.066 26803-26803 ImeTracker com.sgm.agentandroid.console I com.sgm.agentandroid.console:dba1a2df: onRequestHide at ORIGIN_CLIENT reason HIDE_SOFT_INPUT fromUser false
2025-10-28 11:18:59.086 26803-26803 ImeTracker com.sgm.agentandroid.console I com.sgm.agentandroid.console:dba1a2df: onFailed at PHASE_CLIENT_VIEW_SERVED
2025-10-28 11:18:59.087 26803-26803 CompatChangeReporter com.sgm.agentandroid.console D Compat change id reported: 395521150; UID 10218; state: ENABLED
2025-10-28 11:18:59.135 26803-26803 HWUI com.sgm.agentandroid.console W Unknown dataspace 0
2025-10-28 11:18:59.302 26803-26856 EGL_emulation com.sgm.agentandroid.console I Opening libGLESv1_CM_emulation.so
2025-10-28 11:18:59.303 26803-26856 EGL_emulation com.sgm.agentandroid.console I Opening libGLESv2_emulation.so
2025-10-28 11:18:59.337 26803-26856 HWUI com.sgm.agentandroid.console W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2025-10-28 11:18:59.337 26803-26856 HWUI com.sgm.agentandroid.console W Failed to initialize 101010-2 format, error = EGL_SUCCESS
2025-10-28 11:18:59.460 26803-26803 Thread-2 com.sgm.agentandroid.console W type=1400 audit(0.0:908): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/AssetFinder/stdlib-arm64-v8a/_socket.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=369454 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:18:59.622 26803-26803 InsetsController com.sgm.agentandroid.console D hide(ime(), fromIme=false)
2025-10-28 11:18:59.630 26803-26803 ImeTracker com.sgm.agentandroid.console I com.sgm.agentandroid.console:9a63fd7e: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
2025-10-28 11:18:59.984 26803-26803 Thread-2 com.sgm.agentandroid.console W type=1400 audit(0.0:909): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/AssetFinder/stdlib-arm64-v8a/array.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=369455 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:19:00.212 26803-26803 Thread-2 com.sgm.agentandroid.console W type=1400 audit(0.0:910): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/AssetFinder/stdlib-arm64-v8a/_ssl.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=369502 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:19:00.324 26803-26803 Thread-2 com.sgm.agentandroid.console W type=1400 audit(0.0:911): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/AssetFinder/stdlib-arm64-v8a/_contextvars.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=369503 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:19:00.344 26803-26803 Thread-2 com.sgm.agentandroid.console W type=1400 audit(0.0:912): avc: granted { execute } for path="/data/data/com.sgm.agentandroid.console/files/chaquopy/AssetFinder/stdlib-arm64-v8a/_asyncio.cpython-313-aarch64-linux-android.so" dev="dm-54" ino=369626 scontext=u:r:untrusted_app:s0:c218,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c218,c256,c512,c768 tclass=file app=com.sgm.agentandroid.console
2025-10-28 11:19:00.633 26803-26803 ImeTracker com.sgm.agentandroid.console I com.sgm.agentandroid.console:1fe6e17e: onRequestHide at ORIGIN_CLIENT reason HIDE_SOFT_INPUT fromUser false
2025-10-28 11:19:00.634 26803-26803 InsetsController com.sgm.agentandroid.console D hide(ime(), fromIme=false)
2025-10-28 11:19:00.634 26803-26803 ImeTracker com.sgm.agentandroid.console I com.sgm.agentandroid.console:1fe6e17e: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
2025-10-28 11:19:00.634 26803-26860 AndroidRuntime com.sgm.agentandroid.console E FATAL EXCEPTION: Thread-2 (Ask Gemini)
Process: com.sgm.agentandroid.console, PID: 26803
com.chaquo.python.PyException: OSError: dlopen failed: library "libgcc_s.so.1" not found
at <python>.ctypes.__init__(__init__.py:390)
at <python>.pydantic_core.<module>(__init__.py:8)
at <python>.pydantic.version.<module>(version.py:7)
at <python>.pydantic.warnings.<module>(warnings.py:5)
at <python>.pydantic._migration.<module>(_migration.py:4)
at <python>.pydantic.<module>(__init__.py:5)
at <python>.event_source.event_model.<module>(event_model.py:5)
at <python>.event_source.default_simulator.<module>(default_simulator.py:5)
at <python>.apps.cli_app.<module>(cli_app.py:4)
at <python>.java.chaquopy.import_override(import.pxi:26)
at <python>.main.main(main.py:22)
at <python>.chaquopy_java.call(chaquopy_java.pyx:352)
at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:324)
at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
at com.sgm.agentandroid.console.MainActivity$Task.run(MainActivity.java:35)
at com.sgm.agentandroid.utils.ConsoleActivity$Task.lambda$start$0(ConsoleActivity.java:352)
at com.sgm.agentandroid.utils.ConsoleActivity$Task.$r8$lambda$lpIgMxK528jA7eAlkjYsl2DaoRA(Unknown Source:0)
at com.sgm.agentandroid.utils.ConsoleActivity$Task$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1119)
2025-10-28 11:19:00.712 26803-26860 Process com.sgm.agentandroid.console I Sending signal. PID: 26803 SIG: 9
Looks like you've hit the same thing as in https://github.com/rust-lang/rust/issues/119504
I have solved it, it's the bug of cbuildwheel with setuptools-rust, when compling the wheels in Android, it did not set the CARGO_BUILD_TARGET, so target for host has been set automatically. That leads the built wheel need the "libgcc_s.so.1". Now I have build the correct wheel of pydantic-core used for Android.