Commit 85c85e8f authored by Olivier Lenoir's avatar Olivier Lenoir Committed by Damien George

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: default avatarOlivier Lenoir <olivier.len02@gmail.com>
parent 025d10a7
...@@ -80,3 +80,4 @@ Examples: ...@@ -80,3 +80,4 @@ Examples:
mpremote cp -r dir/ : mpremote cp -r dir/ :
mpremote mip install aioble mpremote mip install aioble
mpremote mip install github:org/repo@branch mpremote mip install github:org/repo@branch
mpremote mip install gitlab:org/repo@branch
...@@ -214,7 +214,7 @@ def argparse_mip(): ...@@ -214,7 +214,7 @@ def argparse_mip():
cmd_parser.add_argument( cmd_parser.add_argument(
"packages", "packages",
nargs="+", 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 return cmd_parser
......
...@@ -65,6 +65,18 @@ def _rewrite_url(url, branch=None): ...@@ -65,6 +65,18 @@ def _rewrite_url(url, branch=None):
+ "/" + "/"
+ "/".join(url[2:]) + "/".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 return url
...@@ -116,6 +128,7 @@ def _install_package(transport, package, index, target, version, mpy): ...@@ -116,6 +128,7 @@ def _install_package(transport, package, index, target, version, mpy):
package.startswith("http://") package.startswith("http://")
or package.startswith("https://") or package.startswith("https://")
or package.startswith("github:") or package.startswith("github:")
or package.startswith("gitlab:")
): ):
if package.endswith(".py") or package.endswith(".mpy"): if package.endswith(".py") or package.endswith(".mpy"):
print(f"Downloading {package} to {target}") print(f"Downloading {package} to {target}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment