├── support
├── cross
│ ├── __WASM__.py
│ ├── aio
│ │ ├── atexit.py
│ │ ├── recycle.py
│ │ ├── prepro.py
│ │ ├── clock.py
│ │ ├── toplevel.py
│ │ ├── trace.py
│ │ ├── filelike.py
│ │ ├── cross.py
│ │ ├── gthread.py
│ │ └── simulator.py
│ └── __EMSCRIPTEN__.py
├── sim.links
│ └── put_modules_simlinks_here
├── __EMSCRIPTEN__.overlay
│ ├── pymunk.py
│ └── pygame
│ │ ├── freesansbold.ttf
│ │ ├── _sdl2
│ │ └── __init__.py
│ │ └── wasm_patches.py
├── __EMSCRIPTEN__.tests
│ ├── xxlimited.cpython-311-wasm32-emscripten.so
│ ├── _ctypes_test.cpython-311-wasm32-emscripten.so
│ ├── xxlimited_35.cpython-311-wasm32-emscripten.so
│ ├── _testmultiphase.cpython-311-wasm32-emscripten.so
│ └── _testimportmultiple.cpython-311-wasm32-emscripten.so
├── __EMSCRIPTEN__.py
├── xterm
├── __EMSCRIPTEN__.deps
│ ├── ncurses-6.1_emscripten.patch
│ ├── ncurses-6.1_emscripten_make.patch
│ └── ncurses-6.1_emscripten_makew.patch
├── server.py
├── __EMSCRIPTEN__.patches
│ ├── 3.10-host.diff
│ ├── 3.11
│ │ ├── asyncio
│ │ │ └── __init__.py
│ │ └── hashlib.py
│ └── 3.10
│ │ └── asyncio
│ │ └── __init__.py
├── __EMSCRIPTEN__.yml
├── __EMSCRIPTEN__.embed
│ ├── cpython.diff
│ └── sysmodule.c
├── __EMSCRIPTEN__-pymain.c
└── __EMSCRIPTEN__.sh
├── .github
├── FUNDING.yml
└── workflows
│ └── ci.yml
├── demos
├── 0-pong
│ ├── font.ttf
│ ├── favicon.ico
│ ├── README.md
│ ├── package.toml
│ └── 1001fonts-morris-roman-eula.txt
├── org.python3.11.0
│ ├── static
│ │ ├── org.python3.11.0.html
│ │ └── index.html
│ └── cpython.six
└── 1-touchpong
│ └── package.toml
├── templates
├── no-worker
│ ├── main
│ ├── org.python.html
│ ├── favicon.ico
│ ├── pythons.html
│ ├── pygame.html
│ └── python311.html
└── libs
│ └── xterm
│ ├── styles.css
│ ├── xtermjsixel
│ ├── style.css
│ └── xterm.css
│ └── vtx.js
├── scripts
├── cpython-build-host-deps.sh
├── cpython-build-emsdk-prebuilt.sh
├── re-pack-apk.sh
├── pygame-all.sh
├── cpython-fetch.sh
├── make_coldstartfs.sh
├── cpython-build-host.sh
├── cpython-build-host-prebuilt.sh
├── emsdk-fetch.sh
├── cpython-build-emsdk-deps.sh
└── cpython-build-emsdk.sh
├── .gitignore
├── LICENSE
├── python-wasm-plus.sh
├── python-wasm-sim.sh
├── config
├── README.md
└── tests
├── assets
└── cpython.six
└── code
├── testjoy.py
└── touchpong.py
/support/cross/__WASM__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/support/sim.links/put_modules_simlinks_here:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | open_collective: pythonseverywhere
2 |
3 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.overlay/pymunk.py:
--------------------------------------------------------------------------------
1 | from pymunk4 import *
2 |
--------------------------------------------------------------------------------
/demos/0-pong/font.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/demos/0-pong/font.ttf
--------------------------------------------------------------------------------
/templates/no-worker/main:
--------------------------------------------------------------------------------
1 | templates/libs/emsdk
2 | templates/libs/xterm
3 | templates/libs/browserfs
4 |
--------------------------------------------------------------------------------
/demos/0-pong/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/demos/0-pong/favicon.ico
--------------------------------------------------------------------------------
/templates/no-worker/org.python.html:
--------------------------------------------------------------------------------
1 |
2 | TODO: History of CPython on asm.js/wasm
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/templates/no-worker/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/templates/no-worker/favicon.ico
--------------------------------------------------------------------------------
/demos/0-pong/README.md:
--------------------------------------------------------------------------------
1 | # Pong
2 | A pong game made with pygame.
3 |
4 | ## Todo
5 | * Add multiplayer
6 | * Add highscore using mysql
7 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.overlay/pygame/freesansbold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/support/__EMSCRIPTEN__.overlay/pygame/freesansbold.ttf
--------------------------------------------------------------------------------
/demos/org.python3.11.0/static/org.python3.11.0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Github: Not a git repo
4 |
5 |
6 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.tests/xxlimited.cpython-311-wasm32-emscripten.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/support/__EMSCRIPTEN__.tests/xxlimited.cpython-311-wasm32-emscripten.so
--------------------------------------------------------------------------------
/scripts/cpython-build-host-deps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ${CONFIG:-config}
4 |
5 | echo "
6 | * cpython-build-host-prebuilt pip==$PIP *
7 | " 1>&2
8 |
9 |
10 | # use system packages.
11 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.tests/_ctypes_test.cpython-311-wasm32-emscripten.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/support/__EMSCRIPTEN__.tests/_ctypes_test.cpython-311-wasm32-emscripten.so
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.tests/xxlimited_35.cpython-311-wasm32-emscripten.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/support/__EMSCRIPTEN__.tests/xxlimited_35.cpython-311-wasm32-emscripten.so
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.tests/_testmultiphase.cpython-311-wasm32-emscripten.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/support/__EMSCRIPTEN__.tests/_testmultiphase.cpython-311-wasm32-emscripten.so
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.tests/_testimportmultiple.cpython-311-wasm32-emscripten.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pmp-p/python-wasm-plus/HEAD/support/__EMSCRIPTEN__.tests/_testimportmultiple.cpython-311-wasm32-emscripten.so
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /keystore
2 | /devices
3 | /src
4 | /build
5 | /emsdk/
6 | /wasm32-tot-emscripten-shell.sh
7 | /python-wasm-plus.epj
8 | /.eric6project
9 | /demos
10 | /tests/code
11 | /support/sim.links
12 | /scratchbook/
13 | ATTIC
14 |
--------------------------------------------------------------------------------
/demos/0-pong/package.toml:
--------------------------------------------------------------------------------
1 | # https://toml.io/en/
2 |
3 |
4 | # a section for Mys
5 | [package]
6 | name = "Pong"
7 | version = "0.1"
8 | authors = ["CAPTAIN"]
9 | description = "a Pong game"
10 |
11 |
12 | # packing instruction for vfs
13 | [fs]
14 | memfs = [ "main.py", "font.ttf", ]
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/demos/1-touchpong/package.toml:
--------------------------------------------------------------------------------
1 | # https://toml.io/en/
2 |
3 |
4 | # a section for Mys
5 | [package]
6 | name = "touchpong"
7 | version = "0.1"
8 | authors = ["blubberquark"]
9 | description = "Pong game with Multitouch"
10 |
11 |
12 | # packing instruction for vfs
13 | [fs]
14 | memfs = [ "main.py", ]
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.overlay/pygame/_sdl2/__init__.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | if not sys.platform in ("wasi", "emscripten"):
4 | from .sdl2 import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
5 | from .audio import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
6 | from .video import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
7 |
--------------------------------------------------------------------------------
/templates/libs/xterm/styles.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | max-width: 800px;
4 | margin: 0 auto
5 | }
6 |
7 | #code {
8 | width: 100%;
9 | height: 180px;
10 | }
11 |
12 | .button-container {
13 | display: flex;
14 | justify-content: end;
15 | height: 50px;
16 | align-items: center;
17 | gap: 10px;
18 | }
19 |
20 | button {
21 | padding: 6px 18px;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/support/cross/aio/atexit.py:
--------------------------------------------------------------------------------
1 | plan = []
2 |
3 | def register(func, *args, **kwargs):
4 | global plan
5 | plan.append( (func,arg,kwargs,) )
6 |
7 | def unregister(func):
8 | global plan
9 | todel = []
10 | for i,elem in enumerate(plan)
11 | if elem[0] is func:
12 | todel.append(i)
13 |
14 | while len(todel):
15 | plan.pop( todel.pop() )
16 |
17 |
18 | def exiting():
19 | while len(plan):
20 |
21 |
22 | # replace stock one
23 | import sys
24 | sys.modules['atexit'] = sys.modules['aio.atexit']
25 |
--------------------------------------------------------------------------------
/demos/org.python3.11.0/static/index.html:
--------------------------------------------------------------------------------
1 |
2 | Run CPython 3.11 test suite on browser (runtime at least 20 Minutes)
3 |
4 | do not switch tab for testsuite, keep it in a exposed window or it will pause
5 |
6 | Meanwhile enjoy casual gaming in another window with :
7 |
8 |
9 | Pygame demos
10 |
11 | Please report issues here:
12 | https://github.com/pmp-p/python-wasm-plus/issues
13 |
14 |
--------------------------------------------------------------------------------
/scripts/cpython-build-emsdk-prebuilt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ${CONFIG:-config}
4 |
5 | PIP="$(realpath python3-wasm) -m pip"
6 |
7 | echo "
8 | * cpython-build-emsdk-prebuilt pip==$PIP *
9 | " 1>&2
10 |
11 |
12 | for pkg in installer
13 | do
14 | if [ -d prebuilt/emsdk/${PYBUILD}/site-packages/$pkg ]
15 | then
16 | echo "
17 | $pkg already set to prebuilt
18 | "
19 | else
20 | $PIP install $pkg
21 | mv $PREFIX/lib/python${PYBUILD}/site-packages/${pkg} prebuilt/emsdk/${PYBUILD}/site-packages/
22 | mv $PREFIX/lib/python${PYBUILD}/site-packages/${pkg}-* prebuilt/emsdk/${PYBUILD}/site-packages/
23 | fi
24 | done
25 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.py:
--------------------------------------------------------------------------------
1 | # python startup for python3-wasm
2 | import sys,os
3 |
4 | # for emcc to build wasm shared lib
5 | os.environ['EMCC_CFLAGS']='-s SIDE_MODULE=1'
6 |
7 | ARCH=os.popen('arch').read().strip()
8 |
9 | # the egg system may pollute the sys.path with non compatible .so
10 | # clean it up
11 | for i,path in enumerate(sys.path):
12 | if path.find('/emsdk/')>0:
13 | sys.path[i] = sys.path[i].replace('/emsdk/',f'/{ARCH}/')
14 | sys.path[i] = sys.path[i].replace('py3.11-wasm32-tot-emscripten',f'py3.11-linux-{ARCH}')
15 | sys.path[i] = sys.path[i].replace('py3.10-wasm32-tot-emscripten',f'py3.10-linux-{ARCH}')
16 |
17 | import _cffi_backend
18 | import cffi
19 | from cffi import FFI
20 |
--------------------------------------------------------------------------------
/support/xterm:
--------------------------------------------------------------------------------
1 | xterm|xterm-new|xterm terminal emulator (XFree86):\
2 | :am:km:mi:ms:xn:\
3 | :co#80:it#8:li#24:colors#256:\
4 | :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\
5 | :LE=\E[%dD:\
6 | :RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:bt=\E[Z:\
7 | :cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\
8 | :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:\
9 | :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\
10 | :kD=\177:\
11 | :kb=^H:ke=\E[?1l\E>:\
12 | :ks=\E[?1h\E=:le=^H:mb=\E[5m:md=\E[1m:\
13 | :me=\E[m\017:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[27m:\
14 | :sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[?1047l\E[?1048l:\
15 | :ti=\E[?1048h\E[?1047h:ue=\E[24m:up=\E[A:us=\E[4m:\
16 | :vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h:
17 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.deps/ncurses-6.1_emscripten.patch:
--------------------------------------------------------------------------------
1 | diff -Naur ncurses-6.1/ncurses/curses.priv.h ncurses-6.1_emscripten/ncurses/curses.priv.h
2 | --- ncurses-6.1/ncurses/curses.priv.h 2018-01-20 23:13:41.000000000 -0300
3 | +++ ncurses-6.1_emscripten/ncurses/curses.priv.h 2019-08-08 21:50:05.174897464 -0300
4 | @@ -64,6 +64,23 @@
5 | #include /* for offsetof */
6 | #include
7 | #include
8 | +
9 | +#ifdef __EMSCRIPTEN__
10 | +#ifdef getenv
11 | +#undef getenv
12 | +#endif
13 | +
14 | +#define getenv(name)(char*)\
15 | +({\
16 | + char* data = getenv(name);\
17 | + int length = strlen(data);\
18 | + char* dest = (char*)malloc(length+1);\
19 | + strncpy(dest, data, length);\
20 | + dest[length+1] = '\0';\
21 | + dest;\
22 | +})
23 | +#endif
24 | +
25 | #include
26 | #include
27 |
28 |
--------------------------------------------------------------------------------
/support/cross/aio/recycle.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import aio
3 | import platform
4 |
5 | MODULES = list(sys.modules.keys())
6 | MAIN = list(vars(__import__("__main__")).keys())
7 | BUILTINS = list(vars(__import__("builtins")).keys())
8 |
9 |
10 | def cleanup():
11 | import sys, random
12 |
13 | for mod in list(sys.modules.keys()):
14 | if not mod in MODULES:
15 | sys.modules.pop(mod, None)
16 |
17 | md = vars(__import__("__main__"))
18 | for name in list(md.keys()):
19 | if not name in MAIN:
20 | md.pop(name, None)
21 |
22 | md = vars(__import__("builtins"))
23 | for var in list(md.keys()):
24 | if not name in BUILTINS:
25 | md.pop(name, None)
26 |
27 | del mod, name, md
28 | __import__("importlib").invalidate_caches()
29 | __import__("gc").collect()
30 |
31 | random.seed(1)
32 |
33 | aio.exit = False
34 | aio.paused = False
35 | print(" - cycling done -")
36 | try:
37 | platform.set_window_title('idle')
38 | platform.prompt()
39 | except:
40 | pass
41 |
--------------------------------------------------------------------------------
/support/cross/aio/prepro.py:
--------------------------------------------------------------------------------
1 | import builtins
2 |
3 | DEBUG = False
4 |
5 | defines = {}
6 |
7 |
8 | def defined(plat):
9 | try:
10 | return eval(plat) or True
11 | except:
12 | return False
13 |
14 |
15 | def define(tag, value):
16 | global defines, DEBUG
17 | if DEBUG:
18 | import inspect
19 |
20 | lf = inspect.currentframe().f_back
21 | fn = inspect.getframeinfo(lf).filename.rsplit("/assets/", 1)[-1]
22 | ln = lf.f_lineno
23 | info = f"{fn}:{ln}"
24 | defines.setdefault(tag, info)
25 | else:
26 | info = "?:?"
27 |
28 | redef = defined(tag)
29 | if redef:
30 | if redef is value:
31 | pdb(f"INFO: {tag} redefined from {defines.get(tag)} at {info}")
32 | else:
33 | pdb(
34 | f"""\
35 | WARNING: {tag} was already defined
36 | previous {defines.get(tag)} value {redef}
37 | new {info} value {value}
38 |
39 | """
40 | )
41 |
42 | setattr(builtins, tag, value)
43 |
44 |
45 | builtins.define = define
46 | builtins.defined = defined
47 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Paul m. p. P.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/support/server.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import sys
3 |
4 | import mimetypes
5 |
6 | mimetypes.init()
7 | if ".wasm" not in mimetypes.types_map:
8 | print(
9 | "WARNING: wasm mimetype unsupported on that system, trying to correct",
10 | file=sys.stderr,
11 | )
12 | mimetypes.types_map[".wasm"] = "application/wasm"
13 |
14 | import argparse
15 | from http import server
16 |
17 |
18 | parser = argparse.ArgumentParser(
19 | description="Start a local webserver with a Python terminal."
20 | )
21 | parser.add_argument(
22 | "--port", type=int, default=8000, help="port for the http server to listen on"
23 | )
24 | args = parser.parse_args()
25 |
26 |
27 | class MyHTTPRequestHandler(server.SimpleHTTPRequestHandler):
28 | def end_headers(self):
29 | self.send_my_headers()
30 |
31 | super().end_headers()
32 |
33 | def send_my_headers(self):
34 | self.send_header("Cross-Origin-Opener-Policy", "same-origin")
35 | self.send_header("Cross-Origin-Embedder-Policy", "require-corp")
36 |
37 |
38 | server.test(HandlerClass=MyHTTPRequestHandler, protocol="HTTP/1.1", port=args.port)
39 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push, workflow_dispatch]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-22.04
8 | steps:
9 | - uses: actions/checkout@v1
10 | - name: pygame-wasm-builder prepare
11 | run: |
12 | WD=$(pwd)
13 | python3 -V
14 | echo $WD
15 | clang --version | head -n 1
16 | echo
17 | gcc --version | head -n 1
18 | echo
19 | env|grep GITHUB
20 | echo
21 | env|grep ANDROID
22 | sudo apt-get update
23 | sudo apt-get install -y bash wget
24 |
25 | - name: build
26 | run: |
27 | echo " === Building ===="
28 | cd $GITHUB_WORKSPACE
29 | time bash ./python-wasm-plus.sh
30 | du -hs $(find prebuild/emsdk/)
31 |
32 |
33 | - name: pack
34 | run: |
35 | echo " === Packaging ==="
36 | time bash ./buildapp.sh
37 | cd $GITHUB_WORKSPACE
38 | mv build/demo $GITHUB_WORKSPACE/
39 | du -hs demo/*
40 |
41 | - name : "Upload to GitHub pages"
42 | uses: JamesIves/github-pages-deploy-action@4.1.7
43 | with:
44 | branch: gh-pages
45 | folder: demo
46 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.patches/3.10-host.diff:
--------------------------------------------------------------------------------
1 | --- Python-3.10.5/Modules/readline.c 2022-06-06 13:53:30.000000000 +0200
2 | +++ Python-3.10.5-pydk/Modules/readline.c 2022-06-13 04:07:55.357320826 +0200
3 | @@ -1324,7 +1324,9 @@
4 | int has_input = 0, err = 0;
5 |
6 | while (!has_input)
7 | - { struct timeval timeout = {0, 100000}; /* 0.1 seconds */
8 | + {
9 | +
10 | + struct timeval timeout = {0, 10000}; /* 0.01 seconds */
11 |
12 | /* [Bug #1552726] Only limit the pause if an input hook has been
13 | defined. */
14 | --- Python-3.10.5/Parser/pegen.c 2022-06-06 13:53:30.000000000 +0200
15 | +++ Python-3.10.5-pydk/Parser/pegen.c 2022-06-13 04:10:09.549166880 +0200
16 | @@ -432,7 +432,7 @@
17 | * (multi-line) statement are stored in p->tok->interactive_src_start.
18 | * If not, we're parsing from a string, which means that the whole source
19 | * is stored in p->tok->str. */
20 | - assert((p->tok->fp == NULL && p->tok->str != NULL) || p->tok->fp == stdin);
21 | + assert((p->tok->fp == NULL && p->tok->str != NULL) || p->tok->fp != NULL);
22 |
23 | char *cur_line = p->tok->fp_interactive ? p->tok->interactive_src_start : p->tok->str;
24 | if (cur_line == NULL) {
25 |
--------------------------------------------------------------------------------
/support/cross/aio/clock.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import time
3 | import asyncio
4 |
5 |
6 | class tui:
7 | # use direct access, it is absolute addressing on raw terminal.
8 | out = sys.__stdout__.write
9 |
10 | # save cursor
11 | def __enter__(self):
12 | self.out("\x1b7\x1b[?25l")
13 | return self
14 |
15 | # restore cursor
16 | def __exit__(self, *tb):
17 | self.out("\x1b8\x1b[?25h")
18 |
19 | def __call__(self, *a, **kw):
20 | self.out("\x1b[{};{}H{}".format(kw.get("z", 12), kw.get("x", 40), " ".join(a)))
21 |
22 |
23 | def step(x=70, y=0, z=2):
24 | import time
25 |
26 | def box(t, x, y, z):
27 | lines = t.split("\n")
28 | fill = "─" * len(t)
29 | if z > 1:
30 | print("┌%s┐" % fill, x=x, z=z - 1)
31 | for t in lines:
32 | print("│%s│" % t, x=x, z=z)
33 | z += 1
34 | print("└%s┘" % fill, x=x, z=z)
35 |
36 | with tui() as print:
37 | # draw a clock
38 | t = "%02d:%02d:%02d ☢ 99%% " % time.localtime()[3:6]
39 | box(t, x=x, y=y, z=z)
40 |
41 |
42 | async def clock(x=70, y=0, z=2):
43 | # run as a daemon
44 | while True: # not asyncio.exit:
45 | step(x, y, z)
46 | await asyncio.sleep(1)
47 | sys.stdout.flush()
48 |
49 |
50 | def start(x=70, y=0, z=2):
51 | asyncio.create_task(clock(x, y, z))
52 |
--------------------------------------------------------------------------------
/python-wasm-plus.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | reset
3 | export SDKROOT=${SDKROOT:-$(pwd)}
4 | export PYBUILD=${PYBUILD:-3.11}
5 |
6 | chmod +x scripts/*.sh ./support/*.sh
7 |
8 | mkdir -p build/pycache
9 | export PYTHONDONTWRITEBYTECODE=1
10 |
11 | # make install cpython will force bytecode generation
12 | export PYTHONPYCACHEPREFIX="$(realpath build/pycache)"
13 |
14 | ./scripts/cpython-fetch.sh
15 | ./support/__EMSCRIPTEN__.sh
16 |
17 | ./scripts/cpython-build-host-deps.sh >/dev/null
18 | ./scripts/cpython-build-host.sh >/dev/null
19 | ./scripts/cpython-build-host-prebuilt.sh >/dev/null
20 |
21 | # use ./ or emsdk will pollute env
22 | ./scripts/emsdk-fetch.sh
23 |
24 | echo " ------------------- building cpython wasm deps -------------------"
25 | ./scripts/cpython-build-emsdk-deps.sh > /dev/null
26 |
27 |
28 | echo " ------------------- building cpython wasm -----------------------"
29 | if ./scripts/cpython-build-emsdk.sh > /dev/null
30 | then
31 | echo " ------------------- building cpython wasm packages ----------"
32 | ./scripts/cpython-build-emsdk-deps.sh
33 |
34 | echo " ------------------- building cpython pygame -------------------"
35 | ./scripts/pygame-all.sh > /dev/null
36 |
37 | # pygame won't build if python or sdl failed
38 | [ -f prebuilt/emsdk/libpygame${PYBUILD}.a ] || exit 34
39 |
40 | else
41 | echo " cpython-build-emsdk failed"
42 | exit 38
43 | fi
44 |
45 | echo done
46 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.yml:
--------------------------------------------------------------------------------
1 | name: emsdk_build
2 | on: [workflow_dispatch]
3 |
4 | jobs:
5 | # Build job. Builds app for web with emsdk
6 | build-emsdk:
7 | name: Build for Emscripten
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Checkout
13 | run: |
14 | WD=$(pwd)
15 | python3 -V
16 | echo $WD
17 | clang --version | head -n 1
18 | echo
19 | grep "^Pkg.Revision =" ${ANDROID_HOME}/ndk-bundle/source.properties
20 | cd $GITHUB_WORKSPACE/..
21 | export PROJECT=$(basename $(find $GITHUB_WORKSPACE/static|grep py$) .py)
22 | git clone https://github.com/pmp-p/python-wasm-plus.git
23 | ln -s $GITHUB_WORKSPACE python-wasm-plus/demos/$PROJECT
24 | cd python-wasm-plus
25 | bash ./python-wasm-plus.sh
26 | bash ./buildapp.sh templates/no-worker demos/$PROJECT demo
27 | cd $GITHUB_WORKSPACE/../python-wasm-plus/demos/$PROJECT
28 | echo "==================="
29 | pwd
30 | echo "==================="
31 | cd $GITHUB_WORKSPACE/../python-wasm-plus/build
32 | mv demo $GITHUB_WORKSPACE/
33 | cd $GITHUB_WORKSPACE/
34 | pwd
35 | ls -al demo
36 | du -hs demo/*
37 |
38 |
39 | - name : "Upload to GitHub pages"
40 | uses: JamesIves/github-pages-deploy-action@4.1.7
41 | with:
42 | branch: gh-pages
43 | folder: demo
44 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.patches/3.11/asyncio/__init__.py:
--------------------------------------------------------------------------------
1 | """The asyncio package, tracking PEP 3156."""
2 |
3 | # flake8: noqa
4 |
5 | import sys
6 |
7 | # This relies on each of the submodules having an __all__ variable.
8 | from .base_events import *
9 | from .coroutines import *
10 | from .events import *
11 | from .exceptions import *
12 | from .futures import *
13 | from .locks import *
14 | from .protocols import *
15 | from .runners import *
16 | from .queues import *
17 | from .streams import *
18 | from .subprocess import *
19 | from .tasks import *
20 | from .taskgroups import *
21 | from .timeouts import *
22 | from .threads import *
23 | from .transports import *
24 |
25 | __all__ = (base_events.__all__ +
26 | coroutines.__all__ +
27 | events.__all__ +
28 | exceptions.__all__ +
29 | futures.__all__ +
30 | locks.__all__ +
31 | protocols.__all__ +
32 | runners.__all__ +
33 | queues.__all__ +
34 | streams.__all__ +
35 | subprocess.__all__ +
36 | tasks.__all__ +
37 | threads.__all__ +
38 | timeouts.__all__ +
39 | transports.__all__)
40 |
41 | if sys.platform == 'win32': # pragma: no cover
42 | from .windows_events import *
43 | __all__ += windows_events.__all__
44 | elif sys.platform in ['emscripten','wasi']:
45 | from .wasm_events import *
46 | __all__ += wasm_events.__all__
47 | else:
48 | from .unix_events import * # pragma: no cover
49 | __all__ += unix_events.__all__
50 |
51 |
52 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.patches/3.10/asyncio/__init__.py:
--------------------------------------------------------------------------------
1 | """The asyncio package, tracking PEP 3156."""
2 |
3 | # flake8: noqa
4 |
5 | import sys
6 |
7 | # This relies on each of the submodules having an __all__ variable.
8 | from .base_events import *
9 | from .coroutines import *
10 | from .events import *
11 | from .exceptions import *
12 | from .futures import *
13 | from .locks import *
14 | from .protocols import *
15 | from .runners import *
16 | from .queues import *
17 | from .streams import *
18 | from .subprocess import *
19 | from .tasks import *
20 | #from .taskgroups import *
21 | #from .timeouts import *
22 | from .threads import *
23 | from .transports import *
24 |
25 | __all__ = (base_events.__all__ +
26 | coroutines.__all__ +
27 | events.__all__ +
28 | exceptions.__all__ +
29 | futures.__all__ +
30 | locks.__all__ +
31 | protocols.__all__ +
32 | runners.__all__ +
33 | queues.__all__ +
34 | streams.__all__ +
35 | subprocess.__all__ +
36 | tasks.__all__ +
37 | threads.__all__ +
38 | # timeouts.__all__ +
39 | transports.__all__)
40 |
41 | if sys.platform == 'win32': # pragma: no cover
42 | from .windows_events import *
43 | __all__ += windows_events.__all__
44 | elif sys.platform in ['emscripten','wasi']:
45 | from .wasm_events import *
46 | __all__ += wasm_events.__all__
47 | else:
48 | from .unix_events import * # pragma: no cover
49 | __all__ += unix_events.__all__
50 |
51 |
52 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__.embed/cpython.diff:
--------------------------------------------------------------------------------
1 | --- Python-3.11.0b1/Modules/readline.c 2022-05-07 00:56:26.000000000 +0200
2 | +++ Python-3.11.0b1-plus/Modules/readline.c 2022-05-21 22:57:01.680634385 +0200
3 | @@ -1326,7 +1326,9 @@
4 | int has_input = 0, err = 0;
5 |
6 | while (!has_input)
7 | - { struct timeval timeout = {0, 100000}; /* 0.1 seconds */
8 | + {
9 | +
10 | + struct timeval timeout = {0, 5000}; /* 0.005 seconds */
11 |
12 | /* [Bug #1552726] Only limit the pause if an input hook has been
13 | defined. */
14 | --- Python-3.11.0b1/Python/sysmodule.c 2022-05-07 00:56:26.000000000 +0200
15 | +++ Python-3.11.0b1-plus/Python/sysmodule.c 2022-05-21 22:58:12.873024434 +0200
16 | @@ -48,7 +48,7 @@
17 | extern const char *PyWin_DLLVersionString;
18 | #endif
19 |
20 | -#ifdef __EMSCRIPTEN__
21 | +#if 0
22 | #include
23 | #endif
24 |
25 | @@ -2692,7 +2692,7 @@
26 | return NULL;
27 | }
28 |
29 | -#ifdef __EMSCRIPTEN__
30 | +#if 0
31 |
32 | PyDoc_STRVAR(emscripten_info__doc__,
33 | "sys._emscripten_info\n\
34 | @@ -2928,7 +2928,7 @@
35 | }
36 | }
37 |
38 | -#ifdef __EMSCRIPTEN__
39 | +#if 0
40 | if (EmscriptenInfoType == NULL) {
41 | EmscriptenInfoType = PyStructSequence_NewType(&emscripten_info_desc);
42 | if (EmscriptenInfoType == NULL) {
43 | @@ -3183,7 +3183,7 @@
44 | #endif
45 | _PyStructSequence_FiniType(&Hash_InfoType);
46 | _PyStructSequence_FiniType(&AsyncGenHooksType);
47 | -#ifdef __EMSCRIPTEN__
48 | +#if 0
49 | Py_CLEAR(EmscriptenInfoType);
50 | #endif
51 | }
52 |
--------------------------------------------------------------------------------
/support/cross/aio/toplevel.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import aio
3 |
4 | # import textwrap
5 |
6 | # https://bugs.python.org/issue34616
7 | # https://github.com/ipython/ipython/blob/320d21bf56804541b27deb488871e488eb96929f/IPython/core/interactiveshell.py#L121-L150
8 |
9 | async_skeleton = """
10 | #==========================================
11 | async def retry_async_wrap():
12 | __snapshot = list( locals().keys() )
13 | {}
14 | maybe_new = list( locals().keys() )
15 | while len(__snapshot):
16 | try:maybe_new.remove( __snapshot.pop() )
17 | except:pass
18 | maybe_new.remove('__snapshot')
19 | while len(maybe_new):
20 | new_one = maybe_new.pop(0)
21 | print(new_one , ':=', locals()[new_one])
22 | setattr(__import__('__main__'), new_one , locals()[new_one] )
23 | #==========================================
24 | """
25 |
26 |
27 | async def retry(code, sysinfo ):
28 | global may_have_value
29 | may_have_value = code.startswith('await ') # will display value
30 | try:
31 | code = 'builtins._ = {}'.format(code)
32 | code = async_skeleton.format(" " * 4 + code)
33 | bytecode = compile(code, "", "exec")
34 | #sys.stdout.write(f':async: asyncify "[code stack rewritten]"\n')
35 |
36 | exec(bytecode, vars(__import__('__main__')), globals())
37 | await retry_async_wrap()
38 |
39 | # success ? clear all previous failures
40 | if may_have_value:
41 | if builtins._ is not None:
42 | sys.stdout.write('%r\n' % builtins._)
43 |
44 |
45 |
46 | except Exception as e:
47 | # FIXME: raise old exception
48 | sys.__excepthook__(*sysinfo)
49 | sys.stdout.write(f":async: can't use code : {e}\n~~> ")
50 | sys.print_exception(e)
51 | finally:
52 | #sys.ps1 = __ps1__
53 | aio.prompt_request()
54 |
--------------------------------------------------------------------------------
/python-wasm-sim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | reset
3 | unset PYTHONSTARTUP
4 | ROOT=$(dirname $(realpath $0))
5 |
6 | export PYBUILD=${PYBUILD:-3.11}
7 | export PYMAJOR=$(echo -n $PYBUILD|cut -d. -f1)
8 | export PYMINOR=$(echo -n $PYBUILD|cut -d. -f2)
9 |
10 | export PLATFORM=$ROOT/support/sim.links
11 |
12 | mkdir -p $PLATFORM
13 | echo "
14 |
15 |
16 | Put platform (host) modules or symlink to platform independant ones there :
17 | $PLATFORM
18 |
19 | "
20 |
21 | export PYTHONRC=$ROOT/support/pythonrc.py
22 |
23 | export __FILE__="$1"
24 | #export PATH=$ROOT/devices/$(arch)/usr/bin:$PATH
25 | cat $ROOT/support/cross/aio/simulator.py | envsubst > $ROOT/build/pycache/.pythonrc.py
26 |
27 | unset PYTHONHOME
28 | unset _PYTHON_SYSCONFIGDATA_NAME
29 |
30 | export PYTHONPATH=$(pwd):$ROOT/support/cross:$ROOT/support/sim.links:$PYTHONPATH
31 |
32 | export _PYTHON_SYSCONFIGDATA_NAME=$($ROOT/devices/$(arch)/usr/bin/python3 -c 'import sys;print(f"""_sysconfigdata_{sys.abiflags}_{sys.platform}_{getattr(sys.implementation, "_multiarch", "")}""")')
33 | echo "_PYTHON_SYSCONFIGDATA_NAME=$_PYTHON_SYSCONFIGDATA_NAME"
34 |
35 | export PYTHONSTARTUP=$ROOT/build/pycache/.pythonrc.py
36 |
37 |
38 | PYTHONPATH=$ROOT/prebuilt/emsdk/common/site-packages:$PYTHONPATH
39 |
40 | if false
41 | then
42 | PYTHONPATH=$ROOT/devices/emsdk/usr/lib/python${PYBUILD}:$PYTHONPATH
43 | PYTHONPATH=$ROOT/devices/$(arch)/usr/lib/python${PYBUILD}/site-packages:$PYTHONPATH
44 | export PYTHONPATH
45 | echo "======== SYSTEM PYTHON ============="
46 | export LD_LIBRARY_PATH=$ROOT/devices/$(arch)/usr/lib
47 | /usr/local/bin/python${PYBUILD}
48 | python${PYBUILD} -i -u -B
49 |
50 | else
51 |
52 | export LD_LIBRARY_PATH=$ROOT/devices/$(arch)/usr/lib
53 | export PYTHONPATH=$ROOT/devices/$(arch)/usr/lib/python${PYBUILD}/lib-dynload:$PYTHONPATH
54 | $ROOT/devices/$(arch)/usr/bin/python${PYBUILD} -i -u -B
55 | fi
56 | stty sane
57 |
--------------------------------------------------------------------------------
/templates/libs/xterm/xtermjsixel/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: helvetica, sans-serif, arial;
3 | font-size: 1em;
4 | color: #111;
5 | }
6 |
7 | h1 {
8 | text-align: center;
9 | }
10 |
11 | #terminal-container {
12 | width: 800px;
13 | height: 450px;
14 | margin: 0 auto;
15 | padding: 2px;
16 | }
17 |
18 | p {
19 | font-size: 0.9em;
20 | font-style: italic
21 | }
22 |
23 | #option-container {
24 | display: flex;
25 | justify-content: center;
26 | }
27 |
28 | .option-group {
29 | display: inline-block;
30 | padding-left: 20px;
31 | vertical-align: top;
32 | }
33 |
34 | pre {
35 | display: block;
36 | padding: 9.5px;
37 | font-size: 13px;
38 | color: #c7254e;
39 | background-color: #f9f2f4;
40 | word-break: break-all;
41 | word-wrap: break-word;
42 | white-space: pre-wrap;
43 | }
44 |
45 |
46 | #container {
47 | display: flex;
48 | height: 75vh;
49 | }
50 | #grid {
51 | flex: 1;
52 | /* max-height: 80vh;
53 | overflow-y: auto; */
54 | width: 100%;
55 | }
56 | .tab {
57 | overflow: hidden;
58 | border: 1px solid #ccc;
59 | background-color: #f1f1f1;
60 | }
61 |
62 | /* Style the buttons inside the tab */
63 | .tab button {
64 | background-color: inherit;
65 | float: left;
66 | border: none;
67 | outline: none;
68 | cursor: pointer;
69 | padding: 14px 16px;
70 | transition: 0.3s;
71 | font-size: 17px;
72 | }
73 |
74 | /* Change background color of buttons on hover */
75 | .tab button:hover {
76 | background-color: #ddd;
77 | }
78 |
79 | /* Create an active/current tablink class */
80 | .tab button.active {
81 | background-color: #ccc;
82 | }
83 |
84 | /* Style the tab content */
85 | .tabContent {
86 | display: none;
87 | padding: 6px 12px;
88 | border: 1px solid #ccc;
89 | border-top: none;
90 | max-height: 100vh;
91 | overflow-y: auto;
92 | }
93 |
--------------------------------------------------------------------------------
/support/__EMSCRIPTEN__-pymain.c:
--------------------------------------------------------------------------------
1 | /* Minimal main program -- everything is loaded from the library */
2 |
3 | #include "Python.h"
4 |
5 | #if __PYDK__
6 | #include "pycore_call.h" // _PyObject_CallNoArgs()
7 | #include "pycore_initconfig.h" // _PyArgv
8 | #include "pycore_interp.h" // _PyInterpreterState.sysdict
9 | #include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0()
10 | #include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv()
11 | #include "pycore_pystate.h" // _PyInterpreterState_GET()
12 |
13 | static PyStatus
14 | pymain_init(const _PyArgv *args)
15 | {
16 | PyStatus status;
17 |
18 | status = _PyRuntime_Initialize();
19 | if (_PyStatus_EXCEPTION(status)) {
20 | return status;
21 | }
22 |
23 | PyPreConfig preconfig;
24 | PyPreConfig_InitPythonConfig(&preconfig);
25 |
26 | status = _Py_PreInitializeFromPyArgv(&preconfig, args);
27 | if (_PyStatus_EXCEPTION(status)) {
28 | return status;
29 | }
30 |
31 | PyConfig config;
32 | PyConfig_InitPythonConfig(&config);
33 |
34 | if (args->use_bytes_argv) {
35 | status = PyConfig_SetBytesArgv(&config, args->argc, args->bytes_argv);
36 | }
37 | else {
38 | status = PyConfig_SetArgv(&config, args->argc, args->wchar_argv);
39 | }
40 | if (_PyStatus_EXCEPTION(status)) {
41 | goto done;
42 | }
43 |
44 | status = Py_InitializeFromConfig(&config);
45 | if (_PyStatus_EXCEPTION(status)) {
46 | goto done;
47 | }
48 | status = _PyStatus_OK();
49 |
50 | done:
51 | PyConfig_Clear(&config);
52 | return status;
53 | }
54 |
55 | static void
56 | pymain_free(void)
57 | {
58 | _PyImport_Fini2();
59 | _PyPathConfig_ClearGlobal();
60 | _Py_ClearStandardStreamEncoding();
61 | _Py_ClearArgcArgv();
62 | _PyRuntime_Finalize();
63 | }
64 |
65 | #include "__EMSCRIPTEN__.c"
66 | #else
67 | int
68 | main(int argc, char **argv)
69 | {
70 |
71 | return Py_BytesMain(argc, argv);
72 | }
73 | #endif //#if __PYDK__
74 |
--------------------------------------------------------------------------------
/demos/0-pong/1001fonts-morris-roman-eula.txt:
--------------------------------------------------------------------------------
1 | 1001Fonts Free For Commercial Use License (FFC)
2 |
3 | Preamble
4 | In this license, 'Morris Roman' refers to the given .zip file, which may contain one or numerous fonts. These fonts can be of any type (.ttf, .otf, ...) and together they form a 'font family' or in short a 'typeface'.
5 |
6 | 1. Copyright
7 | Morris Roman is the intellectual property of its respective author, provided it is original, and is protected by copyright laws in many parts of the world.
8 |
9 | 2. Usage
10 | Morris Roman may be downloaded and used free of charge for both personal and commercial use, as long as the usage is not racist or illegal. Personal use refers to all usage that does not generate financial income in a business manner, for instance:
11 |
12 | - personal scrapbooking for yourself
13 | - recreational websites and blogs for friends and family
14 | - prints such as flyers, posters, t-shirts for churches, charities, and non-profit organizations
15 |
16 | Commercial use refers to usage in a business environment, including:
17 |
18 | - business cards, logos, advertising, websites for companies
19 | - t-shirts, books, apparel that will be sold for money
20 | - flyers, posters for events that charge admission
21 | - freelance graphic design work
22 | - anything that will generate direct or indirect income
23 |
24 | 3. Modification
25 | Morris Roman may not be modified, altered, adapted or built upon without written permission by its respective author. This pertains all files within the downloadable font zip-file.
26 |
27 | 4. Distribution
28 | While Morris Roman may freely be copied and passed along to other individuals for private use as its original downloadable zip-file, it may not be sold or published without written permission by its respective author.
29 |
30 | 5. Disclaimer
31 | Morris Roman is offered 'as is' without any warranty. 1001fonts.com and the respective author of Morris Roman shall not be liable for any damage derived from using this typeface. By using Morris Roman you agree to the terms of this license.
--------------------------------------------------------------------------------
/support/cross/aio/trace.py:
--------------------------------------------------------------------------------
1 | STEP_INTO = False
2 |
3 | def on():
4 | global STEP_INTO
5 | STEP_INTO = True
6 |
7 | def off():
8 | global STEP_INTO
9 | STEP_INTO = False
10 |
11 | def lines(frame, event, arg):
12 | if event != 'line':
13 | return
14 | co = frame.f_code
15 | func_name = co.co_name
16 | line_no = frame.f_lineno
17 | filename = co.co_filename
18 | print(f" {func_name} line {line_no}")
19 |
20 |
21 | def calls(frame, event, arg):
22 | global STEP_INTO
23 |
24 | if event != "call":
25 | return
26 |
27 | co = frame.f_code
28 | func_name = co.co_name
29 | if func_name in ("write"):
30 | return
31 | func_line_no = frame.f_lineno
32 | func_filename = co.co_filename
33 |
34 | if func_filename.startswith("/usr/lib/python3."):
35 | return
36 |
37 | if func_filename.find("/aio/") > 0:
38 | return
39 |
40 | caller = frame.f_back
41 | if caller:
42 | caller_line_no = caller.f_lineno
43 | caller_filename = caller.f_code.co_filename
44 | if caller_filename != func_filename:
45 | print(
46 | "%s() on line %s of %s from line %s of %s"
47 | % (
48 | func_name,
49 | func_line_no,
50 | func_filename,
51 | caller_line_no,
52 | caller_filename,
53 | )
54 | )
55 | else:
56 | print(f"{func_name} {func_filename}:{caller_line_no}->{func_line_no}")
57 |
58 | if STEP_INTO:
59 | return lines
60 | return
61 |
62 | """
63 |
64 | def trace_calls_and_returns(frame, event, arg):
65 | co = frame.f_code
66 | func_name = co.co_name
67 | if func_name == 'write':
68 | # Ignore write() calls from print statements
69 | return
70 | line_no = frame.f_lineno
71 | filename = co.co_filename
72 | if event == 'call':
73 | print 'Call to %s on line %s of %s' % (func_name, line_no, filename)
74 | return trace_calls_and_returns
75 | elif event == 'return':
76 | print '%s => %s' % (func_name, arg)
77 | return
78 |
79 |
80 | """
81 |
--------------------------------------------------------------------------------
/config:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | export LC_ALL=C
3 | export ROOT=${ROOT:-$(pwd)}
4 | export SDKROOT=${SDKROOT:-$ROOT}
5 |
6 | export PYTHONDONTWRITEBYTECODE=1
7 | export REBUILD=${REBUILD:-false}
8 | export CI=${CI:-false}
9 |
10 | export PYBUILD=${PYBUILD:-3.11}
11 | export PYMAJOR=$(echo -n $PYBUILD|cut -d. -f1)
12 | export PYMINOR=$(echo -n $PYBUILD|cut -d. -f2)
13 |
14 | export HOST_PREFIX=${HOST_PREFIX:-${SDKROOT}/devices/$(arch)/usr}
15 | export PREFIX=${PREFIX:-${SDKROOT}/devices/emsdk/usr}
16 |
17 | mkdir -p ${SDKROOT}/build/pycache
18 | export PYTHONPYCACHEPREFIX=${PYTHONPYCACHEPREFIX:-$(realpath ${SDKROOT}/build/pycache)}
19 |
20 | export HOME=${SDKROOT}
21 |
22 | export HPY=${HOST_PREFIX}/bin/python${PYBUILD}
23 | export PIP=${HOST_PREFIX}/bin/pip${PYBUILD}
24 |
25 | # cpython build opts
26 | export CPOPTS="-Os -g0 -fPIC"
27 |
28 |
29 | if [ -f ${ROOT}/dev ]
30 | then
31 | export COPTS="-O1 -g3 -fPIC"
32 | export QUIET=""
33 | else
34 | export COPTS="-Os -g0 -fPIC"
35 | if ${VERBOSE:-false}
36 | then
37 | export QUIET=""
38 | else
39 | export QUIET="2>&1 > $PYTHONPYCACHEPREFIX/.log"
40 | fi
41 | fi
42 |
43 |
44 | #stable
45 | # EMFLAVOUR=latest
46 | # EMFLAVOUR=${EMFLAVOUR:-latest}
47 |
48 | export EMFLAVOUR=${EMFLAVOUR:-tot}
49 |
50 | #temp fix for oom on CI (Error: Process completed with exit code 143.)
51 | export EMSDK_NUM_CORES=1
52 |
53 |
54 | export PYDK_PYTHON_HOST_PLATFORM=wasm32-$EMFLAVOUR-emscripten
55 |
56 | if echo $LD_LIBRARY_PATH |grep -q ${HOST_PREFIX}/lib
57 | then
58 | # config already set
59 | echo -n
60 | else
61 | OLDPATH=${PATH}
62 | PATH=/usr/local/bin:/usr/bin:/opt/bin:/bin
63 | # this is python used for emsdk : ${SYS_PYTHON} -> ${EMSDK_PYTHON}
64 | for py in 10 9 8 7
65 | do
66 | if command -v python${PYMAJOR}.${py} >/dev/null
67 | then
68 | export SYS_PYTHON=$(command -v python${PYMAJOR}.${py})
69 | break
70 | else
71 | # sane default
72 | export SYS_PYTHON=$(command -v python${PYMAJOR})
73 | fi
74 | done
75 |
76 | export LD_LIBRARY_PATH="${HOST_PREFIX}/lib:$LD_LIBRARY_PATH"
77 | export PATH="${HOST_PREFIX}/bin:$OLDPATH"
78 | fi
79 |
--------------------------------------------------------------------------------
/scripts/re-pack-apk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ -d .git ]
4 | then
5 | CREDITS_GH=$(git remote -v|head -n1 | cut -d' ' -f1|cut -c8-)
6 | else
7 | CREDITS_GH="Not a git repo"
8 | fi
9 |
10 |
11 |
12 | WEB=${1:-demo}
13 |
14 | CN=$(basename $(pwd))
15 |
16 | APK=$CN.apk
17 | echo "
18 | APK=$APK
19 |
20 | Web Service Folder : $WEB
21 |
22 | assets folder: $(pwd)
23 |
24 | CREDITS:
25 | GH $CREDITS_GH
26 |
27 | "
28 |
29 | export TEMP=some_name_no_one_would_choose
30 |
31 |
32 | if [ -d static ]
33 | then
34 | rm ../../build/$WEB/$APK $APK
35 |
36 | mkdir $TEMP
37 |
38 | mv static ../$APK-static
39 | mv * ./$TEMP/ 2>/dev/null
40 |
41 | mv ./$TEMP/META-INF ./
42 | mv ./$TEMP/package.toml ./
43 |
44 | mv $TEMP assets
45 |
46 | zip -r9 ${APK} . --exclude .git/\* -x .gitignore | wc -l
47 | sync
48 | if du -hs ${APK}
49 | then
50 |
51 | mv ../$APK-static static
52 |
53 |
54 | mv assets ./$TEMP/
55 | mv ./$TEMP/* ./
56 | rmdir ./$TEMP
57 |
58 | cat > static/$CN.html <
60 |
61 | Github: $CREDITS_GH
62 | END
63 |
64 |
65 | if [ -d .git ]
66 | then
67 | git status 2>&1 |grep -v \(use |grep -v ^$|grep -v :$|\
68 | grep -v ^Your |grep -v ^On | grep -v apk$ |grep -v static/ >> static/$CN.html
69 | else
70 | cat package.toml >> static/$CN.html
71 | fi
72 |
73 | cat >> static/$CN.html <
75 |