From c9d6cca0d03d0a1713a82f8becc1e9eeb26bdfdd Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Mon, 12 Jun 2023 08:43:51 +0200 Subject: [PATCH] tools/mpremote/mpremote/mip: Allow target dir in package deps. Signed-off-by: Jonas Scharpf --- docs/reference/packages.rst | 12 ++++++++++-- tools/mpremote/mpremote/mip.py | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/reference/packages.rst b/docs/reference/packages.rst index c9deedea77..3e2d4baf35 100644 --- a/docs/reference/packages.rst +++ b/docs/reference/packages.rst @@ -120,7 +120,12 @@ A typical ``package.json`` for an example ``mlx90640`` library looks like:: "deps": [ ["collections-defaultdict", "latest"], ["os-path", "latest"], - ["github:org/micropython-additions", "main"] + ["github:org/micropython-additions", "main"], + [ + "folder/file.py", + "github:other_org/repo/src/some_file.py", + "1.7.4" + ] ], "version": "0.2" } @@ -130,7 +135,10 @@ This includes two files, hosted at a GitHub repo named the device. It depends on ``collections-defaultdict`` and ``os-path`` which will be installed automatically from the :term:`micropython-lib`. The third dependency installs the content as defined by the ``package.json`` file of the -``main`` branch of the GitHub repo ``org/micropython-additions``. +``main`` branch of the GitHub repo ``org/micropython-additions``. The last +dependency installs the single file ``some_file.py`` of the GitHub repo +``other_org/repo`` located in the subfolder ``src`` as ``folder/file.py`` based on +the ``1.7.4`` tag. Freezing packages ----------------- diff --git a/tools/mpremote/mpremote/mip.py b/tools/mpremote/mpremote/mip.py index f42c7a0b42..ee6c5c21d0 100644 --- a/tools/mpremote/mpremote/mip.py +++ b/tools/mpremote/mpremote/mip.py @@ -107,7 +107,11 @@ def _install_json(transport, package_json_url, index, target, version, mpy): for target_path, url in package_json.get("urls", ()): fs_target_path = target + "/" + target_path _download_file(transport, _rewrite_url(url, version), fs_target_path) - for dep, dep_version in package_json.get("deps", ()): + for sublist in package_json.get("deps", ()): + if len(sublist) == 2: + dep, dep_version = sublist[0], sublist[1] + else: + target, dep, dep_version = sublist[0], sublist[1], sublist[2] _install_package(transport, dep, index, target, dep_version, mpy)