Skip to content

Commit a115939

Browse files
Merge pull request #138 from pyscript/issue-137
Fix #137 - Allow the passthrough option for the cache
2 parents 0276e9a + 2ddc5da commit a115939

File tree

12 files changed

+265
-185
lines changed

12 files changed

+265
-185
lines changed

docs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/toml-BK2RWy-G.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/toml-BK2RWy-G.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/zip-BKVoQflw.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/zip-BKVoQflw.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/interpreter/pyodide.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,37 +71,45 @@ export default {
7171
type,
7272
module: (version = '0.27.7') =>
7373
`https://cdn.jsdelivr.net/pyodide/v${version}/full/pyodide.mjs`,
74-
async engine({ loadPyodide }, config, url, baseURL) {
74+
async engine({ loadPyodide, version }, config, url, baseURL) {
7575
progress('Loading Pyodide');
7676
let { packages, index_urls } = config;
7777
if (packages) packages = packages.map(fixedRelative, baseURL);
7878
progress('Loading Storage');
7979
const indexURL = url.slice(0, url.lastIndexOf('/'));
8080
// each pyodide version shares its own cache
81-
const storage = new IDBMapSync(indexURL);
81+
const storage = new IDBMapSync(`${indexURL}@${version}`);
8282
const options = { indexURL };
8383
const save = config.packages_cache !== 'never';
8484
await storage.sync();
8585
// packages_cache = 'never' means: erase the whole DB
8686
if (!save) storage.clear();
8787
// otherwise check if cache is known
8888
else if (packages) {
89-
packages = packages.sort();
90-
// packages are uniquely stored as JSON key
91-
const key = stringify(packages);
92-
if (storage.has(key)) {
93-
const blob = new Blob(
94-
[storage.get(key)],
95-
{ type: 'application/json' },
96-
);
97-
// this should be used to bootstrap loadPyodide
98-
options.lockFileURL = URL.createObjectURL(blob);
99-
// versions are not currently understood by pyodide when
100-
// a lockFileURL is used instead of micropip.install(packages)
101-
// https://github.com/pyodide/pyodide/issues/5135#issuecomment-2441038644
102-
// https://github.com/pyscript/pyscript/issues/2245
103-
options.packages = packages.map(name => name.split(/[>=<]=/)[0]);
89+
// packages_cache = 'passthrough' means: do not use micropip.install
90+
if (config.packages_cache === 'passthrough') {
91+
options.packages = packages;
10492
packages = null;
93+
storage.clear();
94+
}
95+
else {
96+
packages = packages.sort();
97+
// packages are uniquely stored as JSON key
98+
const key = stringify(packages);
99+
if (storage.has(key)) {
100+
const blob = new Blob(
101+
[storage.get(key)],
102+
{ type: 'application/json' },
103+
);
104+
// this should be used to bootstrap loadPyodide
105+
options.lockFileURL = URL.createObjectURL(blob);
106+
// versions are not currently understood by pyodide when
107+
// a lockFileURL is used instead of micropip.install(packages)
108+
// https://github.com/pyodide/pyodide/issues/5135#issuecomment-2441038644
109+
// https://github.com/pyscript/pyscript/issues/2245
110+
options.packages = packages.map(name => name.split(/[>=<]=/)[0]);
111+
packages = null;
112+
}
105113
}
106114
}
107115
progress('Loaded Storage');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy