Skip to content
Merged

4x #112

Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: docs
on:
workflow_dispatch:
push:
pull_request:
branches:
- main
# pull_request:


defaults:
Expand Down Expand Up @@ -38,7 +40,7 @@ jobs:
environment-name: pyjs-wasm
condarc: |
channels:
- https://repo.mamba.pm/emscripten-forge
- https://repo.mamba.pm/emscripten-forge-4x
- conda-forge

- name: build the docs
Expand Down
30 changes: 13 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ jobs:

strategy:
fail-fast: false
matrix:
include:
- emsdk_ver: "3.1.73"
python_version: "3.13"
pybind11_version: "<3"

steps:
- uses: actions/checkout@v2

Expand All @@ -34,7 +30,7 @@ jobs:
environment-name: pyjs-wasm
condarc: |
channels:
- https://repo.prefix.dev/emscripten-forge-dev
- https://repo.prefix.dev/emscripten-forge-4x
- conda-forge


Expand All @@ -48,14 +44,14 @@ jobs:

micromamba create -n pyjs-build-wasm \
--platform=emscripten-wasm32 \
-c https://repo.prefix.dev/emscripten-forge-dev\
-c https://repo.prefix.dev/emscripten-forge-4x \
-c https://repo.mamba.pm/conda-forge \
--yes \
python=${{matrix.python_version}} \
"pybind11${{matrix.pybind11_version}}" \
"python=3.13" \
"pybind11<3" \
nlohmann_json pybind11_json numpy \
pytest bzip2 sqlite zlib zstd libffi \
exceptiongroup emscripten-abi==${{matrix.emsdk_ver}} \
exceptiongroup emscripten-abi>=4 \
openssl liblzma


Expand Down Expand Up @@ -87,10 +83,10 @@ jobs:
micromamba activate pyjs-wasm
micromamba create -n pyjs-build-wasm-with-numpy \
--platform=emscripten-wasm32 \
-c https://repo.prefix.dev/emscripten-forge-dev\
-c https://repo.prefix.dev/emscripten-forge-4x \
-c https://repo.mamba.pm/conda-forge \
--yes \
"python=${{matrix.python_version}}" pytest numpy exceptiongroup
"python=3.13" pytest numpy exceptiongroup


- name: Test in browser-main
Expand All @@ -100,7 +96,7 @@ jobs:
browser-main \
--conda-env $MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm-with-numpy \
--mount $(pwd)/tests:/tests \
--mount $(pwd)/module/pyjs:/lib/python${{matrix.python_version}}/site-packages/pyjs \
--mount $(pwd)/module/pyjs:/lib/python3.13/site-packages/pyjs \
--script main.py \
--work-dir /tests \
--pyjs-dir $(pwd)/build \
Expand All @@ -116,7 +112,7 @@ jobs:
browser-worker \
--conda-env $MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm-with-numpy \
--mount $(pwd)/tests:/tests \
--mount $(pwd)/module/pyjs:/lib/python${{matrix.python_version}}/site-packages/pyjs \
--mount $(pwd)/module/pyjs:/lib/python3.13/site-packages/pyjs \
--script main.py \
--work-dir /tests \
--pyjs-dir $(pwd)/build \
Expand All @@ -128,10 +124,10 @@ jobs:
micromamba activate pyjs-wasm
micromamba create -n pyjs-build-wasm-no-numpy \
--platform=emscripten-wasm32 \
-c https://repo.prefix.dev/emscripten-forge-dev\
-c https://repo.prefix.dev/emscripten-forge-4x \
-c https://repo.mamba.pm/conda-forge \
--yes \
"python=${{matrix.python_version}}" pytest exceptiongroup
"python=3.13" pytest exceptiongroup

- name: Test in browser-main-no-numpy
run: |
Expand All @@ -142,7 +138,7 @@ jobs:
browser-main \
--conda-env $MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm-no-numpy \
--mount $(pwd)/tests:/tests \
--mount $(pwd)/module/pyjs:/lib/python${{matrix.python_version}}/site-packages/pyjs \
--mount $(pwd)/module/pyjs:/lib/python3.13/site-packages/pyjs \
--script main.py \
--work-dir /tests \
--pyjs-dir $(pwd)/build \
Expand Down
58 changes: 35 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ target_link_libraries(pyjs PRIVATE ${PYTHON_UTIL_LIBS} pybind11::embed)

target_compile_options(pyjs
PUBLIC --std=c++17
PUBLIC -msimd128
PUBLIC -Wno-deprecated
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -fwasm-exceptions"
)

