Dependency management (per project) for micropython projects

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Posts: 7
Joined: Wed Aug 28, 2019 5:07 am

Dependency management (per project) for micropython projects

Post by cristian.spiescu » Thu Aug 29, 2019 8:01 pm

Hi there!

As far as I know, Python doesn't have tooling for managing dependencies local to a project. E.g. "project 1" uses "numpy v1.10". But "project 2" uses "numpy v1.17". Modules in Python (i.e. installed via "pip") are installed globally. Hence the existence of virtual environments managed via tools such as Anaconda/Miniconda.

In other languages, dependencies are local to a project. E.g. in Java via Maven. In JS via npm.

I think when developing using micropython for embedded devices, a tool such as "npm" would be helpful. I.e. in the project dir to have a file (the equivalent of "package.json") that would say: for this project I need:

* micropython-scron v0.7.0 - from PyPI
* uMail v0.3.2 - from some Git repo
* etc

And then, run a command (e.g. the equivalent of "npm install") and then all this deps would be downloaded and stored in a dir, e.g. "my-project/lib". And then this dir would be copied to the micropython board.

I have 2 questions:

1) the kind of flow described above is maybe aleady doable with an existing combination of tools and practices?
2) if not, do you think this would be helpful? I tried upip, but 1) in my case it didn't work (board reset); 2) reading through the forum I see others complain about the stability of this tool; 3) I understand that a package need to be published to PyPI; source code hosted e.g. on GitHub doesn't seem to work through pip/upip;

Best regards,

User avatar
Posts: 6
Joined: Thu Jul 11, 2019 6:29 am

Re: Dependency management (per project) for micropython projects

Post by BradenM » Sat Sep 07, 2019 5:07 am

Hi cristian,

You might be interested in a project I've been working on called micropy-cli.

While it's primary purpose is bringing intellisense/autocompletion/linting to micropython, it also has a dependency management system built in with most of the features you stated.

It accomplishes this through a micropy.json file, which is inspired by npm's package.json. See this example:

Code: Select all

    "name": "MyCoolProject",
    "stubs": {
        "esp8266-pycopy-1.11.0": "1.2.0"
    "config": {
        "vscode": true,
        "pylint": true
    "packages": {
        "blynklib": "*",
        "mPython-hcsr04": "*",
        "picoweb": "==1.7.4"
    "dev-packages": {
        "micropy-cli": "*",
        "rshell": "*"
With this, it automatically generates/upkeeps a requirements.txt and dev-requirements.txt file. And other users can replicate the environment by executing micropy in the project directory (similiar to npm install).

The primary purpose of this for micropy-cli is to enable the linting/intellisense features for external dependencies, and as such, it does not currently implement automatically copying the files to the device. I considered adding it, but ultimately decided it was best not too due to the lack of a "universal" method of installing a module/package (could be done in /lib, as a frozen module, copied/pasted, etc). This way, it lets whomever install the dependencies whichever way they want, rather than being forced into a set method.

If you're interested, you can find much more info here:

Github Page README

VSCode IntelliSense, Autocompletion & Linting capabilities (Article written by LemaRiva) - Includes info about combining the pymakr extension to handle copying/retrieving files


Posts: 7
Joined: Wed Aug 28, 2019 5:07 am

Re: Dependency management (per project) for micropython projects

Post by cristian.spiescu » Sat Sep 07, 2019 9:06 am

Hi Braden!

What a neat project!

I'll give it a spin.

Best regards,

Post Reply