Embed

MicroPython is built to sit inside another program. The official paths are C (the embed port) and JavaScript (the webassembly port). Other languages FFI to one of those two.

C and C++

ports/embed produces a small set of sources you compile into your firmware or desktop app. You own main, the heap, and any native modules you register. Typical calls:

mp_embed_init(heap, sizeof heap);
mp_embed_exec_str("print(1 + 2)");
mp_embed_deinit();
Shape of the embed API — see ports/embed

This is the Lua-style embedding story. Expose your own C functions with MP_DEFINE_CONST_FUN_OBJ and a globals dict. The C modules chapter covers the macros.

JavaScript and the browser

ports/webassembly builds micropython.mjs and micropython.wasm. PyScript uses this. You get runPython, proxies between JS objects and Python, and a js module. You do not get machine.Pin — there is no SoC. For GPIO in a browser, use a board emulator instead.

const mp = await loadMicroPython();
mp.runPython("print(1 + 2)");
Official WASM port

Other languages

There is no first-party PHP, Go or Rust host kit yet. The practical routes today:

What embedding cannot do

Host kits run the language. They do not magically grow Pico GPIO. To script real pins you either run on the device, or you run an emulator that models those pins and load the same firmware.