target_link_options(pyjs
PRIVATE -lembind
PUBLIC -Wno-unused-command-line-argument
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -lembind"
# PUBLIC "SHELL: -fsanitize=address"
#PUBLIC "SHELL:-s EXPORT_EXCEPTION_HANDLING_HELPERS"
#PUBLIC "SHELL:-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules']"
)
Expand Down Expand Up @@ -198,44 +200,54 @@ target_link_libraries(pyjs_runtime_browser PRIVATE pyjs pybind11::embed ${PYTHO
target_compile_options(pyjs_runtime_browser
PUBLIC --std=c++17
PUBLIC -Wno-deprecated
PUBLIC -msimd128
PUBLIC "SHELL: -s ENVIRONMENT=${ENVIRONMENT}"
PUBLIC "SHELL: -fexceptions"
#PUBLIC "SHELL:-s EXPORT_EXCEPTION_HANDLING_HELPERS"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -sSUPPORT_LONGJMP"
PUBLIC "SHELL: -s EXPORT_EXCEPTION_HANDLING_HELPERS"
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
PUBLIC "SHELL: -s LZ4=1"
PUBLIC "SHELL: -flto"
# PUBLIC "SHELL: -s WASM_BIGINT"
PUBLIC "SHELL: -s EXPORT_ALL=1"
# PUBLIC "SHELL: -flto"
# PUBLIC "SHELL: -s MAXIMUM_MEMORY=2GB"
# PUBLIC "SHELL: -fsanitize=address"
)

target_link_options(pyjs_runtime_browser
PRIVATE -lembind
PUBLIC -Wno-unused-command-line-argument
PUBLIC "SHELL: -s MODULARIZE=1"
PUBLIC "SHELL: -s EXPORT_NAME=\"createModule\""
PUBLIC "SHELL: -s EXPORT_ES6=0"
PUBLIC "SHELL: -s USE_ES6_IMPORT_META=0"
PUBLIC "SHELL: -s DEMANGLE_SUPPORT=0"
PUBLIC "SHELL: -s ASSERTIONS=0"
PUBLIC "SHELL: -s EXPORT_ALL=1"
PUBLIC "SHELL: -s EXPORT_EXCEPTION_HANDLING_HELPERS"
# PUBLIC "SHELL: -s EXPORT_ES6=0"
# PUBLIC "SHELL: -s DEMANGLE_SUPPORT=0"
# PUBLIC "SHELL: -s ASSERTIONS=0"
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
PUBLIC "SHELL: -s EXIT_RUNTIME=1"
PUBLIC "SHELL: -s WASM=1"
# PUBLIC "SHELL: -s EXIT_RUNTIME=1"
PUBLIC "SHELL: -s INITIAL_MEMORY=20971520"
PUBLIC "SHELL: -s MAXIMUM_MEMORY=4GB"
# PUBLIC "SHELL: -s WASM=1"
PUBLIC "SHELL: -s USE_PTHREADS=0"
PUBLIC "SHELL: -s ENVIRONMENT=${ENVIRONMENT}"
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -sSUPPORT_LONGJMP"
PUBLIC "SHELL: -s MAIN_MODULE=1"
PUBLIC "SHELL: -s ENVIRONMENT=${ENVIRONMENT}"
PUBLIC "SHELL: -s TOTAL_STACK=16mb"
PUBLIC "SHELL: -s INITIAL_MEMORY=64mb"
# PUBLIC "SHELL: -s MAXIMUM_MEMORY=2GB"
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
PUBLIC "SHELL: -s LZ4=1"
PUBLIC "SHELL: --post-js pyjs_post.js"
PUBLIC "SHELL: --pre-js pyjs_pre.js"
PUBLIC "SHELL: -flto"
PUBLIC "SHELL: -lidbfs.js"
PUBLIC "SHELL: -s WASM_BIGINT"
# PUBLIC "SHELL: -flto"
# PUBLIC "SHELL: -lidbfs.js"
PUBLIC "SHELL: -lembind"
# PUBLIC "SHELL: -fsanitize=address"
)


# target_link_options(pyjs_runtime_browser PRIVATE
# "-sEXPORTED_FUNCTIONS=['_emscripten_dlopen_promise','_dlerror','FS']"
# )



install(TARGETS pyjs_runtime_browser
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib_js/pyjs)
install(FILES
Expand Down
2 changes: 1 addition & 1 deletion build_mkdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ ! -d "$WASM_ENV_PREFIX" ]; then
echo "Creating wasm env $WASM_ENV_NAME"
micromamba create -n $WASM_ENV_NAME \
--platform=emscripten-wasm32 \
-c https://repo.prefix.dev/emscripten-forge-dev\
-c https://repo.prefix.dev/emscripten-forge-4x\
-c https://repo.prefix.dev/conda-forge \
--yes \
python=$PYTHON_VERSION "pybind11<3" nlohmann_json pybind11_json numpy \
Expand Down
7 changes: 4 additions & 3 deletions environment-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: pyjs-wasm
channels:
- conda-forge
- https://repo.prefix.dev/emscripten-forge-dev
- https://repo.prefix.dev/emscripten-forge-4x

dependencies:
- cmake
- pip
Expand All @@ -19,15 +20,15 @@ dependencies:
- mkdocstrings
- mkdocstrings-python
- mkdocs-material
- empack >=3.2.0
- empack >=6.0.0
- jupyter_server # to enable contents
- jupyterlite
- jupyterlite-xeus >= 3.1.8
- jupyterlite-sphinx
- notebook >=7,<8 # to include the extension to switch between JupyterLab and Notebook
# pyjs_code_runner dev deps
- hatchling
- emscripten_emscripten-wasm32
- emscripten_emscripten-wasm32 == 4.0.9
- pip:
- JLDracula
- pyjs_code_runner >= 3.0
8 changes: 8 additions & 0 deletions include/pyjs/post_js/fixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ Module['PATH'] = PATH
Module['LDSO'] = LDSO
Module['getDylinkMetadata'] = getDylinkMetadata
Module['loadDynamicLibrary'] = loadDynamicLibrary
Module['getPromise'] = getPromise
Module['promiseMap'] = promiseMap

Module['stackSave'] = stackSave
Module['stackRestore'] = stackRestore
Module['runtimeKeepalivePush'] = runtimeKeepalivePush
Module['UTF8ToString'] = UTF8ToString
Module['stringToUTF8OnStack'] = stringToUTF8OnStack
Loading