From 85c85e8f0d6e44827553f67a4ab67c2cb3078fdd Mon Sep 17 00:00:00 2001 From: Olivier Lenoir Date: Wed, 13 Mar 2024 21:51:22 +0100 Subject: [PATCH] tools/mpremote: Add support to mip install from GitLab. Changes are: - main.py: Add gitlab:org/repo, gitlab:org/repo@branch. - mip.py: Implement install from GitLab. - README.md: Add mip install gitlab:org/repo@branch example. Signed-off-by: Olivier Lenoir --- tools/mpremote/README.md | 1 + tools/mpremote/mpremote/main.py | 2 +- tools/mpremote/mpremote/mip.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/mpremote/README.md b/tools/mpremote/README.md index 4eb1b86fb4..3d428f1287 100644 --- a/tools/mpremote/README.md +++ b/tools/mpremote/README.md @@ -80,3 +80,4 @@ Examples: mpremote cp -r dir/ : mpremote mip install aioble mpremote mip install github:org/repo@branch + mpremote mip install gitlab:org/repo@branch diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py index eeb9cbd989..e4d15fb47c 100644 --- a/tools/mpremote/mpremote/main.py +++ b/tools/mpremote/mpremote/main.py @@ -214,7 +214,7 @@ def argparse_mip(): cmd_parser.add_argument( "packages", nargs="+", - help="list package specifications, e.g. name, name@version, github:org/repo, github:org/repo@branch", + help="list package specifications, e.g. name, name@version, github:org/repo, github:org/repo@branch, gitlab:org/repo, gitlab:org/repo@branch", ) return cmd_parser diff --git a/tools/mpremote/mpremote/mip.py b/tools/mpremote/mpremote/mip.py index f42c7a0b42..46c9686ad1 100644 --- a/tools/mpremote/mpremote/mip.py +++ b/tools/mpremote/mpremote/mip.py @@ -65,6 +65,18 @@ def _rewrite_url(url, branch=None): + "/" + "/".join(url[2:]) ) + elif url.startswith("gitlab:"): + url = url[7:].split("/") + url = ( + "https://gitlab.com/" + + url[0] + + "/" + + url[1] + + "/-/raw/" + + branch + + "/" + + "/".join(url[2:]) + ) return url @@ -116,6 +128,7 @@ def _install_package(transport, package, index, target, version, mpy): package.startswith("http://") or package.startswith("https://") or package.startswith("github:") + or package.startswith("gitlab:") ): if package.endswith(".py") or package.endswith(".mpy"): print(f"Downloading {package} to {target}")