Changing download file type from uf2 to Python

Is there any way to modify a PXT target so you can download your code as a .py file rather than compiling it to uf2? Since PXT is built on blockly, I figured this should be possible but am a little uncertain where to start with this as I am not super familiar with React. Any help would be super appreciated!

@richard Any thoughts on this?

Hmmm… could you give me a little more detail about what you’re trying to do? are you just trying to download the user’s code or are you compiling the user project down into a bigger python file? what will the user do with this python file? are they going to be running it themselves or is it just for saving it?

makecode projects are projects, so they aren’t usually constrained to a single file. you’ll need some way of combining all of the user code into a single file, along with the dependency information from pxt.json

I am trying to have users be able to use Makecode to program a Raspbery Pi Pico but using a Micropython bootloader rather than the UF2 bootloader. The reason for this is the current RP2040 support does not seem to be fully functioning (analog reading and writing do not work currently) and is a bit above my head to try to fix. I figured downloading a Makecode program as a Micropython file and uploading it to the board might be an elegant solution to avoid having to mess with the CODAL and low level RP2040 support. Maybe I’m mistaken with that though.

hmmm, yeah that might be tough. our python is quite a bit different than micropython. in particular, we don’t support importing modules like micropython does.

in any case, this is the function that is called when the download button is pressed:

i generally recommend against forking pxt though

Gotcha, that all makes sense. Any idea who might be the best person to reach out to to fix the issues with the RP2040 support? If forking PXT is not advised then maybe I’ll change my direction to working with the CODAL