From ec45240485c434f819b613233b0edf7b6057226d Mon Sep 17 00:00:00 2001 From: Matt Trentini Date: Wed, 4 Nov 2026 01:12:06 +1100 Subject: [PATCH] mip: Avoid str.rpartition for limited builds. ESP8266 disables str.partition and str.rpartition to save flash, so installing a package manifest currently fails when deriving its base URL. Use rfind and slicing instead, preserving the empty prefix when no slash is present. This avoids requiring partition support on limited builds without removing the on-device package installer. Bump mip to version 0.5.1. See https://github.com/micropython/micropython/pull/19844 Signed-off-by: Matt Trentini --- micropython/mip/manifest.py | 2 +- micropython/mip/mip/__init__.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/micropython/mip/manifest.py b/micropython/mip/manifest.py index f577ea601..96c8df630 100644 --- a/micropython/mip/manifest.py +++ b/micropython/mip/manifest.py @@ -1,4 +1,4 @@ -metadata(version="0.5.0", description="On-device package installer for network-capable boards") +metadata(version="0.5.1", description="On-device package installer for network-capable boards") require("requests") diff --git a/micropython/mip/mip/__init__.py b/micropython/mip/mip/__init__.py index 22982fe9a..dfe722288 100644 --- a/micropython/mip/mip/__init__.py +++ b/micropython/mip/mip/__init__.py @@ -121,7 +121,9 @@ def _install_json(package_json_url, index, target, version, mpy): if not _download_file(file_url, fs_target_path): print("File not found: {} {}".format(target_path, short_hash)) return False - base_url = package_json_url.rpartition("/")[0] + # str.rpartition is not available on all builds. + slash = package_json_url.rfind("/") + base_url = package_json_url[:slash] if slash >= 0 else "" for target_path, url in package_json.get("urls", ()): fs_target_path = target + "/" + target_path is_full_url = any(url.startswith(p) for p in _ALLOWED_MIP_URL_PREFIXES)