Skip to content

Commit 8466e3c

Browse files
Merge pull request #130 from pyscript/pyscript-issue-2302
Pyscript issue 2302 - Unable to resolve relative wheels
2 parents 4db4ec0 + 5589ad3 commit 8466e3c

9 files changed

+67
-60
lines changed

Diff for: docs/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/zip-CFEEYRfx.js

-2
This file was deleted.

Diff for: docs/zip-CFEEYRfx.js.map

-1
This file was deleted.

Diff for: esm/interpreter/micropython.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fetch from '@webreflection/fetch';
33
import { createProgress, writeFile } from './_utils.js';
44
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
55
import { stdio, buffered } from './_io.js';
6-
import { absoluteURL } from '../utils.js';
6+
import { absoluteURL, fixedRelative } from '../utils.js';
77
import mip from '../python/mip.js';
88
import { zip } from '../3rd-party.js';
99

@@ -44,7 +44,7 @@ export default {
4444
this.writeFile(interpreter, './mip.py', mip);
4545
if (config.packages) {
4646
progress('Loading packages');
47-
await py_imports(config.packages);
47+
await py_imports(config.packages.map(fixedRelative, baseURL));
4848
progress('Loaded packages');
4949
}
5050
progress('Loaded MicroPython');

Diff for: esm/interpreter/pyodide.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { create } from 'gc-hook';
33
import { RUNNING_IN_WORKER, createProgress, writeFile } from './_utils.js';
44
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
55
import { stdio } from './_io.js';
6-
import { IDBMapSync, isArray } from '../utils.js';
6+
import { IDBMapSync, isArray, fixedRelative } from '../utils.js';
77

88
const type = 'pyodide';
99
const toJsOptions = { dict_converter: Object.fromEntries };
@@ -90,6 +90,7 @@ export default {
9090
applyOverride();
9191
progress('Loading Pyodide');
9292
let { packages, index_urls } = config;
93+
if (packages) packages = packages.map(fixedRelative, baseURL);
9394
progress('Loading Storage');
9495
const indexURL = url.slice(0, url.lastIndexOf('/'));
9596
// each pyodide version shares its own cache
@@ -101,7 +102,7 @@ export default {
101102
if (!save) storage.clear();
102103
// otherwise check if cache is known
103104
else if (packages) {
104-
packages = packages.slice(0).sort();
105+
packages = packages.sort();
105106
// packages are uniquely stored as JSON key
106107
const key = stringify(packages);
107108
if (storage.has(key)) {

Diff for: esm/utils.js

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const { all, resolve } = new Proxy(Promise, {
2020
const absoluteURL = (path, base = location.href) =>
2121
new URL(path, base.replace(/^blob:/, '')).href;
2222

23+
function fixedRelative(path) {
24+
'use strict';
25+
return path.startsWith('.') ? absoluteURL(path, this) : path;
26+
}
27+
2328
/* c8 ignore start */
2429
let id = 0;
2530
const nodeInfo = (node, type) => ({
@@ -144,5 +149,6 @@ export {
144149
all,
145150
resolve,
146151
absoluteURL,
152+
fixedRelative,
147153
nodeInfo,
148154
};

Diff for: package-lock.json

+52-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyscript",
3-
"version": "0.16.15",
3+
"version": "0.16.17",
44
"description": "PyScript single core to rule them all",
55
"main": "./esm/index.js",
66
"types": "./types/polyscript/esm/index.d.ts",
@@ -94,6 +94,6 @@
9494
"to-json-callback": "^0.1.1"
9595
},
9696
"worker": {
97-
"blob": "sha256-fH3KC/dEPpvYJaLteD5BhwHUo3eOXk+xcMrnO0EdlL0="
97+
"blob": "sha256-odSpqB8aMfMygAA/w4HACJlJ6oY/otMHtCZmVUbUkIk="
9898
}
9999
}

0 commit comments

Comments
 (0)