Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
fail-fast: true

steps:
- uses: actions/checkout@v2

- name: Install micromamba
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@v3
with:
init-shell: >-
bash
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


Expand All @@ -44,15 +46,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.13" \
"pybind11<3" \
nlohmann_json pybind11_json numpy \
pytest bzip2 sqlite zlib zstd libffi \
exceptiongroup emscripten-abi>=4 \
"openssl<4" liblzma
"libpython-static=3.14" \
"pybind11" \
"nlohmann_json" "pybind11_json" "numpy" \
pytest \
exceptiongroup emscripten-abi>=6



mkdir build
Expand Down Expand Up @@ -83,10 +85,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.13" pytest numpy exceptiongroup
"libpython-static=3.14" pytest numpy exceptiongroup


- name: Test in browser-main
Expand All @@ -96,7 +98,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 \
Expand All @@ -112,7 +114,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 \
Expand All @@ -124,10 +126,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.13" pytest exceptiongroup
"libpython-static=3.14" pytest exceptiongroup

- name: Test in browser-main-no-numpy
run: |
Expand All @@ -138,7 +140,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 \
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
)


Expand Down
139 changes: 139 additions & 0 deletions build_v2.sh
Original file line number Diff line number Diff line change
@@ -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
34 changes: 0 additions & 34 deletions environment-dev.yml

This file was deleted.

34 changes: 34 additions & 0 deletions environment-wasm-build.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions environment-wasm.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/js_timestamp.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PYJS_JS_UTC_TIMESTAMP "2025-10-07 09:33:27.627626"
#define PYJS_JS_UTC_TIMESTAMP "2026-09-03 14:23:48.492790"
Loading