Uh oh!
There was an error while loading. Please reload this page.
interpreters/python: Add Python's port to NuttX - #2879
Conversation
nuttxpr
commented
Dec 5, 2024
[Experimental Bot, please feedback here] This PR does not fully meet the NuttX requirements, although it presents a significant feature addition. Here's a breakdown: Summary: While the summary explains the what and why, it lacks details on how the Python integration works internally. More specifics on memory management, interaction with the OS, and the build process would be beneficial. The "Considerations" section highlights important limitations and to-dos, which is good, but some of these should be addressed before merging. Impact: The impact section is incomplete. While it mentions the target architecture, it needs to address all the points:
Testing: The testing section is insufficient.
Recommendations:
This PR has great potential but needs more work to meet NuttX's standards for completeness and maintainability. Addressing these points will make the integration more robust and easier for the community to adopt. |
anjiahao1
commented
Dec 5, 2024
Great, nice work! |
anjiahao1
commented
Dec 5, 2024
need add cmake? |
tmedicci
commented
Dec 5, 2024
Yes! There is a long list of to-do, but I preferred to submit upstream because I need more hands working on it (and I think we can engage the NuttX community by doing that). NuttX would be one of the first RTOS supporting Python ;) |
hartmannathan
left a comment
There was a problem hiding this comment.
Very cool! I'm in favor of making an early version available for testing and further development by the community. Should it be behind a "EXPERIMENTAL" config, to set the right expectations?
Uh oh!
There was an error while loading. Please reload this page.
tmedicci
commented
Dec 5, 2024
Yes, it makes total sense! |
tmedicci
commented
Dec 5, 2024
Error for |
I ran the CI locally (apache/nuttx#14601 (comment)) and it didn't fail. However, it may be related to an issue that I fixed at f064a19 (just sent along with this PR) |
fdcavalcanti
commented
Dec 6, 2024
This is awesome. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The generation of `sys info.h` depends on evaluating whether Espressif's HAL exists in the arch folder. However, cloning the HAL itself happens in the `context` phase of the build, so it is necessary to wait for it to finish before proceeding to the evaluation in nxdiag. This is done by using the `depend` phase to generate the `sysinfo.h` file.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is the NuttX's port of Python (cpython)! Initial support of Python includes building the Python's static library and the `python` (Programs/python.c) application. Python's modules are stored in `pyc` (byte-code file) and loaded as needed from flash.
Summary
Say Hello to Python!
This is the NuttX's port of Python (CPython)!
Initial support of Python includes building the Python's static library and the
python(Programs/python.c) application. Python's modules are stored inpyc(byte-code file) and loaded as needed from flash.Considerations
Please note that this is the initial port of one of the most used programming languages for NuttX (and, maybe, for embedded RTOSes). There is a long list of To-Do to make it fully functional. NuttX is perhaps one of the best embedded RTOSes for working with Python due to its POSIX Compatibility and on-demand paging (https://nuttx.apache.org/docs/latest/components/paging.html#ondemandpaging). I hope this PR engages NuttX community to keep improving Python for use in embedded applications with NuttX.
Please consider that:
rv-virt(RISC-V QEMU). That being said, itsinterpreters/python/config.siteandinterpreters/python/Setup.localare somehow tied with the features enabled by the attached defconfig (Yes, I will submit a PR on https://github.com/apache/nuttx for it)pycmodules are loaded from a ROMFS image at startup. Therefore, we need an application to mount it (that's themount_modulesrole!).PYTHONHOMEandPYTHON_BASIC_REPLenvironment variables.Impact
Provides initial support for Python on NuttX. Please note that it supports, initially, only the
rv-virt(RISC-V QEMU) "board".Testing
Internal CI testing +
rv-virt:cpython.Building
Create a defconfig file at
nuttx/boards/risc-v/qemu-rv/rv-virt/configs/cpython/defconfigwith the following content:Build it with:
Testing
Run it with RISC-V QEMU:
On NuttX:
Check the following record to run Python
(yes, you can copy the commands from there)