forked from emmatyping/python-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-python-host-emscripten.sh
More file actions
executable file
·57 lines (53 loc) · 2.28 KB
/
build-python-host-emscripten.sh
File metadata and controls
executable file
·57 lines (53 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/env bash
shopt -s extglob
mkdir -p cpython/builddir/host
mkdir -p cpython/builddir/usr/local
# install emcc ports so configure is able to detect the dependencies
embuilder build zlib bzip2
pushd cpython/builddir/host
cp ../../../config.site-wasm config.site-wasm
CONFIG_SITE=config.site-wasm READELF=true ZLIB_LIBS="-s USE_ZLIB" BZIP2_LIBS="-s USE_BZIP2" emconfigure ../../configure -C --without-pymalloc --enable-big-digits=30 --with-pydebug --with-ensurepip=no --disable-ipv6 --host=wasm32-unknown-emscripten --build=$(../../config.guess) --with-build-python=$(pwd)/../build/python --with-freeze-module=$(pwd)/../build/Programs/_freeze_module
ln -sfr Modules/Setup.stdlib Modules/Setup.local
emmake make -j$(nproc)
make altinstall prefix=../usr/local
pushd ../usr/local
# not needed, as the binary is already loaded by the .html
# includes aren't need for distribution, various libraries
# won't be used in the web (at least for now)
rm -rf bin include lib/pkgconfig lib/libpython3.11d.a
rm -f lib/python3.11/_aix_support.py
rm -f lib/python3.11/_bootsubprocess.py
rm -rf lib/python3.11/_osx_support.py
rm -f lib/python3.11/antigravity.py
rm -rf lib/python3.11/asyncio
rm -rf lib/python3.11/concurrent
rm -rf lib/python3.11/config-3.11*
rm -rf lib/python3.11/ctypes
rm -rf lib/python3.11/curses
rm -rf lib/python3.11/dbm
rm -rf lib/python3.11/distutils
rm -rf lib/python3.11/encoding/*.py
rm -rf lib/python3.11/ensurepip
rm -rf lib/python3.11/idlelib
rm -rf lib/python3.11/lib2to3
rm -rf lib/python3.11/multiprocessing
rm -rf lib/python3.11/pydoc_data
rm -rf lib/python3.11/test
rm -rf lib/python3.11/tkinter
rm -rf lib/python3.11/turtle.py
rm -rf lib/python3.11/turtledemo
rm -rf lib/python3.11/venv
rm -f lib/python3.11/webbrowser.py
rm -rf lib/python3.11/wsgiref
find lib/python3.11 -type f \( -iname \*.opt-1.pyc -o -iname \*.opt-2.pyc \) -delete
# os.py is a marker for finding the correct lib directory
# so its important to keep
cd lib/python3.11
zip -9 -r ../python311.zip * -x lib/python3.11/os.py
rm -vrf !(os.py|encoding/__pycache__)
cd ../..
mkdir -p lib/python3.11/lib-dynload
touch lib/python3.11/lib-dynload/.gitignore
popd
emcc -Os -o python.html Programs/python.o libpython3.11d.a Modules/_decimal/libmpdec/libmpdec.a Modules/expat/libexpat.a -ldl -lm -s USE_ZLIB -s USE_BZIP2 --preload-file ../usr
popd