* inspect: Implement iscoroutinefunction and iscoroutine. * inspect: Add basic unit tests. * inspect: Fix isgenerator logic. * usb-device-cdc: Optimise writing small data so it doesn't require alloc. * aiohttp: Allow headers to be passed to a WebSocketClient. * aiohttp: Fix header case sensitivity. * requests: Use the host in the redirect url, not the one in headers. * unix-ffi/machine: Use libc if librt is not present. * unix-ffi/json: Accept both str and bytes as arg for json.loads(). * lora-sx126x: Fix invert_iq_rx / invert_iq_tx behaviour. * nrf24l10: Bump minor version. * nrf24l01: Optimize status reading. * nrf24l01: Properly handle timeout. * nrf24l01: Increase startup delay. * umqtt.simple: Restore legacy ssl/ssl_params arguments. * mip: Make mip.install() skip /rom*/lib directories. * github/workflows: Update actions/upload-artifact to v4. * mip: Allow relative URLs in package.json. * requests: Bump version to 0.10.1. * requests: Do not leak header modifications when calling request. * unittest: Always use "raise" with an argument. * unittest: Allow SkipTest to work within a subTest. * tools/ci.sh: Enable unittest tests. * aioespnow,webrepl: Use recommended network.WLAN.IF_[AP|STA] constants. * umqtt.simple: Add optional socket timeout to connect method. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/micropython-lib?expand=0&rev=7
61 lines
2.1 KiB
Diff
61 lines
2.1 KiB
Diff
From 65adc276a3e76e51b8c9c6770a2611679e607f3f Mon Sep 17 00:00:00 2001
|
|
From: Dominik Heidler <dheidler@suse.de>
|
|
Date: Fri, 14 Mar 2025 14:01:39 +0100
|
|
Subject: [PATCH] micropython/mip: Allow accessing index from local filesystem.
|
|
|
|
Just set the index to `file://relative/path` or `file:///absolute/path`.
|
|
|
|
Signed-off-by: Dominik Heidler <dheidler@suse.de>
|
|
---
|
|
micropython/mip/mip/__init__.py | 29 +++++++++++++++++++++--------
|
|
1 file changed, 21 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/micropython/mip/mip/__init__.py b/micropython/mip/mip/__init__.py
|
|
index 8920ad8f4..4b4a8c79f 100644
|
|
--- a/micropython/mip/mip/__init__.py
|
|
+++ b/micropython/mip/mip/__init__.py
|
|
@@ -91,6 +91,14 @@ def _rewrite_url(url, branch=None):
|
|
|
|
|
|
def _download_file(url, dest):
|
|
+ if url.startswith("file://"):
|
|
+ print("Copying:", dest)
|
|
+ src = url[7:]
|
|
+ _ensure_path_exists(dest)
|
|
+ with open(src, "b") as sf:
|
|
+ with open(dest, "wb") as f:
|
|
+ _chunk(sf, f.write)
|
|
+ return True
|
|
response = requests.get(url)
|
|
try:
|
|
if response.status_code != 200:
|
|
@@ -108,15 +116,20 @@ def _download_file(url, dest):
|
|
|
|
|
|
def _install_json(package_json_url, index, target, version, mpy):
|
|
- response = requests.get(_rewrite_url(package_json_url, version))
|
|
- try:
|
|
- if response.status_code != 200:
|
|
- print("Package not found:", package_json_url)
|
|
- return False
|
|
+ if package_json_url.startswith("file://"):
|
|
+ import json
|
|
|
|
- package_json = response.json()
|
|
- finally:
|
|
- response.close()
|
|
+ package_json = json.load(open(package_json_url[7:]))
|
|
+ else:
|
|
+ response = requests.get(_rewrite_url(package_json_url, version))
|
|
+ try:
|
|
+ if response.status_code != 200:
|
|
+ print("Package not found:", package_json_url)
|
|
+ return False
|
|
+
|
|
+ package_json = response.json()
|
|
+ finally:
|
|
+ response.close()
|
|
for target_path, short_hash in package_json.get("hashes", ()):
|
|
fs_target_path = target + "/" + target_path
|
|
if _check_exists(fs_target_path, short_hash):
|