Skip to content

Commit 92ee97d

Browse files
mattytrentinidpgeorge
authored andcommitted
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 micropython/micropython#19844 Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
1 parent 660ddd8 commit 92ee97d

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎micropython/mip/manifest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(version="0.5.0", description="On-device package installer for network-capable boards")
1+
metadata(version="0.5.1", description="On-device package installer for network-capable boards")
22

33
require("requests")
44

‎micropython/mip/mip/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def _install_json(package_json_url, index, target, version, mpy):
121121
if not _download_file(file_url, fs_target_path):
122122
print("File not found: {} {}".format(target_path, short_hash))
123123
return False
124-
base_url = package_json_url.rpartition("/")[0]
124+
# str.rpartition is not available on all builds.
125+
slash = package_json_url.rfind("/")
126+
base_url = package_json_url[:slash] if slash >= 0 else ""
125127
for target_path, url in package_json.get("urls", ()):
126128
fs_target_path = target + "/" + target_path
127129
is_full_url = any(url.startswith(p) for p in _ALLOWED_MIP_URL_PREFIXES)

0 commit comments

Comments
 (0)