Skip to content

Pyscript issue 2302 - Unable to resolve relative wheels #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/zip-CFEEYRfx.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/zip-CFEEYRfx.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions esm/interpreter/micropython.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fetch from '@webreflection/fetch';
import { createProgress, writeFile } from './_utils.js';
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
import { stdio, buffered } from './_io.js';
import { absoluteURL } from '../utils.js';
import { absoluteURL, fixedRelative } from '../utils.js';
import mip from '../python/mip.js';
import { zip } from '../3rd-party.js';

Expand Down Expand Up @@ -44,7 +44,7 @@ export default {
this.writeFile(interpreter, './mip.py', mip);
if (config.packages) {
progress('Loading packages');
await py_imports(config.packages);
await py_imports(config.packages.map(fixedRelative, baseURL));
progress('Loaded packages');
}
progress('Loaded MicroPython');
Expand Down
5 changes: 3 additions & 2 deletions esm/interpreter/pyodide.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { create } from 'gc-hook';
import { RUNNING_IN_WORKER, createProgress, writeFile } from './_utils.js';
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
import { stdio } from './_io.js';
import { IDBMapSync, isArray } from '../utils.js';
import { IDBMapSync, isArray, fixedRelative } from '../utils.js';

const type = 'pyodide';
const toJsOptions = { dict_converter: Object.fromEntries };
Expand Down Expand Up @@ -90,6 +90,7 @@ export default {
applyOverride();
progress('Loading Pyodide');
let { packages, index_urls } = config;
if (packages) packages = packages.map(fixedRelative, baseURL);
progress('Loading Storage');
const indexURL = url.slice(0, url.lastIndexOf('/'));
// each pyodide version shares its own cache
Expand All @@ -101,7 +102,7 @@ export default {
if (!save) storage.clear();
// otherwise check if cache is known
else if (packages) {
packages = packages.slice(0).sort();
packages = packages.sort();
// packages are uniquely stored as JSON key
const key = stringify(packages);
if (storage.has(key)) {
Expand Down
6 changes: 6 additions & 0 deletions esm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const { all, resolve } = new Proxy(Promise, {
const absoluteURL = (path, base = location.href) =>
new URL(path, base.replace(/^blob:/, '')).href;

function fixedRelative(path) {
'use strict';
return path.startsWith('.') ? absoluteURL(path, this) : path;
}

/* c8 ignore start */
let id = 0;
const nodeInfo = (node, type) => ({
Expand Down Expand Up @@ -144,5 +149,6 @@ export {
all,
resolve,
absoluteURL,
fixedRelative,
nodeInfo,
};
101 changes: 52 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polyscript",
"version": "0.16.15",
"version": "0.16.17",
"description": "PyScript single core to rule them all",
"main": "./esm/index.js",
"types": "./types/polyscript/esm/index.d.ts",
Expand Down Expand Up @@ -94,6 +94,6 @@
"to-json-callback": "^0.1.1"
},
"worker": {
"blob": "sha256-fH3KC/dEPpvYJaLteD5BhwHUo3eOXk+xcMrnO0EdlL0="
"blob": "sha256-odSpqB8aMfMygAA/w4HACJlJ6oY/otMHtCZmVUbUkIk="
}
}
Loading