FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add basic web Python prompt · python-emscripten/python@5b2c7fc · GitHub

Repository navigation

Commit 5b2c7fc

Browse files
committed
Add basic web Python prompt
1 parent 1a7ce67 commit 5b2c7fc

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎2.7.10/webprompt.sh‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash -ex
2+
3+
# Simple Python prompt for the browser, for smoke testing
4+
5+
# Copyright (C) 2019 Sylvain Beucler
6+
7+
# Copying and distribution of this file, with or without modification,
8+
# are permitted in any medium without royalty provided the copyright
9+
# notice and this notice are preserved. This file is offered as-is,
10+
# without any warranty.
11+
12+
INSTALLDIR=${INSTALLDIR:-$(dirname $(readlink -f $0))/destdir}
13+
14+
mkdir -p t
15+
#cat <<'EOF' > t/main.c
16+
##include <Python.h>
17+
#int main(int argc, char**argv) { Py_InitializeEx(0); }
18+
#EOF
19+
echo 'int main(int argc, char**argv) { }' > t/main.c
20+
21+
# Alternatively: use Emscripten's old binary:
22+
# emscripten/tests/python/python.bc -s ERROR_ON_UNDEFINED_SYMBOLS=0
23+
24+
emcc -o t/webprompt.html \
25+
t/main.c -I$INSTALLDIR/include/python2.7 -L$INSTALLDIR/lib -lpython2.7 \
26+
-s WASM=0 \
27+
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
28+
-s USE_ZLIB=1 \
29+
-s TOTAL_MEMORY=256MB \
30+
--preload-file $INSTALLDIR/lib/python2.7@/lib/python2.7 \
31+
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_Py_Initialize', '_PyRun_SimpleString']" \
32+
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
33+
34+
# TODO: add a textarea in a custom shell.html, meanwhile use the JavaScript Console:
35+
# Module.cwrap('Py_Initialize', 'number', [])();
36+
# Module.cwrap('PyRun_SimpleString', 'number', ['string'])("import sys; print sys.builtin_module_names");
37+
# Module.ccall('PyRun_SimpleString', 'number', ['string'], ["print 'hello'"])

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL