Command line Application for automating Micropython project setup and management in Visual Studio Code.
Project description
Micropy Cli
![Coverage Status](https://pypi-camo.freetls.fastly.net/8eb528d97868ed1eb4fa06563df3e7b84521c9fe/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f42726164656e4d2f6d6963726f70792d636c692f62616467652e737667)
Micropy Cli is a project management/generation tool for writing Micropython code in modern IDEs such as VSCode. Its primary goal is to automate the process of creating a workspace complete with:
- Linting compatible with Micropython
- VSCode Intellisense
- Autocompletion
- Dependency Management (WIP)
- VCS Compatibility
Installation
You can download and install the latest version of this software from the Python package index (PyPI) as follows:
pip install --upgrade micropy-cli
Usage
Usage: micropy [OPTIONS] COMMAND [ARGS]...
CLI Application for creating/managing Micropython Projects.
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
init Create new Micropython Project
stubs Manage Micropy Stubs
Creating a Project
Creating a new project folder is as simple as:
- Executing
micropy init <PROJECT NAME>
- Selecting your target device/firmware
- Boom. Your workspace is ready.
Micropy Project Environment
When creating a project with micropy-cli
, two special items are added:
- A
.micropy/
folder - A
micropy.json
file
The .micropy/
contains symlinks from your project to your $HOME/.micropy/stubs
folder. By doing this, micropy can reference the required stub files for your project as relative to it, rather than using absolute paths to $HOME/.micropy
. How does this benefit you? Thanks to this feature, you can feel free to push common setting files such as settings.json
and .pylint.rc
to your remote git repository. This way, others who clone your repo can achieve a matching workspace in their local environment.
Note: The generated
.micropy/
folder should be IGNORED by your VCS. It is created locally for each environment via themicropy.json
file.
The micropy.json
file contains information micropy needs in order to resolve your projects required files when other clone your repo. Think of it as a package.json
for micropython.
Cloning a Micropy Environment
To setup a Micropy environment locally, simply:
- Install
micropy-cli
- Navigate to the project directory
- Execute
micropy
Micropy will automatically configure and install any stubs required a project thanks to its micropy.json
file.
Stub Management
Stub files are the magic behind how micropy allows features such as linting, Intellisense, and autocompletion to work. To achieve the best results with MicropyCli, its important that you first add the appropriate stubs for the device/firmware your project uses.
Note: When working in a micropy project, all stub related commands will also be executed on the active project. (i.e if in a project and you run
micropy stubs add <stub-name>
, then that stub retrieved AND added to the active project.)
Adding Stubs
Adding stubs to Micropy is a breeze. Simply run: micropy stubs add <STUB_NAME>
By sourcing micropy-stubs, MicroPy has several premade stub packages to choose from.
These packages generally use the following naming schema:
<device>-<firmware>-<version>
For example, running micropy stubs add esp32-micropython-1.11.0
will install the following:
- Micropython Specific Stubs
- ESP32 Micropython v1.11 Device Specific Stubs
- Frozen Modules for both device and firmware
You can search stubs that are made available to Micropy via micropy stubs search <QUERY>
Alternatively, using micropy stubs add <PATH>
, you can manually add stubs to Micropy.
For manual stub generation, please see Josvel/micropython-stubber.
Creating Stubs
Using micropy stubs create <PORT/IP_ADDRESS>
, MicropyCli can automatically generate and add stubs from any Micropython device you have on hand. This can be done over both USB and WiFi.
Viewing Stubs
To list stubs you have installed, simply run micropy stubs list
.
To search for stubs for your device, use micropy stubs search <QUERY>
.
Acknowledgements
Micropython-Stubber
Josverl's Repo is full of information regarding Micropython compatibility with VSCode and more. To find out more about how this process works, take a look at it.
micropy-cli and micropy-stubs depend on micropython-stubber for its ability to generate frozen modules, create stubs on a pyboard, and more.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for micropy_cli-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c688a5fb45783b84a2bace2a72b4d6115c7927e73504c468cd5ae3444c777a3d |
|
MD5 | 3395bc10da888a18b53ddaf79362e4e4 |
|
BLAKE2b-256 | 3b9d60f5b2632d8340f6b9670bf56ac1b45300e70d2281433ac103e8aa77d6fa |