Skip to content

Document how to generate stubs for a branch or fork of MicroPython? #441

@samskiter

Description

@samskiter

Describe the bug
I've tried 2 or 3 times to work out how to use this to generate stubs for a custom micropython build for the RPi Pico W but I'm really struggling!

Here's what I've tried/gleaned so far:

  • Some stubs can be generated on the board itself. I've managed to do this - I don't know if it's correct and I don't know where the firmware stubs are stored in the Stubs (https://github.com/Josverl/micropython-stubs) repo)
  • There's some docstubs which can be generated from the micropython repository. These get stored in the stubs folder under some some directory called 'micropython--docstubs'
  • There's some 'frozen' stubs - I don't know where these come from, I've managed to run get-frozen but don't know where the stubs that are 'got' are stored. I have tried deleting the stubs directory and rerunning get-frozen but despite apparent success, no folders seem to be created
  • There's some 'core' stubs - get-core doesn't seem to create a micropython-core directory.
  • There's merging stubs which produces a new directory with 'merged' in the name. I don't know how or whether this is used in later steps
  • There's building the stubs - which uses the frozen and docstubs and maybe the generated stubs from the device. It presumably uses the merged directory? but it also seems to look for the frozen directory?
  • There's a specific directory structure I need to check out. According to this I need to check out 4 repositories side-by-side and setup a symlink. But I think that's out of date, according to the docstring here in the github action: https://github.com/Josverl/micropython-stubs/blob/main/.github/workflows/get-all-frozen.yml

My guess for what I should do:

  1. pip install micropython-stubber
  2. checkout micropython-stubs
  3. mkdir 'repos' inside micropython-stubs
  4. checkout micropython & micropython-lib inside repos and checkout to the commit I want to generate stubs for.
  5. Create a master branch at that commit
  6. Run build of micropython for my pico w (do I need to do this?)
  7. install micropython onto the pico w
  8. Run create_stubs.py on the pico w (is this necessary?)
  9. copy the generated stubs off the pico and place them into a folder inside micropython-stubs/stubs named micropython-latest-rp2-RPI_PICO_W
  10. Run stubber get-frozen --black --version=latest
  11. stubber get-docstubs
  12. Run stubber merge --version latest --board RPI_PICO_W
  13. Run stubber build --version latest --port rp2 --board RPI_PICO_W

This just isn't working for me - I'm getting failures about missing frozen stubs and all sorts - I must be doing something fundamentally wrong here or misunderstanding what's already checked in and what needs to be generated

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions