Comments (12)
Ok, fixed a bug with using get-frozen with version=latest #442
from micropython-stubber.
Update: I seem to be successfully using the get-frozen
get-docstubs
and merge
commands now
- get-frozen reaches into the micropython repo and reads a bunch of manifest.py files to build up a list of pyi files. I had to add a fix to get this working here: #442
- get-docstubs seems to reach into micropython/docs and 'compiles' a bunch of the RST files together and drops them into stubs/micropython--docstubs. There's no way to specify the board to my knowledge and it doesn't seem to work with version=latest, but ommitting version seems to default to latest... I'm unsure how the precedence works here - for example several 'default' values seem to appear in the output that don't seem to have a source (e.g. machine.adc init has a default value that I can't find specified anywhere). This process is a big mystical to me still - it's some kind of reverse application of sphinx?
- You can drop firmware stubs in stubs/micropython--- - e.g. micropython-latest-rp2-RPI_PICO_W in my case
- merge and get-docstubs will clean git up so if you're developing make sure you commit before running them
- my merge command looks like: stubber merge --version latest --port rp2 --board RPI_PICO_W
build
outputs into publish/micropython-latest-rp2-rpi_pico_w-stubs (note the lower case now). My build command looks likestubber build --version latest --port rp2 --board RPI_PICO_W
- I haven't worked out how to get this output into VSCode yet - about to start trying
from micropython-stubber.
My understanding of the workflow right now:
- Install micropython-stubber
- Clone micropython-stubs
mkdir repos && cd repos
- clone micropython - checkout the desired point in history and force move the 'master' branch there
- clone micropython-lib - checkout the desired point in history and force move the 'master' branch there
cd ..
(aka move to the micropython-stubs repo) and start creating the stubs:- CORE STUBS: run
stubber get-core
- This creates a bunch of folders likestubs/cpython_core-micropython
- FROZEN STUBS: run
stubber get-frozen --black --version=latest
- This should createstubs/micropython-latest-frozen
- DOCSTUBS: run
stubber get-docstubs
- this should createsstubs/micropython-latrest-docstubs
- FIRMWARE STUBS: build micropython and install it on yuour desired board & run create_stubs.py copy these firmware stubs stubs to
stubs/micropython-latest-rp2-RPI_PICO_W
- Instructions for this are elsewhere, but looks roughly like:cd repos/micropython
(aka go into the micropython repo)git submodule update --init
(aka get the submodules all checked out)make -C mpy-cross
cd ports/rp2
make BOARD=RPI_PICO_W
. Then you need to flash your version of micropython onto a board and runcreatestubs.py
(I followed instructions here: https://github.com/paulober/Pico-W-Stub/blob/main/micropython-stubber.md#generating-the-stubs). Drag the files off an drop them inmicropython-stubs/stubs/micropython-latest-rp2-RPI_PICO_W
- MERGED STUBS: run
stubber merge --version latest --port rp2 --board RPI_PICO_W
- BUILD: run
stubber build --version latest --port rp2 --board RPI_PICO_W
from micropython-stubber.
The above doesn't work - seems that the frozen stubs overwrite the merged stubs - I thiunk I need to work out how to get the micropython repo to update the frozen bits
from micropython-stubber.
Sam, thanks for your perseverance
This project started very small years ago - and has grown over time. documentation that I once wrote - has been surpassed by the reality of tools and micropython evolving.
also there is tech dept of some functionality - such as creating the firmware aka board stubs - that are not fully integrated into the packaged stubber tool, as I can't get them fully stable across all ports ( not esp8266)
writing this from memory in the train:
-
clone the micropython-stubber repo ( to get the scripts folder and the pyproject.toml file that holds the config)
-
either
pip install micropython-stubber
orpoetry install
-
stubber clone --with stubs
-
optionally
stubber clone --version v1.21.0
This will clone the micropython, -lib and -stubs repos under/repos/*
-
run
python scripts/board_stubber.py
this will run the createstubs.py on the board , run post processing , merge them with the checked out stubs , and build them ( not sure about the build step) -
the get-core command is obsoleted - it has been replaced by the get-docstubs which is actually better than get-core ever was. Il l need to deprecate that command.
from micropython-stubber.
Sam, thanks for your perseverance
This project started very small years ago - and has grown over time. documentation that I once wrote - has been surpassed by the reality of tools and micropython evolving. also there is tech dept of some functionality - such as creating the firmware aka board stubs - that are not fully integrated into the packaged stubber tool, as I can't get them fully stable across all ports ( not esp8266)
writing this from memory in the train:
- clone the micropython-stubber repo ( to get the scripts folder and the pyproject.toml file that holds the config)
- either
pip install micropython-stubber
orpoetry install
stubber clone --with stubs
- optionally
stubber clone --version v1.21.0
This will clone the micropython, -lib and -stubs repos under/repos/*
- run
python scripts/board_stubber.py
this will run the createstubs.py on the board , run post processing , merge them with the checked out stubs , and build them ( not sure about the build step)- the get-core command is obsoleted - it has been replaced by the get-docstubs which is actually better than get-core ever was. Il l need to deprecate that command.
Thanks for this and sorry for my previous impatience - felt so close to getting things working!
I think your instructions work but only for a specific tagged version. I'm testing a branch of micropython (micropython/micropython#10704) so I need to check out an arbitrary commit and generate stubs...
I notice you didn't mention using get-frozen or get-docstubs specifically but I think I will need those?
from micropython-stubber.
I never considered a specific COMMIT, only versions to be honest.
You could add a local tag based on semver. I think something like v1.20.x could work.
Also if you do not specify a version, I think most commands just leave the repost on the commit they are. Or at least that is something that can be added with little change
from micropython-stubber.
After looking at that PR I think I understand better what you are trying to do.
If there is a new DMA.rst file you'll indeed need to run get-docstubs and may need to run Get-frozen as well
Perhaps --version
should also allow PR#1234
notation, let me think on that.
Still for this specific PR it will not be of any use,
as the PR does not add/change:
- any .rst file in
docs/library
- any frozen .py file
comparing to main there are only 2 .rst files changed, however the files docs/rp2/general.rst
and docs/rp2/quickref.rst
are not used in generation stubs
so that means that you do not need to re-generate the docstubs , nor the frozen stubs.
You can recreate them , or re-use them from the nearest (lower) version
from micropython-stubber.
--version=HEAD
might be an interesting option and the produced output could be v<latest>-<sha>
or v-adhoc-<sha>
or something like that? - just some way to specify that I'd like it to be built right where we are...
Have you considered not checking in anything that is generated by the build? that might have made things clearer for me personally.
from micropython-stubber.
you considered not checking in anything that is generated by the build?
Nothing is checked in automatically by the stubber
from micropython-stubber.
just some way to specify that I'd like it to be built right where we are...
It already does that, if you just do not specify a version
Or do you have a specific command where you find this does not work?
All output that is not a specific tag, is considered 'latest', as that's exactly what I need, and keeps me from needing to do quite complex version resolution,
I see that if you are working on a year old PR that that is confusing, but it still works if you mentally time travel back to that PR.
It may be useful for your scenario if you remove all -latest- folders
Naming convention.
I do not think that using the Git hash for versioning is useful. It does not follow semver, nor is it human readable.
Also I do not see how it would be helpful in your scenario.
I may consider adding the pre-release build nr, now that that is adopted by micropython.
Still that would be 1.22.0-B1 and newer, and not solve parallel branches such as a PR or a fork
from micropython-stubber.
It already does that, if you just do not specify a version Or do you have a specific command where you find this does not work?
Yea, I'm not sure that's working for me, OR I'm getting confused!
I think I couldn't find a way to get this to work for the merge and get-docstub commands because of this 'switch branch' command.
Latest also seems to be the default for those commands:
It may be useful for your scenario if you remove all -latest- folders
That might be a good idea
Nothing is checked in automatically by the stubber
Sorry I meant the stubs library - are the outputs, of e.g. 'generate docstubs' not checked in there? Could these be viewed as intermediate-generate files?
I do not think that using the Git hash for versioning is useful. It does not follow semver, nor is it human readable.
Also I do not see how it would be helpful in your scenario.
Sorry I mean something like:
v1.19.0-a64d88
or
v-adhoc-a64d88
I have seen it as quite common practice to include a non-human-readable portion to version numbers (e.g. SHAs or build numbers) even for releases - this allows developer traceability back to a specific commit and build (as version numbers can be a little 'blurry' sometimes).
It would help my scenario of debug-devolpment because I could produce builds that I can produce stub builds that would let me easily identify where they came from...
It's been a week or so since I needed to touch this issue so some of this is from memory so sorry if this is a bit of a nonsensical reply :D
from micropython-stubber.
Related Issues (20)
- Add sample for mpy escaping
- Pin and Signal should be callable
- MPFlash unnecessarily verbose error message HOT 2
- MPFlash list output doesn't fit a standard terminal HOT 4
- mpflash: rp2 download fails HOT 3
- Mpflash error flashing blank esp32
- Mpflash error flashing. UF2 on macos HOT 1
- MPflash: unable to flash rp2040 /.uf2 on macos HOT 13
- mpflash: does not identify 'ESP32 module with ESP32' v1.13 HOT 1
- mpflash: Failing flash without --serial HOT 4
- mpflash: Improve HTTP error handling HOT 3
- Mpflash - : use 1200 Bd to reset boards to bootloader HOT 2
- Add tls module HOT 1
- mpflash: unable to download PICO firmware due to changed BOARD_ID HOT 4
- mpflash: non-zero return code to indicate no device found HOT 7
- MPFlash: Failed flash in CI should return error HOT 1
- stubber createstubs aborts on error while stubbing one board
- MPFlash: ask_input tests fail in CI
- MPFlash: implement erase for RPI_PICO and other boards
- stubber: get_frozen fails for ARDUINO boards that depend on arduino_lib HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython-stubber.