fix: pass wheel filename through extraction chain to fix micropip install

micropip requires the full PEP 427 wheel filename (name-version-py-abi-plat.whl)
— writing the file as bincio.whl caused InvalidWheelFilename. The wheel URL from
/api/wheel/version now provides the basename; it flows through fetchWheelBase64 →
extractFile → WebView where the file is written with the correct name and
_wheel_path is set as a Pyodide global before PY_INSTALL_WHEEL runs.
This commit is contained in:
Davide Scaini
2026-04-25 09:29:33 +02:00
parent ef45d4f4bb
commit 69571c1306
3 changed files with 23 additions and 13 deletions
+10 -6
View File
@@ -13,9 +13,10 @@ const PY_INSTALL_PACKAGES = [
// emfs:// is Pyodide's Emscripten-FS URL scheme — the only reliable way to
// install a wheel from bytes without an http/https URL (blob: URLs are not
// recognised by micropip and cause an InvalidRequirement parse error).
// _wheel_path is set as a Pyodide global before this runs.
const PY_INSTALL_WHEEL = [
'import micropip',
'await micropip.install("emfs:///tmp/bincio.whl", deps=False)',
'await micropip.install("emfs://" + _wheel_path, deps=False)',
].join('\n');
const PY_EXTRACT = [
@@ -90,10 +91,11 @@ var initError = null;
})();
window._bincioExtract = async function(params) {
var reqId = params.reqId;
var filename = params.filename;
var base64 = params.base64;
var wheelBase64 = params.wheelBase64; // pre-fetched by React Native (avoids ATS/HTTP issues)
var reqId = params.reqId;
var filename = params.filename;
var base64 = params.base64;
var wheelBase64 = params.wheelBase64; // pre-fetched by React Native (avoids ATS/HTTP issues)
var wheelFilename = params.wheelFilename; // e.g. "bincio-0.1.0-py3-none-any.whl"
function post(m) { _post(Object.assign({}, m, { reqId: reqId })); }
@@ -118,7 +120,9 @@ window._bincioExtract = async function(params) {
if (!wheelReady) {
post({ type: 'progress', msg: 'Loading Bincio…' });
var wheelBytes = Uint8Array.from(atob(wheelBase64), function(c) { return c.charCodeAt(0); });
pyodide.FS.writeFile('/tmp/bincio.whl', wheelBytes);
var wheelPath = '/tmp/' + wheelFilename;
pyodide.FS.writeFile(wheelPath, wheelBytes);
pyodide.globals.set('_wheel_path', wheelPath);
await pyodide.runPythonAsync(_PY_INSTALL_WHEEL);
wheelReady = true;
}