mip: package installation using GitLab URLs for repos in subgroups
This is more of an awareness piece and something to trigger a discussion. There is also the possibility that I am wrong and the installation process is working as intended.
I'm currently developing MicroPython packages on GitLab, which sit inside a 'Libraries' subgroup, which is inside a parent 'MicroPython IoT Projects' group.
Due to the way that the mip _rewrite_url function parses GitLab and GitHub URLs, the assumption is made that the first component after splitting the URL, is the org and the second is the repository slug, which doesn't account for subgroups.
https://github.com/micropython/micropython-lib/blob/96bd01ec047923c15bf936d2f77043968745542d/micropython/mip/mip/init.py#L63
As a result, I had to change the way I reference my packages and package extension urls and deps in the package.json files. My network-utils 'package.json' has to have the following structure:
{
"urls": [
["network_utils/__init__.py", "https://gitlab.com/micropython-iot-projects/libraries/micropython-network-utils/-/raw/HEAD/network-utils/network_utils/__init__.py"]
],
"deps": [
["logging", "latest"],
["github:josverl/micropython-stubs/mip/typing.mpy", "main"],
["github:josverl/micropython-stubs/mip/typing_extensions.mpy", "main"]
],
"version": "0.0.1"
}
In order to install network-utils with mpremote, I would have to use the following command:
mpremote mip install https://gitlab.com/micropython-iot-projects/libraries/micropython-network-utils/-/raw/HEAD/network-utils/package.json
The command below will not work, resulting in a 403 error:
mpremote mip install gitlab:micropython-iot-projects/libraries/micropython-network-utils/network-utils/package.json
The network-utils-mqtt extension package, which requires network-utils, had to have its package.json written like so:
{
"urls": [
["network_utils/mqtt.py", "https://gitlab.com/micropython-iot-projects/libraries/micropython-network-utils/-/raw/HEAD/network-utils-mqtt/network_utils/mqtt.py"]
],
"deps": [
["https://gitlab.com/micropython-iot-projects/libraries/micropython-network-utils/-/raw/HEAD/network-utils/", "develop"]
],
"version": "0.0.1"
}
The URL for the deps, which is the network-utils package this one extends, had to be rewritten so that the package.json could be found correctly.
micropython/mip/mip/__init__.py: Implement install from gitlab.
Modify _rewrite_url() to allow mip install from gitlab: repository.
Signed-off-by: Olivier Lenoir olivier.len02@gmail.com
Both pull requests are link to the same implementation of mip install from GitLab.
Signed-off-by: Olivier Lenoir olivier.len02@gmail.com
https://github.com/micropython/micropython-lib/pull/816
Modify _rewrite_url() to allow mip install from gitlab: repository.
Signed-off-by: Olivier Lenoir olivier.len02@gmail.com
https://github.com/micropython/micropython/pull/13791
mpremote: Implement mip install from GitLab.
tools/mpremote/README.md: Add mip install gitlab:org/repo@branch.
Add example mpremote mip install gitlab:org/repo@branch.
tools/mpremote/mpremote/mip.py: Implement install from GitLab.
Modify _rewrite_url() to allow mip install from gitlab: repository.
mpremote/mpremote/main.py: Add gitlab:org/repo, gitlab:org/repo@branch.
Modify argparse_mip() for gitlab:org/repo, gitlab:org/repo@branch.
docs/reference/packages.rst: Mip install from GitLab.
Describe how to mip install from GitLab.
docs/reference/mpremote.rst: Install package from GitLab.
Install the package from the specified branch at org/repo on GitLab.
Signed-off-by: Olivier Lenoir olivier.len02@gmail.com
@jimmo I think this PR is right.
What's the next step, if any?
Thanks for the contribution! This looks good, and is now merged.
Rebased and merged in 57cbc3484060f646deb0f4f652abcca4732b3458