Commit 8875c17b authored by Michael Droettboom's avatar Michael Droettboom

Fix URLs so remote loading works

parent 093a0225
......@@ -32,7 +32,7 @@ NUMPY_LIBS=\
SITEPACKAGES=root/lib/python$(PYMINOR)/site-packages
all: build/pyodide.asm.html build/pyodide.js
all: build/pyodide.asm.html build/pyodide.js build/pyodide_dev.js
build/pyodide.asm.html: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python.bc \
......@@ -41,10 +41,17 @@ build/pyodide.asm.html: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python
[ -d build ] || mkdir build
$(CC) -s EXPORT_NAME="'pyodide'" --bind -o $@ $(filter %.bc,$^) $(LDFLAGS) \
$(foreach d,$(wildcard root/*),--preload-file $d@/$(notdir $d))
sed -i -e "s#REMOTE_PACKAGE_BASE = 'pyodide.asm.data'#REMOTE_PACKAGE_BASE = pyodide.baseURL + 'pyodide.asm.data'#g" build/pyodide.asm.js
build/pyodide_dev.js: src/pyodide.js
cp $< $@
sed -i -e "s#{{DEPLOY}}##g" $@
build/pyodide.js: src/pyodide.js
cp $< $@
sed -i -e 's#{{DEPLOY}}#https://iodide-project.github.io/pyodide-demo/#g' $@
build/test.html: src/test.html
......
var pyodide = {}
{
let wasmURL = 'pyodide.asm.wasm';
let baseURL = "{{DEPLOY}}";
let wasmURL = baseURL + 'pyodide.asm.wasm';
let wasmXHR = new XMLHttpRequest();
wasmXHR.open('GET', wasmURL, true);
wasmXHR.responseType = 'arraybuffer';
......@@ -9,16 +10,13 @@ var pyodide = {}
if (wasmXHR.status === 200 || wasmXHR.status === 0) {
pyodide.wasmBinary = wasmXHR.response;
} else {
var wasmURLBytes = tryParseAsDataURI(wasmURL);
if (wasmURLBytes) {
pyodide.wasmBinary = wasmURLBytes.buffer;
}
alert("Couldn't download the pyodide.asm.wasm binary. Response was " + wasmXHR.status);
}
pyodide.baseURL = baseURL;
var script = document.createElement('script');
script.src = "pyodide.asm.js";
script.src = baseURL + "pyodide.asm.js";
document.body.appendChild(script);
};
wasmXHR.send(null);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment