8000 mpremote: Support relative URLs in mip package.json file. by glenn20 · Pull Request #12477 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

mpremote: Support relative URLs in mip package.json file. #12477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

glenn20
Copy link
Contributor
@glenn20 glenn20 commented Sep 19, 2023

Allow URLs in mip package.json files to be specified relative to the base URL of the package.json file.

This simplifies use of mip packages from forked or copied repos. When taken together with PR #12476, it also simplifies installing from repos cloned to the local filesystem. Is also useful during testing and development.

Example package.json (adapted from https://github.com/glenn20/micropython-esp32-ota/blob/main/mip/ota/package.json):

{
    "urls": [
        ["ota/rollback.py", "rollback.py"],
        ["ota/status.py", "status.py"],
        ["ota/update.py", "update.py"],
        ["ota/blockdev_writer.py", "blockdev_writer.py"]
    ],
    "deps": [
    ],
    "version": "0.2"
}

@github-actions
Copy link
github-actions bot commented Sep 19, 2023

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@codecov
Copy link
codecov bot commented Sep 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.53%. Comparing base (4364d94) to head (2992e34).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12477   +/-   ##
=======================================
  Coverage   98.53%   98.53%           
=======================================
  Files         169      169           
  Lines       21822    21822           
=======================================
  Hits        21502    21502           
  Misses        320      320           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dpgeorge dpgeorge added the tools Relates to tools/ directory in source, or other tooling label Sep 29, 2023
@mgsb
Copy link
Contributor
mgsb commented Oct 4, 2023

+1
DRY is good in this situation

@vshymanskyy
Copy link
Contributor
vshymanskyy commented Oct 14, 2024

I think I effectively implemented it in ViperIDE since day 0, and now found this PR while researching the project import feature: vshymanskyy/ViperIDE#42

@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch 2 times, most recently from eabff45 to b3cd762 Compare February 10, 2025 03:30
@glenn20
Copy link
Contributor Author
glenn20 commented Feb 10, 2025

Rebased, patched and squashed.

@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch 3 times, most recently from 7831b6f to 4542ab6 Compare February 15, 2025 12:09
@glenn20
Copy link
Contributor Author
glenn20 commented Feb 15, 2025

Rebased and squashed.

@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch from 4542ab6 to f31439d Compare February 15, 2025 12:30
Copy link
Member
@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really great improvement, makes it much easier to define a package.json that works locally and the same file works on a remote HTTP(S) server, among other things.

Two things that I think need doing:

  1. Update the docs at docs/reference/package.rst to mention this new feature.
  2. Update micropython-lib's mip package to support the same relative URLs, so that when mip is run locally on a board (with a network connection) it can work (or using micropython -m mip).

Would be good to include (1) in this PR.

(2) needs to be done in a separate PR to micropython-lib.

I'm happy to do either or both of those, or leave it to you @glenn20, just let me know.

@dpgeorge dpgeorge added this to the release-1.25.0 milestone Feb 17, 2025
@glenn20
Copy link
Contributor Author
glenn20 commented Feb 17, 2025
  1. Update the docs at docs/reference/package.rst to mention this new feature.

OK. I will add that this afternoon.

  1. Update micropython-lib's mip package to support the same relative URLs, so that when mip is run locally on a board (with a network connection) it can work (or using micropython -m mip).

Would be good to include (1) in this PR.

(2) needs to be done in a separate PR to micropython-lib.

I'm happy to do either or both of those, or leave it to you @glenn20, just let me know.

Re. 2, Im also happy to take a look this afternoon and post a second PR, but go ahead if you prefer to do it yourself ;).

I also have a small test script for this PR (and the local fs PR) that I'll update as a test in tools/mpremote/tests.

@dpgeorge
Copy link
Member

Im also happy to take a look this afternoon and post a second PR

Great, thanks, I'll leave it to you.

I also have a small test script for this PR (and the local fs PR) that I'll update as a test in tools/mpremote/tests.

Very good!

I can make a test package available at https://micropython.org/resources/... if needed.

glenn20 added a commit to glenn20/micropython that referenced this pull request Feb 17, 2025
Update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the package.json file (PR micropython#12477).

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch from c3bab1b to 90cf3a4 Compare February 17, 2025 23:33
glenn20 added a commit to glenn20/micropython-lib that referenced this pull request Feb 18, 2025
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in micropython/micropython#12477.
glenn20 added a commit to glenn20/micropython that referenced this pull request Feb 18, 2025
URLs in package.json may be specified relative to the base URL of
the package.json file.

Relative URLs wil work for package.json files installed from the web
as well as local file paths.

Update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the package.json file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the
  default in package.json.
@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch from f48655d to 4c8d89c Compare February 18, 2025 02:09
glenn20 added a commit to glenn20/micropython that referenced this pull request Feb 18, 2025
URLs in package.json may be specified relative to the base URL of
the package.json file.

Relative URLs wil work for package.json files installed from the web
as well as local file paths.

Update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the package.json file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the
  default in package.json.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch from 4c8d89c to 4bb9cda Compare February 18, 2025 02:13
@glenn20
Copy link
Contributor Author
glenn20 commented Feb 18, 2025

Squashed commits.

glenn20 added a commit to glenn20/micropython that referenced this pull request Feb 18, 2025
URLs in package.json may be specified relative to the base URL of
the package.json file.

Relative URLs wil work for package.json files installed from the web
as well as local file paths.

Docs: update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the package.json file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the
  default in package.json.

Add tools/mpremote/tests/test_mip_local_install.sh to test the
installation of a package from local files using relative URLs in the
package.json.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
@glenn20 glenn20 force-pushed the feature-mip-package-json-relative-url branch from 7cc10a8 to d70e4d7 Compare February 18, 2025 06:38
glenn20 added a commit to glenn20/micropython-lib that referenced this pull request Feb 18, 2025
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in micropython/micropython#12477.
glenn20 added a commit to glenn20/micropython-lib that referenced this pull request Feb 18, 2025
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in micropython/micropython#12477.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
glenn20 added a commit to glenn20/micropython-lib that referenced this pull request Feb 18, 2025
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in micropython/micropython#12477.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
glenn20 added a commit to glenn20/micropython-lib that referenced this pull request Feb 18, 2025
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in micropython/micropython#12477.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
@glenn20
Copy link
Contributor Author
glenn20 commented Feb 18, 2025
  1. Update micropython-lib's mip package to support the same relative URLs, so that when mip is run locally on a board (with a network connection) it can work (or using micropython -m mip).

(2) needs to be done in a separate PR to micropython-lib.

I have submitted micropython-lib:#975 to support relative URLs in the mip module.

(Builds are failing due to something deprecated in the github actions.)

Copy link
Member
@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test, and updating the docs. This looks really good now!

URLs in `package.json` may now be specified relative to the base URL of the
`package.json` file.

Relative URLs wil work for `package.json` files installed from the web as
well as local file paths.

Docs: update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the `package.json` file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the default
  in `package.json`.

Add `tools/mpremote/tests/test_mip_local_install.sh` to test the
installation of a package from local files using relative URLs in the
`package.json`.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
@dpgeorge dpgeorge force-pushed the feature-mip-package-json-relative-url branch from d70e4d7 to 2992e34 Compare February 24, 2025 02:31
@dpgeorge dpgeorge merged commit 2992e34 into micropython:master Feb 24, 2025
66 checks passed
@glenn20 glenn20 deleted the feature-mip-package-json-relative-url branch February 24, 2025 03:03
dpgeorge pushed a commit to glenn20/micropython-lib that referenced this pull request Feb 24, 2025
This allows to specify relative URLs in package.json, which are resolved
relative to the package.json URL. This mirrors the functionality added to
mpremote in micropython/micropython#12477.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
HighImp pushed a commit to HighImp/micropython that referenced this pull request Mar 16, 2025
URLs in `package.json` may now be specified relative to the base URL of the
`package.json` file.

Relative URLs wil work for `package.json` files installed from the web as
well as local file paths.

Docs: update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the `package.json` file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the default
  in `package.json`.

Add `tools/mpremote/tests/test_mip_local_install.sh` to test the
installation of a package from local files using relative URLs in the
`package.json`.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
mseminatore pushed a commit to mseminatore/micropython that referenced this pull request Mar 31, 2025
URLs in `package.json` may now be specified relative to the base URL of the
`package.json` file.

Relative URLs wil work for `package.json` files installed from the web as
well as local file paths.

Docs: update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the `package.json` file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the default
  in `package.json`.

Add `tools/mpremote/tests/test_mip_local_install.sh` to test the
installation of a package from local files using relative URLs in the
`package.json`.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
lawrencedudley pushed a commit to lawrencedudley/micropython-esp32-pcnt that referenced this pull request May 29, 2025
URLs in `package.json` may now be specified relative to the base URL of the
`package.json` file.

Relative URLs wil work for `package.json` files installed from the web as
well as local file paths.

Docs: update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the `package.json` file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the default
  in `package.json`.

Add `tools/mpremote/tests/test_mip_local_install.sh` to test the
installation of a package from local files using relative URLs in the
`package.json`.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
eliclement pushed a commit to eliclement/micropython that referenced this pull request Jun 2, 2025
URLs in `package.json` may now be specified relative to the base URL of the
`package.json` file.

Relative URLs wil work for `package.json` files installed from the web as
well as local file paths.

Docs: update `docs/reference/packages.rst` to add documentation for:

- Installing packages from local filesystems (PR micropython#12476); and
- Using relative URLs in the `package.json` file (PR micropython#12477);
- Update the packaging example to encourage relative URLs as the default
  in `package.json`.

Add `tools/mpremote/tests/test_mip_local_install.sh` to test the
installation of a package from local files using relative URLs in the
`package.json`.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relates to tools/ directory in source, or other tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0