Dependency management (per project) for micropython projects
Posted: 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,
Cristian
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,
Cristian