GithubHelp home page GithubHelp logo

bradenm / micropy-stubs Goto Github PK

View Code? Open in Web Editor NEW
29.0 5.0 6.0 1.52 MB

Automatically Generated Stub Packages for Micropy-Cli and whomever else

License: Other

Python 100.00%
micropython micropy-cli stubs python microcontroller

micropy-stubs's Introduction

Micropy Stubs

Note: This is currently a WIP. The end goal is to have a mostly automated method of creating 'stub packages' with device-specific and firmware-specific modules included for micropy-cli. Also, as it was originally aimed at being a quick script for personal use, the code is a bit of a mess. A refactor with tests will be coming soon.

Crawls file tree looking for info.json files, sorting them by either firmware or device.

If a firmware file is found, it creates the file structure required and downloads/stubs firmware specific modules.

If a device file is found, it will then download its required modules and stub them. The initial info file and device stubs must be added manually.

Please refer to the example directory for more information.

Credits

This is heavily inspired by (and even uses) Josvel's micropython-stubber. All credit for the stub generation in this project goes to him and those who aided him.

micropy-stubs's People

Contributors

actions-user avatar bradenm avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

micropy-stubs's Issues

Pycom stub not recognized

Dear maintainer

I have issues getting the pycom stub recognized when initializing a project. I have the LoPy4 board.
Searching:
image

Installing:
image
I see the stub being downloaded to %userprofile%.micropy\stubs

Initializing the project:
image

Then this hits:
image

The micropy.log file doesn't contain anything more detailed than these same messages. I have reached out to Pycom to ask if they have official stubs available.

I also tried creating a stub myself, using the micropy stubs create. After applying the patch to the pybwrapper.py file, I got to a stage where it says copying stub, but there it sits for 20 minutes. I haven't filed an issue for this yet, can do it over at the other repo if needed.

Cannot create stubs on WiPy

I tried creating stubs for my WiPy, but got this error message at the end. Any ideas on what may cause this?

C:\Users\Jonathan\Documents\GitHub\weather-station>micropy stubs create COM7

MicroPy  Connecting to Pyboard @ COM7
MicroPyConnected!
MicroPy  Executing stubber on pyboard...
MicroPy  Pyboard  Stub module: uasyncio/core
MicroPy  Pyboard  Stub module: umqtt/robust
MicroPy  Pyboard  Stub module: umqtt/simple
MicroPy  Pyboard  Stub module: urllib/urequest
MicroPy  Pyboard  Stub module: _thread
MicroPy  Pyboard  Stub module: ak8963
MicroPy  Pyboard  Stub module: apa102
MicroPy  Pyboard  Stub module: apa106
MicroPy  Pyboard  Stub module: array
MicroPy  Pyboard  Stub module: binascii
MicroPy  Pyboard  Stub module: btree
MicroPy  Pyboard  Stub module: builtins
MicroPy  Pyboard  Stub module: cmath
MicroPy  Pyboard  Stub module: collections
MicroPy  Pyboard  Stub module: crypto
MicroPy  Pyboard  Stub module: curl
MicroPy  Pyboard  Stub module: dht
MicroPy  Pyboard  Stub module: display
MicroPy  Pyboard  Stub module: ds18x20
MicroPy  Pyboard  Stub module: errno
MicroPy  Pyboard  Stub module: e p
MicroPy  Pyboard  Stub module: esp32
MicroPy  Pyboard  Stub module: flashbdev
MicroPy  Pyboard  Stub module: framebuf
MicroPy  Pyboard  Stub module: freesans20
MicroPy  Pyboard  Stub module: functools
MicroPy  Pyboard  Stub module: gc
MicroPy  Pyboard  Stub module: gsm
MicroPy  Pyboard  Stub module: hashlib
MicroPy  Pyboard  Stub module: heapq
MicroPy  Pyboard  Stub module: inisetup
MicroPy  Pyboard  Stub module: io
MicroPy  Pyboard  Stub module: json
MicroPy  Pyboard  Stub module: logging
MicroPy  Pyboard  Stub module: lwip
MicroPy  Pyboard  Stub module: machine
MicroPy  Pyboard  Stub module: math
MicroPy  Pyboard  Stub module: microWebSocket
MicroPy  Pyboard  Stub module: microWebSrv
MicroPy  Pyboard  Stub module: microWebTemplate
MicroPy  Pyboard  Stub module: micropython
MicroPy  Pyboard  Stub module: mpu6500
MicroPy  Pyboard  Stub module: mpu9250
MicroPy  Pyboard  Stub module: neopixel
MicroPy  Pyboard  Stub module: network
MicroPy  Pyboard  Stub module: ntptime
MicroPy  Pyboard  Stub module: onewire
MicroPy  Pyboard  Stub module: os
MicroPy  Pyboard  Stub module: port_diag
MicroPy  Pyboard  Stub module: pycom
MicroPy  Pyboard  Stub module: pye
MicroPy  Pyboard  Stub module: random
MicroPy  Pyboard  Stub module: re
MicroPy  Pyboard  Stub module: requests
MicroPy  Pyboard  Stub module: select
MicroPy  Pyboard  Stub module: socket
MicroPy  Pyboard  Stub module: ssd1306
MicroPy  Pyboard  Stub module: ssh
MicroPy  Pyboard  Stub module: ssl
MicroPy  Pyboard  Stub module: struct
MicroPy  Pyboard  Stub module: sys
MicroPy  Pyboard  Stub module: time
MicroPy  Pyboard  Stub module: tpcalib
MicroPy  Pyboard  Stub module: ubinascii
MicroPy  Pyboard  Stub module: ucollections
MicroPy  Pyboard  Stub module: ucryptolib
MicroPy  Pyboard  Stub module: uctypes
MicroPy  Pyboard  Stub module: uerrno
MicroPy  Pyboard  Stub module: uhashlib
MicroPy  Pyboard  Stub module: uheapq
MicroPy  Pyboard  Stub module: uio
MicroPy  Pyboard  Stub module: ujson
MicroPy  Pyboard  Stub module: uos
MicroPy  Pyboard  Stub module: upip
MicroPy  Pyboard  Stub module: upip_utarfile
MicroPy  Pyboard  Stub module: urandom
MicroPy  Pyboard  Stub module: ure
MicroPy  Pyboard  Stub module: urequests
MicroPy  Pyboard  Stub module: uselect
MicroPy  Pyboard  Stub module: usocket
MicroPy  Pyboard  Stub module: ussl
MicroPy  Pyboard  Stub module: ustruct
MicroPy  Pyboard  Stub module: utime
MicroPy  Pyboard  Stub module: utimeq
MicroPy  Pyboard  Stub module: uwebsocket
MicroPy  Pyboard  Stub module: uzlib
MicroPy  Pyboard  Stub module: websocket
MicroPy  Pyboard  Stub module: websocket_helper
MicroPy  Pyboard  Stub module: writer
MicroPy  Pyboard  Stub module: ymodem
MicroPy  Pyboard  Stub module: zlib
MicroPyDone!
MicroPy  Copying stubs...
Source directory /pyboard/stubs does not exist.
Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\micropy.exe\__main__.py", line 9, in <module>
  File "c:\python38\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\python38\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\python38\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python38\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python38\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python38\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\python38\lib\site-packages\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\python38\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\python38\lib\site-packages\micropy\cli.py", line 280, in create
    return mpy.create_stubs(port, verbose=verbose)
  File "c:\python38\lib\site-packages\micropy\main.py", line 124, in create_stubs
    stub_path = next(out_dir.iterdir())
