tmedicci opened a new pull request, #3495:
URL: https://github.com/apache/nuttx-apps/pull/3495
## Summary
* interpreters/python: Add ctypes prototype patches for NuttX:
* integrate NuttX-specific ctypes and posixmodule updates.
* system/libffi: Add libffi package integration:
* Add Kconfig, build rules, and ignore entries required to build and
package libffi as a standalone system component.
## Impact
Impact on user: Allow users to import the ctypes module for Python on NuttX.
Impact on build: No.
Impact on hardware: No.
Impact on documentation: No.
Impact on security: No.
Impact on compatibility: No.
## Testing
`rv-virt:cpython` can be used to test it.
### Building
```
make -j distclean
./tools/configure.sh -S rv-virt:python
kconfig-tweak -e FS_TMPFS
kconfig-tweak --set-val FS_HEAPSIZE 2097152
kconfig-tweak --set-val RAM_SIZE 67108864
kconfig-tweak -e LIBC_DLFCN
kconfig-tweak -e LIB_LIBFFI
kconfig-tweak -e INTERPRETERS_CPYTHON_ENABLE_PIP
make olddefconfig
make -j$(nproc)
```
### Running
After build, run it on the generic RISC-V QEMU:
```
qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 8 -m 128 \
-global virtio-mmio.force-legacy=false \
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
-chardev
socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=foo \
-device virtconsole,chardev=foo \
-device virtio-rng-device,bus=virtio-mmio-bus.1 \
-netdev
user,id=u1,hostfwd=tcp:127.0.0.1:10023-10.0.2.15:23,hostfwd=tcp:127.0.0.1:15001-10.0.2.15:5001
\
-device virtio-net-device,netdev=u1,bus=virtio-mmio-bus.2 \
-drive file=./mydisk-1gb.img,if=none,format=raw,id=hd \
-device virtio-blk-device,bus=virtio-mmio-bus.3,drive=hd \
-bios none -kernel ./nuttx -nographic
```
And, then, try to import `ctypes` on Python and check its output result to
calculate the size of a C type.
### Results
```
nsh> python
[ 2.710000] check_and_mount_romfs: Mounting ROMFS filesystem at
target=/usr/local/lib with source=/dev/ram1
Python 3.13.0 (main, May 21 2026, 16:35:39) [GCC 14.2.0] on nuttx
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> x = ctypes.sizeof(ctypes.c_longlong)
>>> x
8
>>>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]