Skip to content

Use make python.html and config.site #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 6 additions & 50 deletions build-python-host-emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,17 @@
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

pushd cpython/builddir/host
cp ../../../config.site-wasm config.site-wasm
CONFIG_SITE=config.site-wasm READELF=true ZLIB_LIBS="-s USE_ZLIB" emconfigure ../../configure -C --without-pymalloc --with-pydebug --host=wasm32-unknown-emscripten --build=$(../../config.guess) --with-build-python=$(pwd)/../build/python --with-freeze-module=$(pwd)/../build/Programs/_freeze_module
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-emscripten \
emconfigure ../../configure -C \
--host=wasm32-unknown-emscripten \
--build=$(../../config.guess) \
--with-build-python=$(pwd)/../build/python

# Use Setup.stdlib and force rebuild of Makefile
ln -sfr Modules/Setup.stdlib Modules/Setup.local
rm Modules/config.c
make Modules/config.c
emmake make -j$(nproc) python.html

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 ASSERTIONS=1 --preload-file ../usr
popd