Replies: 4 comments 10 replies
-
MicroPython doesn't have a TOML parser in micropython-lib, so using device-side This seems to mostly duplicate the function of package.json, which is already in mip and documented too. |
Beta Was this translation helpful? Give feedback.
-
I also miss |
Beta Was this translation helpful? Give feedback.
-
As suggested by @aivarannamaa above, the Another approach might be to specify the dependencies in the Main uses for the
DEs generally get tooling configs from the DE configs (eg. The new-ish For development in the cpython world, I use For development in micropython it would be useful to have a command which performs similar actions:
When deploying the package during development, the package and dependencies could be installed from the local micropython "venv". Then I have an all-local environment I can preserve and rebuild for reproducible deployments. If the |
Beta Was this translation helpful? Give feedback.
-
I think that the new ROMFS facility adds something to the mix .. I can envisage some tool taking a set of package descriptions plus (local) files, deploying them to a directory, then generating a ROMFS image of that directory. This could then be deployed to a device using mpremote. The goal here would be some way to automatically build a deployable application using CI or on a build server. As a further refinement, if there were a way to combine a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was thinking to add a
-r/--requirement
option tompremote mip install
command, to allow installing packages from a requirements file.This is a common feature in Python package managers, and it would be useful for users who want to install multiple packages at once. urrently the only option is to chreate a shell script ( .ps1/.sh/zsh/....) that calls
mpremote mip install
for each package.The primary goal would be is to add a -r/--requirement option to
mpremote mip install
command, to allow installing packages from a requirements file.I want to focus on the
mpremote mip
package manager, and not attempt to implement all capabilities in themip module
available in the MicroPython runtime, as not all features available inmpremote mip
package manager make sense inmip
module .Some changes, such as changes to the dependency specifiers, should be reflected in the
mip module
as wellA requirements file:requirements.txt
- A text file listing the dependencies required for the project, commonly used in Python projects.package.json
file , with additional featurespyproject.toml
- A configuration file for Python projects that can specify dependencies and build system requirements.requirements-mip.lock
- A file that records the exact versions of dependencies to ensure reproducible installations.I want to initially focus on the 'package.json' and pyproject.toml file, as these are the most common formats used in Python projects.
I have not spend efforts on the lock file yet , as that would also mean implementing a resolver for the dependencies, which is not trivial.
Hoever even if the lock file is not part of the initial PR, I think it would be a good idea to consider the structure / format so that it would be possible to install based on a lock file in the future in order to achieve reproducible installations.
@aivarannamaa , do you have suggestions on this ?
Related conversations:
using the micropython
package.json
format from a local file [Added]In a merged but not yet released version of mpremote the command
mpremote mip install <package_name>.json
will install the defined content of that package.https://docs.micropython.org/en/latest/reference/packages.html#writing-publishing-packages
Note: All files and modules will be deployed to the same directory.
while it is possible to use a mpremote
--target
option to specify a target directory,it is not possible to use the
--target
option to specify a target directory for each file or module in the package.json file.To deploy a micropython solution to a device using dependencies will, in its current form, require multiple package files. One to install the dependencies, and one for the main application.
I do not think that they can be combined in a single file, but that would be a nice feature to have. Note that the same will need to be handled for the pyproject.toml file as well.
Any integration with other python tooling tooling, such as for the installation or configuration of formnatters , linters and static type checking will need to be added, or handled in other configuration files such as pyproject.toml.
Whilhile it is possible for additional nodes to be addedd to the package.json file, some additional guidance, and possible a official schema would be useful to help users understand how to use the package.json file for their projects.
I think the documentation on the use of a local package.json file for deployment to a device should be improved, as I could not find a clear description of how to use this, and what the limitations are.
using the pyproject.toml file format.
Similar to the requirements file, it should be possible to use a
pyproject.toml
file to specify the dependencies for a micropython project. This is a common file format used in Python projects, and it would be useful for users who want to specify their dependencies in a standard way, and allow for a single configuration file for the project.This would allow users to use the same file format for
mpremote mip
as they do for other Python projects, making it easier to share micropython projects, including their dependencies.The
pyproject.toml
file should be a standard toml file, with a[project]
section for the project metadata, and a[tool.mpremote]
section for the mip dependencies.mpremote mip install -r pyproject.toml
File:
pyproject.toml
:The use of the
[tool.mpremote]
table is linked to the name of the mpremote package on PiPIthe name
mip
seems a logical location , leaving room for other configuration, but there are other options as well.I'm open to alternatives here to cover additional scenarios, as after reading it is simply a dict with a list of packages.
packages = toml_data['tool']['mpremote']['mip']
We could extend to handle different ports , or groups similar to [extras]
using the requirements.txt formatThere is little or no use for a requirements.txt format as with 1.25.0 mpremote will be able to use package.json files ( which I initially overlooked)
requirements.txt is no longer considered
It should be possible to use a requirements file format that is compatible with the
pip
package manager.This would allow users to the simple requirements file format for
mpremote mip
, making it easier to share MicroPython projects, including their dependencies.mpremote mip install -r requirements-mip.txt
will install the requirements from
requirements-mip.txt
file:File:
requirements-mip.txt
The requirements file format is a simple text file with one package per line, or a comment line starting with
#
.Note: The https://pip.pypa.io/en/stable/reference/requirements-file-format/ requirement file format has (many) additional features that are not supported by
mpremote mip install
, such as:-e
for editable installs-r
for including other requirements files-c
for constraints filesPEP 508 Dependency specifiers ( all formats)
mip does not currently recognize the PEP 508 dependency specifiers. Instead it uses the
@
sign to denote a version specifier.However thr @ sign is not a standard way to specify dependencies in Python packaging. The PEP 508 standard uses the
==
operator for exact version matching.Also the
@
sign is also used in the mip module to denote a branch or tag in a git repository.I think it would be better to use the PEP 508 standard for version specifiers in mip, and use the
==
operator for exact version matching. This would make it more consistent with other Python packaging tools and avoid confusion with the@
sign used for git repositories.To allow for backwards compatibility, mip should still recognize the
@
version specifiers, but apart from GitHub and GitLab sources, I propose it should be deprecated in favor of the==
per PEP 508 standard.https://packaging.python.org/en/latest/specifications/dependency-specifiers/#dependency-specifiers
Exerpt from PEP 508:
Currently mip only recognizes the
==
operator for exact version matching, or specifies the most recent version available.While I think that there is benefit to adding support for the remaining version specifiers in PEP 508, I am not sure if there is suffient of a use case for this.
While there are multiple packages that have multiple published versions , I am not sure if there currently is a need end users to specify a version range for a package as there are cureenltly only a few packages that have more than 2 published versions.
I think that the most common use case for mip are
Proof of concept
A limited PoC is located in my fork of micropython.
👷try it:
uv pip install git+https://github.com/Josverl/micropython.git@mpr/mip_requirements_file#subdirectory=tools/mpremote
( slow even with uv due to the size of the micropython repo, but it works)
Beta Was this translation helpful? Give feedback.
All reactions