From 64d3aa31536838e84a4eb5c949251f04b492a6c1 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 2 Sep 2026 16:12:20 +0200 Subject: [PATCH 01/18] 6x --- .github/workflows/docs.yml | 4 ++-- .github/workflows/main.yml | 12 ++++++------ environment-dev.yml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3dc945a..d620987 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,8 +23,8 @@ jobs: fail-fast: false matrix: include: - - emsdk_ver: "3.1.73" - python_version: "3.13" + - emsdk_ver: "6.0.8" + python_version: "3.14" steps: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb46a16..a978eae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,7 +47,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-4x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "python=3.13" \ + "python=3.14" \ "pybind11<3" \ nlohmann_json pybind11_json numpy \ pytest bzip2 sqlite zlib zstd libffi \ @@ -86,7 +86,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-4x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "python=3.13" pytest numpy exceptiongroup + "python=3.14" pytest numpy exceptiongroup - name: Test in browser-main @@ -96,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/python3.13/site-packages/pyjs \ + --mount $(pwd)/module/pyjs:/lib/python3.14/site-packages/pyjs \ --script main.py \ --work-dir /tests \ --pyjs-dir $(pwd)/build \ @@ -112,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/python3.13/site-packages/pyjs \ + --mount $(pwd)/module/pyjs:/lib/python3.14/site-packages/pyjs \ --script main.py \ --work-dir /tests \ --pyjs-dir $(pwd)/build \ @@ -127,7 +127,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-4x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "python=3.13" pytest exceptiongroup + "python=3.14" pytest exceptiongroup - name: Test in browser-main-no-numpy run: | @@ -138,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/python3.13/site-packages/pyjs \ + --mount $(pwd)/module/pyjs:/lib/python3.14/site-packages/pyjs \ --script main.py \ --work-dir /tests \ --pyjs-dir $(pwd)/build \ diff --git a/environment-dev.yml b/environment-dev.yml index ef42e07..5ea2f07 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -1,7 +1,7 @@ name: pyjs-wasm channels: - conda-forge - - https://repo.prefix.dev/emscripten-forge-4x + - https://repo.prefix.dev/emscripte-forge-bot/emscripten-forge-6x dependencies: - cmake @@ -28,7 +28,7 @@ dependencies: - notebook >=7,<8 # to include the extension to switch between JupyterLab and Notebook # pyjs_code_runner dev deps - hatchling - - emscripten_emscripten-wasm32 == 4.0.9 + - emscripten_emscripten-wasm32 == 6.0.8 - pip: - JLDracula - pyjs_code_runner >= 3.0 From 420822e5a456a4a087a1485c8521005adf5b39d3 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 2 Sep 2026 16:15:36 +0200 Subject: [PATCH 02/18] 6x --- .github/workflows/main.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a978eae..64a515d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,15 +44,15 @@ jobs: micromamba create -n pyjs-build-wasm \ --platform=emscripten-wasm32 \ - -c https://repo.prefix.dev/emscripten-forge-4x \ + -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "python=3.14" \ - "pybind11<3" \ - nlohmann_json pybind11_json numpy \ - pytest bzip2 sqlite zlib zstd libffi \ - exceptiongroup emscripten-abi>=4 \ - "openssl<4" liblzma + "libpython-python=3.14" \ + "pybind11" \ + "nlohmann_json" "pybind11_json" "numpy" \ + pytest \ + exceptiongroup emscripten-abi>=6 + mkdir build @@ -83,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-4x \ + -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "python=3.14" pytest numpy exceptiongroup + "libpython-static=3.14" pytest numpy exceptiongroup - name: Test in browser-main @@ -124,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-4x \ + -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "python=3.14" pytest exceptiongroup + "libpython-static=3.14" pytest exceptiongroup - name: Test in browser-main-no-numpy run: | From def38763f2f2b8ea3dd1075ee2112ea031caece9 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 2 Sep 2026 16:17:09 +0200 Subject: [PATCH 03/18] 6x --- .github/workflows/main.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64a515d..387a8c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,14 +24,17 @@ jobs: - uses: actions/checkout@v2 - name: Install micromamba - uses: mamba-org/setup-micromamba@v1 + uses: mamba-org/setup-micromamba@v3 with: - environment-file: environment-dev.yml - environment-name: pyjs-wasm - condarc: | - channels: - - https://repo.prefix.dev/emscripten-forge-4x - - conda-forge + init-shell: >- + bash + powershell + environment-file: environment-dev.yml + environment-name: pyjs-wasm + condarc: | + channels: + - https://repo.prefix.dev/emscripten-forge-4x + - conda-forge - name: Install Playwright From cfbb5f389d723870f6d6f73e5e818a34580e6a40 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 2 Sep 2026 16:27:07 +0200 Subject: [PATCH 04/18] 6x --- .github/workflows/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 387a8c6..09280bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,15 +26,15 @@ jobs: - name: Install micromamba uses: mamba-org/setup-micromamba@v3 with: - init-shell: >- - bash - powershell - environment-file: environment-dev.yml - environment-name: pyjs-wasm - condarc: | - channels: - - https://repo.prefix.dev/emscripten-forge-4x - - conda-forge + init-shell: >- + bash + powershell + environment-file: environment-dev.yml + environment-name: pyjs-wasm + condarc: | + channels: + - https://repo.prefix.dev/emscripten-forge-4x + - conda-forge - name: Install Playwright From 1826288df04dc1e8d24656b8450d3e2639cb9d5d Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 2 Sep 2026 16:54:34 +0200 Subject: [PATCH 05/18] 6x --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09280bd..e9ccf8f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,12 +28,11 @@ jobs: with: init-shell: >- bash - powershell environment-file: environment-dev.yml environment-name: pyjs-wasm condarc: | channels: - - https://repo.prefix.dev/emscripten-forge-4x + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x - conda-forge From c06dc971661bbba5d378342f0138bf39f77ec1bb Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Thu, 3 Sep 2026 09:31:55 +0200 Subject: [PATCH 06/18] fix --- environment-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment-dev.yml b/environment-dev.yml index 5ea2f07..0c8ab3c 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -1,7 +1,7 @@ name: pyjs-wasm channels: - conda-forge - - https://repo.prefix.dev/emscripte-forge-bot/emscripten-forge-6x + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x dependencies: - cmake From ab6bce4eb4d1a822ba937e0f405dd01326bae622 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Thu, 3 Sep 2026 13:57:51 +0200 Subject: [PATCH 07/18] trigger --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e9ccf8f..920c752 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: true steps: - uses: actions/checkout@v2 @@ -49,7 +49,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "libpython-python=3.14" \ + "libpython-static=3.14" \ "pybind11" \ "nlohmann_json" "pybind11_json" "numpy" \ pytest \ From 1a909ea1f2dba3c8030dc14b75822ee97c94c856 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 4 Sep 2026 08:45:40 +0200 Subject: [PATCH 08/18] wip --- CMakeLists.txt | 8 ++- build_v2.sh | 139 +++++++++++++++++++++++++++++++++++++++++++ environment-dev.yml | 34 ----------- src/js_timestamp.cpp | 2 +- 4 files changed, 145 insertions(+), 38 deletions(-) create mode 100755 build_v2.sh delete mode 100644 environment-dev.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 56aa6b1..664b613 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option(LINK_LIBLZMA "Link liblzma" OFF) # set PY_VERSION to 3.11 if the user has not set it if (NOT DEFINED PY_VERSION) - set(PY_VERSION 3.11) + set(PY_VERSION 3.14) endif() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pycpp_includes) @@ -148,9 +148,9 @@ target_include_directories(pyjs ) SET(PYTHON_UTIL_LIBS - ${CMAKE_INSTALL_PREFIX}/lib/libbz2.a + # ${CMAKE_INSTALL_PREFIX}/lib/libbz2.a ${CMAKE_INSTALL_PREFIX}/lib/libz.a - ${CMAKE_INSTALL_PREFIX}/lib/libsqlite3.a + # ${CMAKE_INSTALL_PREFIX}/lib/libsqlite3.a ${CMAKE_INSTALL_PREFIX}/lib/libffi.a ${CMAKE_INSTALL_PREFIX}/lib/libzstd.a # ssl @@ -159,6 +159,8 @@ SET(PYTHON_UTIL_LIBS ${CMAKE_INSTALL_PREFIX}/lib/libcrypto.a # lzma ${CMAKE_INSTALL_PREFIX}/lib/liblzma.a + + ${CMAKE_INSTALL_PREFIX}/lib/libpython${PY_VERSION}.a ) diff --git a/build_v2.sh b/build_v2.sh new file mode 100755 index 0000000..2d4202d --- /dev/null +++ b/build_v2.sh @@ -0,0 +1,139 @@ +#!/bin/bash +set -e + +# dir of this script +THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +BUILD_PREFIX_DIR=$THIS_DIR/build_prefix +WASM_PREFIX_DIR=$THIS_DIR/debug_prefix +WASM_DEPLOY_PREFIX_DIR=$THIS_DIR/deploy_prefix +EMSDK_DIR=$THIS_DIR/emsdk_install +EMSDK_ABI_VERSION=">=4" +DEPLOYMENT_DIR=$THIS_DIR/deploy + +mkdir -p $DEPLOYMENT_DIR + +MM=$MAMBA_EXE + + + +if false; then + rm -rf $BUILD_PREFIX_DIR + echo "Creating wasm env at $BUILD_PREFIX_DIR" + $MM create -p $BUILD_PREFIX_DIR \ + -f $THIS_DIR/environment-wasm-build.yml \ + --yes + exit 0 +fi + +if false; then + rm -rf $WASM_PREFIX_DIR + echo "Creating wasm env at $WASM_PREFIX_DIR" + $MM create -p $WASM_PREFIX_DIR \ + --platform=emscripten-wasm32 \ + -f $THIS_DIR/environment-wasm.yml \ + --yes + +fi + +export PY_VER=3.14 + +if true; then + echo "Building pyjs" + + rm -rf build + mkdir -p build + cd build + + export PREFIX=$WASM_PREFIX_DIR + export CMAKE_PREFIX_PATH=$PREFIX + export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX + emcmake cmake \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DBUILD_RUNTIME_BROWSER=ON \ + -DBUILD_RUNTIME_NODE=OFF \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DLINK_LIBLZMA=ON \ + -DPYTHON_SITE_PACKAGES=$PREFIX/lib/python${PY_VER}/site-packages \ + -DPython_INCLUDE_DIRS=$PREFIX/include/python${PY_VER} \ + -DPython_LIBRARY=$PREFIX/lib/libpython${PY_VER}.a \ + -DPython_LIBRARIES=$PREFIX/lib/libpython${PY_VER}.a \ + -DPython_Interpreter_FOUND=TRUE \ + -DPython_EXECUTABLE=$BUILD_PREFIX/bin/python${PY_VER} \ + -DPYTHON_MODULE_EXTENSION=.so \ + -DPYTHON_MODULE_DEBUG_POSTFIX="" \ + -DPYTHON_MODULE_EXT_SUFFIX=.so \ + -DPython_FOUND=TRUE \ + .. + + emmake make -j8 + emmake make install +fi + + +DEPLOYMENT_DIR=$THIS_DIR/deploy +mkdir -p $DEPLOYMENT_DIR + +# pack env with empack +if false; then + + cd $THIS_DIR + + + echo "Packing wasm env" + rm -rf $DEPLOYMENT_DIR/pyjs-wasm-env.tar.zst + + + empack pack env \ + --env-prefix $WASM_DEPLOY_PREFIX_DIR \ + --relocate-prefix "/" \ + --no-use-cache \ + --outdir $DEPLOYMENT_DIR + + echo "pack pyjs module" + empack pack dir \ + --host-dir $THIS_DIR/module/pyjs \ + --mount-dir /lib/python3.13/site-packages/pyjs \ + --outname "pyjsmod.tar.gz" \ + --outdir $DEPLOYMENT_DIR + + empack pack append \ + --env-meta $DEPLOYMENT_DIR/empack_env_meta.json \ + --tarfile $DEPLOYMENT_DIR/pyjsmod.tar.gz + +fi + +# copy pyjs binary to deployment dir +cp $THIS_DIR/build/pyjs_runtime_browser.js $DEPLOYMENT_DIR/pyjs_runtime_browser.js +cp $THIS_DIR/build/pyjs_runtime_browser.wasm $DEPLOYMENT_DIR/pyjs_runtime_browser.wasm +# cp $THIS_DIR/index.html $DEPLOYMENT_DIR/index.html + +if false; then + mkdir -p $THIS_DIR/build/host_work_dir + cd $THIS_DIR + BUILD_DIR=$THIS_DIR/build + + # run in env with does not contain numpy + pyjs_code_runner run script \ + browser-main \ + --conda-env $WASM_DEPLOY_PREFIX_DIR \ + --mount $THIS_DIR/tests:/tests \ + --mount $THIS_DIR/module/pyjs:/lib/python3.13/site-packages/pyjs \ + --script main.py \ + --work-dir /tests \ + --host-work-dir $BUILD_DIR/host_work_dir \ + --headless \ + --no-cache \ + --slow-mo 0 \ + --async-main \ + --pyjs-dir $BUILD_DIR \ + +fi + + + +# rm -rf deploy +# mkdir -p deploy +# cd deploy + +# jupyter lite build --XeusAddon.prefix=$WASM_PREFIX_DIR \ No newline at end of file diff --git a/environment-dev.yml b/environment-dev.yml deleted file mode 100644 index 0c8ab3c..0000000 --- a/environment-dev.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: pyjs-wasm -channels: - - conda-forge - - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x - -dependencies: - - cmake - - pip - - python - - yarn - - click - - microsoft::playwright <= 1.50 - - ninja - - nodejs - - pyjs_code_runner >= 2.0.1 - - exceptiongroup - # documentation - - jupytext - - mkdocs - - mkdocstrings - - mkdocstrings-python - - mkdocs-material - - 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 == 6.0.8 - - pip: - - JLDracula - - pyjs_code_runner >= 3.0 diff --git a/src/js_timestamp.cpp b/src/js_timestamp.cpp index 6c1742d..b30456f 100644 --- a/src/js_timestamp.cpp +++ b/src/js_timestamp.cpp @@ -1 +1 @@ -#define PYJS_JS_UTC_TIMESTAMP "2025-10-07 09:33:27.627626" \ No newline at end of file +#define PYJS_JS_UTC_TIMESTAMP "2026-09-03 14:23:48.492790" \ No newline at end of file From 9311d50476e3dec91c9c9ee3df9a5087f6828134 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 4 Sep 2026 08:48:12 +0200 Subject: [PATCH 09/18] wip --- environment-wasm-build.yml | 34 ++++++++++++++++++++++++++++++++++ environment-wasm.yml | 11 +++++++++++ 2 files changed, 45 insertions(+) create mode 100644 environment-wasm-build.yml create mode 100644 environment-wasm.yml diff --git a/environment-wasm-build.yml b/environment-wasm-build.yml new file mode 100644 index 0000000..74050c5 --- /dev/null +++ b/environment-wasm-build.yml @@ -0,0 +1,34 @@ +name: pyjs-wasm-build +channels: + - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + +dependencies: + - cmake + - pip + - python + - yarn + - click + - ninja + - nodejs + - emscripten_emscripten-wasm32 == 6.0.8 + # - microsoft::playwright <= 1.50 + # - pyjs_code_runner >= 2.0.1 + # - exceptiongroup + # # documentation + # - jupytext + # - mkdocs + # - mkdocstrings + # - mkdocstrings-python + # - mkdocs-material + # - 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 + # - pip: + # - JLDracula + # - pyjs_code_runner >= 3.0 diff --git a/environment-wasm.yml b/environment-wasm.yml new file mode 100644 index 0000000..a2b5885 --- /dev/null +++ b/environment-wasm.yml @@ -0,0 +1,11 @@ +name: pyjs-wasm-run +channels: + - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + +dependencies: + - python-dev + - pybind11 + - emscripten-abi==6.0.8 + - numpy + - zlib-static \ No newline at end of file From c3ee07b5eefcd1da224615bd9fad235815df4812 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 13:41:58 +0200 Subject: [PATCH 10/18] 6x --- .clang-format | 52 ------------ CMakeLists.txt | 86 +++++++++----------- build_utils/merge_js.py | 6 +- build_v2.sh | 127 +++++++++++++++++++----------- environment-wasm-build-wasm32.yml | 36 +++++++++ environment-wasm-build-wasm64.yml | 32 ++++++++ environment-wasm-build.yml | 34 -------- environment-wasm-deploy.yml | 10 +++ environment-wasm.yml | 8 +- src/export_js_proxy.cpp | 8 +- src/js_timestamp.cpp | 2 +- tests/main.py | 21 ++--- 12 files changed, 221 insertions(+), 201 deletions(-) delete mode 100644 .clang-format create mode 100644 environment-wasm-build-wasm32.yml create mode 100644 environment-wasm-build-wasm64.yml delete mode 100644 environment-wasm-build.yml create mode 100644 environment-wasm-deploy.yml diff --git a/.clang-format b/.clang-format deleted file mode 100644 index cd67ef0..0000000 --- a/.clang-format +++ /dev/null @@ -1,52 +0,0 @@ -BasedOnStyle: Mozilla -AccessModifierOffset: '-4' -AlignAfterOpenBracket: Align -AlignEscapedNewlinesLeft: 'false' -AllowAllParametersOfDeclarationOnNextLine: 'true' -AllowShortBlocksOnASingleLine: 'false' -AllowShortCaseLabelsOnASingleLine: 'false' -AllowShortFunctionsOnASingleLine: 'false' -AllowShortIfStatementsOnASingleLine: 'false' -AllowShortLoopsOnASingleLine: 'false' -AlwaysBreakTemplateDeclarations: 'true' -SpaceAfterTemplateKeyword: 'true' -BreakBeforeBinaryOperators: All -BreakBeforeBraces: Allman -BreakBeforeTernaryOperators: 'true' -BreakConstructorInitializersBeforeComma: 'true' -BreakStringLiterals: 'false' -ColumnLimit: '100' -ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' -ConstructorInitializerIndentWidth: '4' -ContinuationIndentWidth: '4' -Cpp11BracedListStyle: 'false' -DerivePointerAlignment: 'false' -DisableFormat: 'false' -ExperimentalAutoDetectBinPacking: 'true' -IndentCaseLabels: 'true' -IndentWidth: '4' -IndentWrappedFunctionNames: 'false' -JavaScriptQuotes: Single -KeepEmptyLinesAtTheStartOfBlocks: 'false' -Language: Cpp -MaxEmptyLinesToKeep: '2' -NamespaceIndentation: All -ObjCBlockIndentWidth: '4' -ObjCSpaceAfterProperty: 'false' -ObjCSpaceBeforeProtocolList: 'false' -PointerAlignment: Left -ReflowComments: 'true' -SortIncludes: 'false' -SpaceAfterCStyleCast: 'true' -SpaceBeforeAssignmentOperators: 'true' -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: 'false' -SpacesBeforeTrailingComments: '2' -SpacesInAngles: 'false' -SpacesInCStyleCastParentheses: 'false' -SpacesInContainerLiterals: 'false' -SpacesInParentheses: 'false' -SpacesInSquareBrackets: 'false' -Standard: c++17 -TabWidth: '4' -UseTab: Never diff --git a/CMakeLists.txt b/CMakeLists.txt index 664b613..161d017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,18 @@ -cmake_minimum_required(VERSION 3.9) - +cmake_minimum_required(VERSION 4.0) project(pyjs VERSION 4.0.6 DESCRIPTION "pyjs") -option(BUILD_RUNTIME_BROWSER "Build runtime" ON) -option(WITH_NODE_TESTS "With node tests" OFF) -option(LINK_LIBEXPAT "Link libexpat" OFF) -option(LINK_LIBMPDEC "Link libmpdec" OFF) -option(LINK_LIBLZMA "Link liblzma" OFF) +# cmake module directory +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + + +option(WASM64 "Enable WebAssembly 64-bit support" OFF) + + -# set PY_VERSION to 3.11 if the user has not set it if (NOT DEFINED PY_VERSION) - set(PY_VERSION 3.14) + # raise an error if the user has not set PY_VERSION + message(FATAL_ERROR "PY_VERSION is not set. Please set it to the desired Python version (e.g., 3.14) before running CMake.") endif() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pycpp_includes) @@ -19,7 +20,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pycpp_includes) ########################################################## # generate prejs and postjs ########################################################## -set(PREJS_FILES +set(PREJS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pyjs/pre_js/constants.js ${CMAKE_CURRENT_SOURCE_DIR}/include/pyjs/pre_js/get_type_string.js ${CMAKE_CURRENT_SOURCE_DIR}/include/pyjs/pre_js/wrap_result.js @@ -43,14 +44,12 @@ set(POSTJS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pyjs/post_js/fixes.js ) - add_custom_target(merge_pyjs ALL DEPENDS "pyjs_pre.js" "pyjs_post.js" ) - add_custom_command(OUTPUT "pyjs_pre.js" COMMAND $ENV{CONDA_PREFIX}/bin/python ${CMAKE_SOURCE_DIR}/build_utils/merge_js.py @@ -68,7 +67,6 @@ add_custom_command(OUTPUT "pyjs_post.js" ${CMAKE_CURRENT_SOURCE_DIR}/src/js_timestamp.cpp DEPENDS ${POSTJS_FILES}) - ########################################################## # headers to install ########################################################## @@ -85,19 +83,10 @@ set(PYJS_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/pyjs_post.js ) - - set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(pybind11_REQUIRED_VERSION 2.6.1) - -if (NOT TARGET pybind11::headers) - find_package(pybind11 ${pybind11_REQUIRED_VERSION} REQUIRED) -endif () - - add_library(pyjs STATIC src/export_js_module.cpp src/export_js_proxy.cpp @@ -108,10 +97,12 @@ add_library(pyjs STATIC src/inflate.cpp src/untar.cpp src/install_conda_file.cpp - ${PYCPPSOURCES} ) +if(WASM64) + target_compile_options(pyjs PUBLIC -m64) + target_link_options(pyjs PUBLIC -m64) +endif() -target_link_libraries(pyjs PRIVATE ${PYTHON_UTIL_LIBS} pybind11::embed) target_compile_options(pyjs PUBLIC --std=c++17 @@ -124,20 +115,15 @@ target_link_options(pyjs PUBLIC -Wno-unused-command-line-argument 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']" ) - set_target_properties(pyjs PROPERTIES PUBLIC_HEADER "${PYJS_HEADERS}" - # DEPENDS "pyjs_pre.js" "pyjs_post.js" ) add_dependencies(pyjs merge_pyjs) -target_link_libraries(pyjs PRIVATE pybind11::pybind11) +target_link_libraries(pyjs PRIVATE ) target_compile_options(pyjs PRIVATE -fPIC) @@ -147,36 +133,34 @@ target_include_directories(pyjs $ ) -SET(PYTHON_UTIL_LIBS - # ${CMAKE_INSTALL_PREFIX}/lib/libbz2.a +SET(PYTHON_LIBRARIES + ${CMAKE_INSTALL_PREFIX}/lib/libbz2.a ${CMAKE_INSTALL_PREFIX}/lib/libz.a - # ${CMAKE_INSTALL_PREFIX}/lib/libsqlite3.a + ${CMAKE_INSTALL_PREFIX}/lib/libsqlite3.a ${CMAKE_INSTALL_PREFIX}/lib/libffi.a ${CMAKE_INSTALL_PREFIX}/lib/libzstd.a - # ssl ${CMAKE_INSTALL_PREFIX}/lib/libssl.a - # crypto ${CMAKE_INSTALL_PREFIX}/lib/libcrypto.a - # lzma ${CMAKE_INSTALL_PREFIX}/lib/liblzma.a - - ${CMAKE_INSTALL_PREFIX}/lib/libpython${PY_VERSION}.a + ${CMAKE_INSTALL_PREFIX}/lib/libpython${PY_VERSION}.a + ${CMAKE_INSTALL_PREFIX}/lib/libexpat.a + ${CMAKE_INSTALL_PREFIX}/lib/libmpdec.a + ${CMAKE_INSTALL_PREFIX}/lib/libHacl_Hash_BLAKE2.a + ${CMAKE_INSTALL_PREFIX}/lib/libHacl_Hash_MD5.a + ${CMAKE_INSTALL_PREFIX}/lib/libHacl_Hash_SHA1.a + ${CMAKE_INSTALL_PREFIX}/lib/libHacl_Hash_SHA2.a + ${CMAKE_INSTALL_PREFIX}/lib/libHacl_Hash_SHA3.a ) -if (LINK_LIBEXPAT) - SET(PYTHON_UTIL_LIBS ${PYTHON_UTIL_LIBS} ${CMAKE_INSTALL_PREFIX}/lib/libexpat.a) -endif() - -if (LINK_LIBMPDEC) - SET(PYTHON_UTIL_LIBS ${PYTHON_UTIL_LIBS} ${CMAKE_INSTALL_PREFIX}/lib/libmpdec.a) -endif() - set_target_properties(pyjs PROPERTIES CXX_STANDARD 17 ) +find_package(pybind11 CONFIG) + + add_executable(pyjs_runtime_browser src/runtime.cpp ) SET(ENVIRONMENT "web,worker") @@ -195,7 +179,11 @@ set_target_properties(pyjs_runtime_browser ) target_compile_definitions(pyjs_runtime_browser PUBLIC -DPYJS_WEB) target_compile_options(pyjs_runtime_browser PRIVATE -fPIC) -target_link_libraries(pyjs_runtime_browser PRIVATE pyjs pybind11::embed ${PYTHON_UTIL_LIBS}) + +# include the dir where pybind11 is installed, so that we can find the pybind11Config.cmake file +include_directories(${pybind11_INCLUDE_DIRS}) + +target_link_libraries(pyjs_runtime_browser PRIVATE ${PYTHON_LIBRARIES} pyjs) @@ -209,12 +197,10 @@ target_compile_options(pyjs_runtime_browser PUBLIC "SHELL: -s EXPORT_EXCEPTION_HANDLING_HELPERS" PUBLIC "SHELL: -s FORCE_FILESYSTEM" 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 + PUBLIC "SHELL: -sJSPI" PUBLIC -Wno-unused-command-line-argument PUBLIC "SHELL: -s MODULARIZE=1" PUBLIC "SHELL: -s EXPORT_NAME=\"createModule\"" diff --git a/build_utils/merge_js.py b/build_utils/merge_js.py index 70581c8..64c5c9b 100644 --- a/build_utils/merge_js.py +++ b/build_utils/merge_js.py @@ -18,9 +18,9 @@ def merge(*filenames): outfile.write(line) outfile.write("\n") - with open(filename_timestamp, "w") as outfile: - timestamp = str(datetime.datetime.utcnow()) - outfile.write(f'#define PYJS_JS_UTC_TIMESTAMP "{timestamp}"') + # with open(filename_timestamp, "w") as outfile: + # timestamp = str(datetime.datetime.utcnow()) + # outfile.write(f'#define PYJS_JS_UTC_TIMESTAMP "{timestamp}"') if __name__ == "__main__": diff --git a/build_v2.sh b/build_v2.sh index 2d4202d..4cb58fc 100755 --- a/build_v2.sh +++ b/build_v2.sh @@ -1,59 +1,89 @@ #!/bin/bash set -e -# dir of this script + +# wasm bitness is first argument, if not passed, throw an error +WASM_BITNESS=$1 +if [ -z "$WASM_BITNESS" ]; then + echo "Error: WASM bitness not specified." + exit 1 +fi + +WASM_NAME=wasm$WASM_BITNESS THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -BUILD_PREFIX_DIR=$THIS_DIR/build_prefix -WASM_PREFIX_DIR=$THIS_DIR/debug_prefix -WASM_DEPLOY_PREFIX_DIR=$THIS_DIR/deploy_prefix -EMSDK_DIR=$THIS_DIR/emsdk_install -EMSDK_ABI_VERSION=">=4" +BUILD_PREFIX_DIR=$THIS_DIR/build_prefix_$WASM_NAME +WASM_PREFIX_DIR=$THIS_DIR/wasm_prefix_$WASM_NAME +WASM_DEPLOY_PREFIX_DIR=$THIS_DIR/wasm_deploy_prefix_$WASM_NAME DEPLOYMENT_DIR=$THIS_DIR/deploy - +BUILD_DIR=$THIS_DIR/build-$WASM_NAME mkdir -p $DEPLOYMENT_DIR MM=$MAMBA_EXE +RAT=rattker +unset EMCC_FLAGS -if false; then +# does build env exist? +if [ ! -d "$BUILD_PREFIX_DIR" ]; then rm -rf $BUILD_PREFIX_DIR echo "Creating wasm env at $BUILD_PREFIX_DIR" $MM create -p $BUILD_PREFIX_DIR \ - -f $THIS_DIR/environment-wasm-build.yml \ + -f $THIS_DIR/environment-wasm-build-$WASM_NAME.yml \ --yes exit 0 fi -if false; then +if [ ! -d "$WASM_PREFIX_DIR" ]; then rm -rf $WASM_PREFIX_DIR echo "Creating wasm env at $WASM_PREFIX_DIR" $MM create -p $WASM_PREFIX_DIR \ - --platform=emscripten-wasm32 \ + --platform=emscripten-$WASM_NAME \ -f $THIS_DIR/environment-wasm.yml \ --yes - +fi + +if [ ! -d "$WASM_DEPLOY_PREFIX_DIR" ]; then + echo "Creating wasm env at $WASM_DEPLOY_PREFIX_DIR" + $MM create -p $WASM_DEPLOY_PREFIX_DIR \ + --platform=emscripten-$WASM_NAME \ + -f $THIS_DIR/environment-wasm-deploy.yml \ + --yes fi export PY_VER=3.14 + +# clear CC and CXX to avoid using host compiler +unset LDFLAGS +unset LDFLAGS_LD + + +# set -m64 flag for wasm64 +if [ "$WASM_BITNESS" == "64" ]; then + echo "Setting EMCC_FLAGS for wasm64" + export EMCC_FLAGS="$EMCC_FLAGS -m64" +fi + +export PREFIX="${WASM_PREFIX_DIR}" + if true; then echo "Building pyjs" - rm -rf build - mkdir -p build - cd build + # rm -rf build + mkdir -p $BUILD_DIR + cd $BUILD_DIR export PREFIX=$WASM_PREFIX_DIR export CMAKE_PREFIX_PATH=$PREFIX export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX emcmake cmake \ - -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ -DBUILD_RUNTIME_BROWSER=ON \ -DBUILD_RUNTIME_NODE=OFF \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DLINK_LIBLZMA=ON \ + -DPY_VERSION=$PY_VER \ -DPYTHON_SITE_PACKAGES=$PREFIX/lib/python${PY_VER}/site-packages \ -DPython_INCLUDE_DIRS=$PREFIX/include/python${PY_VER} \ -DPython_LIBRARY=$PREFIX/lib/libpython${PY_VER}.a \ @@ -64,6 +94,7 @@ if true; then -DPYTHON_MODULE_DEBUG_POSTFIX="" \ -DPYTHON_MODULE_EXT_SUFFIX=.so \ -DPython_FOUND=TRUE \ + -DWASM64=TRUE \ .. emmake make -j8 @@ -74,51 +105,51 @@ fi DEPLOYMENT_DIR=$THIS_DIR/deploy mkdir -p $DEPLOYMENT_DIR -# pack env with empack -if false; then +# # pack env with empack +# if true; then - cd $THIS_DIR +# cd $THIS_DIR - echo "Packing wasm env" - rm -rf $DEPLOYMENT_DIR/pyjs-wasm-env.tar.zst +# echo "Packing wasm env" +# rm -rf $DEPLOYMENT_DIR/pyjs-wasm-env.tar.zst - empack pack env \ - --env-prefix $WASM_DEPLOY_PREFIX_DIR \ - --relocate-prefix "/" \ - --no-use-cache \ - --outdir $DEPLOYMENT_DIR - - echo "pack pyjs module" - empack pack dir \ - --host-dir $THIS_DIR/module/pyjs \ - --mount-dir /lib/python3.13/site-packages/pyjs \ - --outname "pyjsmod.tar.gz" \ - --outdir $DEPLOYMENT_DIR - - empack pack append \ - --env-meta $DEPLOYMENT_DIR/empack_env_meta.json \ - --tarfile $DEPLOYMENT_DIR/pyjsmod.tar.gz +# empack pack env \ +# --env-prefix $WASM_PREFIX_DIR \ +# --relocate-prefix "/" \ +# --no-use-cache \ +# --outdir $DEPLOYMENT_DIR + +# echo "pack pyjs module" +# empack pack dir \ +# --host-dir $THIS_DIR/module/pyjs \ +# --mount-dir /lib/python3.14/site-packages/pyjs \ +# --outname "pyjsmod.tar.gz" \ +# --outdir $DEPLOYMENT_DIR + +# empack pack append \ +# --env-meta $DEPLOYMENT_DIR/empack_env_meta.json \ +# --tarfile $DEPLOYMENT_DIR/pyjsmod.tar.gz + +# fi + +# # copy pyjs binary to deployment dir +# cp $THIS_DIR/build/pyjs_runtime_browser.js $DEPLOYMENT_DIR/pyjs_runtime_browser.js +# cp $THIS_DIR/build/pyjs_runtime_browser.wasm $DEPLOYMENT_DIR/pyjs_runtime_browser.wasm +# # cp $THIS_DIR/index.html $DEPLOYMENT_DIR/index.html -fi - -# copy pyjs binary to deployment dir -cp $THIS_DIR/build/pyjs_runtime_browser.js $DEPLOYMENT_DIR/pyjs_runtime_browser.js -cp $THIS_DIR/build/pyjs_runtime_browser.wasm $DEPLOYMENT_DIR/pyjs_runtime_browser.wasm -# cp $THIS_DIR/index.html $DEPLOYMENT_DIR/index.html - -if false; then - mkdir -p $THIS_DIR/build/host_work_dir +if true; then + mkdir -p $BUILD_DIR/host_work_dir cd $THIS_DIR - BUILD_DIR=$THIS_DIR/build + # run in env with does not contain numpy pyjs_code_runner run script \ browser-main \ --conda-env $WASM_DEPLOY_PREFIX_DIR \ --mount $THIS_DIR/tests:/tests \ - --mount $THIS_DIR/module/pyjs:/lib/python3.13/site-packages/pyjs \ + --mount $THIS_DIR/module/pyjs:/lib/python3.14/site-packages/pyjs \ --script main.py \ --work-dir /tests \ --host-work-dir $BUILD_DIR/host_work_dir \ diff --git a/environment-wasm-build-wasm32.yml b/environment-wasm-build-wasm32.yml new file mode 100644 index 0000000..49923b8 --- /dev/null +++ b/environment-wasm-build-wasm32.yml @@ -0,0 +1,36 @@ +name: pyjs-wasm-build +channels: + - microsoft + - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + + +dependencies: + - cmake + - pip + - python + - yarn + - click + - ninja + - nodejs + - emscripten_emscripten-wasm32 == 6.0.8 + - microsoft::playwright + - pyjs_code_runner >= 2.0.1 + - exceptiongroup + # documentation + - jupytext + - mkdocs + - mkdocstrings + - mkdocstrings-python + - mkdocs-material + - 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 + - pip: + - JLDracula + - pyjs_code_runner >= 3.0 diff --git a/environment-wasm-build-wasm64.yml b/environment-wasm-build-wasm64.yml new file mode 100644 index 0000000..4f157ad --- /dev/null +++ b/environment-wasm-build-wasm64.yml @@ -0,0 +1,32 @@ +name: pyjs-wasm-build +channels: + - microsoft + - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + +dependencies: + - cmake + - pip + - python + - yarn + - click + - ninja + - nodejs + - emscripten_emscripten-wasm64 == 6.0.8 + - microsoft::playwright + - pyjs_code_runner + - exceptiongroup + # documentation + - jupytext + - mkdocs + - mkdocstrings + - mkdocstrings-python + - mkdocs-material + - 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 diff --git a/environment-wasm-build.yml b/environment-wasm-build.yml deleted file mode 100644 index 74050c5..0000000 --- a/environment-wasm-build.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: pyjs-wasm-build -channels: - - conda-forge - - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x - -dependencies: - - cmake - - pip - - python - - yarn - - click - - ninja - - nodejs - - emscripten_emscripten-wasm32 == 6.0.8 - # - microsoft::playwright <= 1.50 - # - pyjs_code_runner >= 2.0.1 - # - exceptiongroup - # # documentation - # - jupytext - # - mkdocs - # - mkdocstrings - # - mkdocstrings-python - # - mkdocs-material - # - 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 - # - pip: - # - JLDracula - # - pyjs_code_runner >= 3.0 diff --git a/environment-wasm-deploy.yml b/environment-wasm-deploy.yml new file mode 100644 index 0000000..3cdd98a --- /dev/null +++ b/environment-wasm-deploy.yml @@ -0,0 +1,10 @@ +name: pyjs-wasm-deploy +channels: + - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + +dependencies: + - python + - emscripten-abi==6.0.8 + - numpy + - pytest \ No newline at end of file diff --git a/environment-wasm.yml b/environment-wasm.yml index a2b5885..b898f82 100644 --- a/environment-wasm.yml +++ b/environment-wasm.yml @@ -1,11 +1,15 @@ name: pyjs-wasm-run channels: + - /Users/thorstenbeier/src/recipes/output - conda-forge - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x dependencies: - - python-dev + - libpython-static + - python - pybind11 - emscripten-abi==6.0.8 - numpy - - zlib-static \ No newline at end of file + - zlib-static + - libsqlite-static + - libbzip2-static \ No newline at end of file diff --git a/src/export_js_proxy.cpp b/src/export_js_proxy.cpp index 76062e3..94e5d95 100644 --- a/src/export_js_proxy.cpp +++ b/src/export_js_proxy.cpp @@ -58,6 +58,11 @@ namespace pyjs } } + em::val val_jspi_await(em::val v) + { + return v.await(); + } + inline py::object getattr(em::val* self, em::val* key) { @@ -212,8 +217,7 @@ namespace pyjs m_internal.def("val_bind", [](em::val* v, em::val arg1) { return v->call("bind", arg1); }); - - + // m_internal.def("val_new",[](em::val v){ // return v.new_(); // }); diff --git a/src/js_timestamp.cpp b/src/js_timestamp.cpp index b30456f..a0e4475 100644 --- a/src/js_timestamp.cpp +++ b/src/js_timestamp.cpp @@ -1 +1 @@ -#define PYJS_JS_UTC_TIMESTAMP "2026-09-03 14:23:48.492790" \ No newline at end of file +#define PYJS_JS_UTC_TIMESTAMP "2026-09-07 08:23:38.609625" \ No newline at end of file diff --git a/tests/main.py b/tests/main.py index 8cdf5fe..37da2d3 100644 --- a/tests/main.py +++ b/tests/main.py @@ -52,28 +52,31 @@ async def main(): if run_sync_pytest_tests: import pyjs - import pytest - import os + import pytest dir_path = os.path.dirname(os.path.realpath(__file__)) os.chdir(dir_path) - # import pytest_asyncio - - # start the tests os.environ["NO_COLOR"] = "1" specific_test = None - args = [] - args = ["-s", f"{dir_path}/tests"] + + args = [ + "-s", + "-vvv", + "-p", "no:faulthandler", + f"{dir_path}/tests", + ] + if specific_test is not None: args += ["-k", str(specific_test)] - # args += ["-p", "pytest_asyncio"] - retcode = pytest.main(args, plugins=[]) + if retcode != pytest.ExitCode.OK: raise RuntimeError(f"pytest failed with return code: {retcode}") + + return 0 From 502f5cfd12225e8f796fcb1a78227cc07040e36d Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 14:19:22 +0200 Subject: [PATCH 11/18] ci --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 920c752..31bbb2d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,12 +28,13 @@ jobs: with: init-shell: >- bash - environment-file: environment-dev.yml + environment-file: environment-wasm-build-wasm32.yml environment-name: pyjs-wasm condarc: | channels: - - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + - microsoft - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x - name: Install Playwright @@ -49,7 +50,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "libpython-static=3.14" \ + "python-dev=3.14" \ "pybind11" \ "nlohmann_json" "pybind11_json" "numpy" \ pytest \ @@ -88,7 +89,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "libpython-static=3.14" pytest numpy exceptiongroup + "python=3.14" pytest numpy exceptiongroup - name: Test in browser-main @@ -129,7 +130,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.mamba.pm/conda-forge \ --yes \ - "libpython-static=3.14" pytest exceptiongroup + "python=3.14" pytest exceptiongroup - name: Test in browser-main-no-numpy run: | From 5504ae8cb5712efb120acb720ccb5468d674ffa5 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 14:21:19 +0200 Subject: [PATCH 12/18] ci --- .github/workflows/main.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 31bbb2d..c2e277a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,12 +68,24 @@ jobs: # build pyjs emcmake cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ - -DBUILD_RUNTIME_BROWSER=ON \ - -DBUILD_RUNTIME_NODE=OFF \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - .. + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DBUILD_RUNTIME_BROWSER=ON \ + -DBUILD_RUNTIME_NODE=OFF \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DLINK_LIBLZMA=ON \ + -DPY_VERSION=$PY_VER \ + -DPYTHON_SITE_PACKAGES=$PREFIX/lib/python${PY_VER}/site-packages \ + -DPython_INCLUDE_DIRS=$PREFIX/include/python${PY_VER} \ + -DPython_LIBRARY=$PREFIX/lib/libpython${PY_VER}.a \ + -DPython_LIBRARIES=$PREFIX/lib/libpython${PY_VER}.a \ + -DPython_Interpreter_FOUND=TRUE \ + -DPython_EXECUTABLE=$BUILD_PREFIX/bin/python${PY_VER} \ + -DPYTHON_MODULE_EXTENSION=.so \ + -DPYTHON_MODULE_DEBUG_POSTFIX="" \ + -DPYTHON_MODULE_EXT_SUFFIX=.so \ + -DPython_FOUND=TRUE \ + -DWASM64=FALSE \ + .. make -j2 From 4f84da14c86edfcc60b6824b057a6dcaa293ccd7 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 14:28:03 +0200 Subject: [PATCH 13/18] ci --- .github/workflows/main.yml | 4 ++-- environment-wasm-build-wasm32.yml | 2 +- environment-wasm-build-wasm64.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c2e277a..404bec4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,7 +65,7 @@ jobs: export PREFIX=$MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm export CMAKE_PREFIX_PATH=$PREFIX export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX - + export PY_VER=3.14 # build pyjs emcmake cmake \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ @@ -79,7 +79,7 @@ jobs: -DPython_LIBRARY=$PREFIX/lib/libpython${PY_VER}.a \ -DPython_LIBRARIES=$PREFIX/lib/libpython${PY_VER}.a \ -DPython_Interpreter_FOUND=TRUE \ - -DPython_EXECUTABLE=$BUILD_PREFIX/bin/python${PY_VER} \ + -DPython_EXECUTABLE=$MAMBA_ROOT_PREFIX/envs/pyjs-wasm/bin/python${PY_VER} \ -DPYTHON_MODULE_EXTENSION=.so \ -DPYTHON_MODULE_DEBUG_POSTFIX="" \ -DPYTHON_MODULE_EXT_SUFFIX=.so \ diff --git a/environment-wasm-build-wasm32.yml b/environment-wasm-build-wasm32.yml index 49923b8..8f5a77e 100644 --- a/environment-wasm-build-wasm32.yml +++ b/environment-wasm-build-wasm32.yml @@ -8,7 +8,7 @@ channels: dependencies: - cmake - pip - - python + - python =3.14 - yarn - click - ninja diff --git a/environment-wasm-build-wasm64.yml b/environment-wasm-build-wasm64.yml index 4f157ad..b9b2382 100644 --- a/environment-wasm-build-wasm64.yml +++ b/environment-wasm-build-wasm64.yml @@ -7,7 +7,7 @@ channels: dependencies: - cmake - pip - - python + - python =3.14 - yarn - click - ninja From a1ea9c9b47b34312f7e2ea17970ef0396c547355 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 14:40:03 +0200 Subject: [PATCH 14/18] ci --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 404bec4..821c607 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -99,9 +99,9 @@ jobs: micromamba create -n pyjs-build-wasm-with-numpy \ --platform=emscripten-wasm32 \ -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ - -c https://repo.mamba.pm/conda-forge \ + -c https://repo.prefix.dev/conda-forge \ --yes \ - "python=3.14" pytest numpy exceptiongroup + "python=3.14" "pytest>=9" numpy - name: Test in browser-main @@ -140,7 +140,7 @@ jobs: micromamba create -n pyjs-build-wasm-no-numpy \ --platform=emscripten-wasm32 \ -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ - -c https://repo.mamba.pm/conda-forge \ + -c https://repo.prefix.dev/conda-forge \ --yes \ "python=3.14" pytest exceptiongroup From 4be2d3420227c03ba6f0d9c43feb430b4397c372 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 14:44:53 +0200 Subject: [PATCH 15/18] ci --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 821c607..5545e58 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -142,7 +142,7 @@ jobs: -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ -c https://repo.prefix.dev/conda-forge \ --yes \ - "python=3.14" pytest exceptiongroup + "python=3.14" "pytest>=9" - name: Test in browser-main-no-numpy run: | From 3502d8a8668e034e7b09525591d67ef4d54472a3 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 11 Sep 2026 14:46:29 +0200 Subject: [PATCH 16/18] ci --- .github/workflows/main.yml | 151 ++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5545e58..34a9ead 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ defaults: jobs: - test-browser: + test-browser-wasm32: runs-on: ubuntu-latest @@ -159,4 +159,151 @@ jobs: --pyjs-dir $(pwd)/build \ --headless \ --async-main \ - --no-cache \ No newline at end of file + --no-cache + test-browser-wasm64: + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + + steps: + - uses: actions/checkout@v2 + + - name: Install micromamba + uses: mamba-org/setup-micromamba@v3 + with: + init-shell: >- + bash + environment-file: environment-wasm-build-wasm64.yml + environment-name: pyjs-wasm + condarc: | + channels: + - microsoft + - conda-forge + - https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x + + + - name: Install Playwright + run: | + playwright install + + - name: Build pyjs + run: | + micromamba activate pyjs-wasm + + micromamba create -n pyjs-build-wasm64 \ + --platform=emscripten-wasm64 \ + -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ + -c https://repo.mamba.pm/conda-forge \ + --yes \ + "python-dev=3.14" \ + "pybind11" \ + "nlohmann_json" "pybind11_json" "numpy" \ + pytest \ + exceptiongroup emscripten-abi>=6 + + + + mkdir build + pushd build + + + export PREFIX=$MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm64 + export CMAKE_PREFIX_PATH=$PREFIX + export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX + export PY_VER=3.14 + # build pyjs + emcmake cmake \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DBUILD_RUNTIME_BROWSER=ON \ + -DBUILD_RUNTIME_NODE=OFF \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DLINK_LIBLZMA=ON \ + -DPY_VERSION=$PY_VER \ + -DPYTHON_SITE_PACKAGES=$PREFIX/lib/python${PY_VER}/site-packages \ + -DPython_INCLUDE_DIRS=$PREFIX/include/python${PY_VER} \ + -DPython_LIBRARY=$PREFIX/lib/libpython${PY_VER}.a \ + -DPython_LIBRARIES=$PREFIX/lib/libpython${PY_VER}.a \ + -DPython_Interpreter_FOUND=TRUE \ + -DPython_EXECUTABLE=$MAMBA_ROOT_PREFIX/envs/pyjs-wasm/bin/python${PY_VER} \ + -DPYTHON_MODULE_EXTENSION=.so \ + -DPYTHON_MODULE_DEBUG_POSTFIX="" \ + -DPYTHON_MODULE_EXT_SUFFIX=.so \ + -DPython_FOUND=TRUE \ + -DWASM64=TRUE \ + .. + + make -j2 + + make install + + popd + + - name: setup env with numpy + run: | + micromamba activate pyjs-wasm + micromamba create -n pyjs-build-wasm-with-numpy \ + --platform=emscripten-wasm64 \ + -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ + -c https://repo.prefix.dev/conda-forge \ + --yes \ + "python=3.14" "pytest>=9" numpy + + + - name: Test in browser-main + run: | + micromamba activate pyjs-wasm + pyjs_code_runner run script \ + browser-main \ + --conda-env $MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm-with-numpy \ + --mount $(pwd)/tests:/tests \ + --mount $(pwd)/module/pyjs:/lib/python3.14/site-packages/pyjs \ + --script main.py \ + --work-dir /tests \ + --pyjs-dir $(pwd)/build \ + --headless \ + --async-main + + - name: Test in browser-worker + run: | + micromamba activate pyjs-wasm + + + pyjs_code_runner run script \ + browser-worker \ + --conda-env $MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm-with-numpy \ + --mount $(pwd)/tests:/tests \ + --mount $(pwd)/module/pyjs:/lib/python3.14/site-packages/pyjs \ + --script main.py \ + --work-dir /tests \ + --pyjs-dir $(pwd)/build \ + --headless \ + --async-main + + - name: setup minimal env without numpy + run: | + micromamba activate pyjs-wasm + micromamba create -n pyjs-build-wasm-no-numpy \ + --platform=emscripten-wasm64 \ + -c https://repo.prefix.dev/emscripten-forge-bot/emscripten-forge-6x \ + -c https://repo.prefix.dev/conda-forge \ + --yes \ + "python=3.14" "pytest>=9" + + - name: Test in browser-main-no-numpy + run: | + micromamba activate pyjs-wasm + + + pyjs_code_runner run script \ + browser-main \ + --conda-env $MAMBA_ROOT_PREFIX/envs/pyjs-build-wasm-no-numpy \ + --mount $(pwd)/tests:/tests \ + --mount $(pwd)/module/pyjs:/lib/python3.14/site-packages/pyjs \ + --script main.py \ + --work-dir /tests \ + --pyjs-dir $(pwd)/build \ + --headless \ + --async-main \ + --no-cache \ No newline at end of file From b4b1d889f7d1561c32c77c0cf3e68f5b695d5e51 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Mon, 14 Sep 2026 14:34:06 +0200 Subject: [PATCH 17/18] fix --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 161d017..868a6f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,6 @@ target_compile_options(pyjs_runtime_browser ) target_link_options(pyjs_runtime_browser - PUBLIC "SHELL: -sJSPI" PUBLIC -Wno-unused-command-line-argument PUBLIC "SHELL: -s MODULARIZE=1" PUBLIC "SHELL: -s EXPORT_NAME=\"createModule\"" From 226266fe6f70cfd1e74fb84d336c8a237533d92b Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Mon, 14 Sep 2026 14:41:25 +0200 Subject: [PATCH 18/18] fix --- src/export_js_proxy.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/export_js_proxy.cpp b/src/export_js_proxy.cpp index 94e5d95..2c1c568 100644 --- a/src/export_js_proxy.cpp +++ b/src/export_js_proxy.cpp @@ -58,11 +58,6 @@ namespace pyjs } } - em::val val_jspi_await(em::val v) - { - return v.await(); - } - inline py::object getattr(em::val* self, em::val* key) {