StopIteration

Contributing page

After quickly looking around, I still don't get it, how to properly contribute 😄
Would be awesome to see an example of full workflow on how to contribute to the stubs repo.
For example, the MicroPython ESP32 network library's WiFi class is not even a class 🤔

uBluetooth or bluetooth

I am using a M5Stack Fire with SPRAM for development. I installed the stub esp32-micropython-1.12.0, but I am unable to find either network.Bluetooth class or the top-level ubluetooth class mentioned by the official MicroPython doc from the VS Code code autocomplete. Could you help me understand what went wrong? Thanks

Licence type

Hi Braden,

would you consider changing the license type to MIT ?

currently the GPL license you have added on top of the MIT work I have done , prevents me from using your work. which is a shame

/jos

Use Repo as Stub Source

Setup this Git repository to work as a Stub Source (primarily for micropy-cli).

Basic Idea:

  • Automate the creation of a "package branch" for each stub package. This branch's root is created from the git tree object on the master branch. (ex. origin/master/micropython-official/v1.11/esp32 == origin/pkg/esp32-micropython-1.11

  • Use Githubs integration of git archive to download [stub_pkg].tar.gz files from this repo.

  • Automate upkeep of a repo.json file in the project root which has the following basic schema:

{
  "name": "repo-code-name",
  "location": "https://url.com/repo.json",
  "path": "https://cdn.url.com/repo/branch",
  "packages": [
    {
      "name": "esp32-micropython-1.11",
      "path": "pkg/esp32-micropython-1.11.tar.gz",
      "type": "device",
      "version": "0.0.0"
    }
  ]
}

Stubs for Raspberry Pi Pico

Hi!

Having found this wonderful tool I wanted to try and generate stubs for my shiny new Rasberry Pi Pico. However, I fell at the first hurdle as it seems that the Pico does not have all of the MicroPython modules required to enable the generation of the stubs. It first fails with an import error for the errno module, which is relatively easily fixed by copying the python source for that module onto the board.

The much bigger problem, and where I've hit the wall, is that the MicroPython port for the pico does not have the ujson module, which is required by the stubber. Presumably, as this board has no network access the Pi foundation saw no reason to include a network-focused serialization mechanism like JSON. This does leave us a bit out of luck when it comes to generating stubs though.

As far as I can tell ujson is a C module and has to be included at compile time of the MicroPython firmware. Short of compiling my own custom firmware for the Pico, which could be fun, is there another way to make this work? I'm pretty proficient with CPython, and I've done some C for Arduino before, but this is my first venture into MicroPython.

If not is there an existing set of stubs for a board with a similar feature set that might be appropriate to use?

ESP32 v1.13 stubs?

Hello! Love your project, I'm working on a project that requires micropython v1.13 on the ESP32

Right now I'm using the stubs for version 1.12 but it would be awesome if Visual Studio Code wasn't giving me fake errors.

I noticed that Josverl has the stubs for the ESP32 v1.13:
https://github.com/Josverl/micropython-stubs/blob/master/firmwares.md

Would it be possible to update your list of stubs to include the latest version of micropython for the ESP32?

Thanks!!!!
-Ben

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.