diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index faff507..cd2ba29 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,9 +48,6 @@ jobs: run: | micromamba activate pyjs-wasm - python -m pip install git+https://github.com/emscripten-forge/empack@rootpack --no-deps --ignore-installed - python -m pip install git+https://github.com/DerThorsten/pyjs-code-runner@relocate_env --no-deps --ignore-installed - emsdk activate ${{matrix.emsdk_ver}} source $CONDA_EMSDK_DIR/emsdk_env.sh @@ -59,7 +56,7 @@ jobs: -c https://repo.mamba.pm/emscripten-forge \ -c https://repo.mamba.pm/conda-forge \ --yes \ - python pybind11 nlohmann_json pybind11_json numpy pytest bzip2 sqlite zlib libffi + python pybind11 nlohmann_json pybind11_json numpy "pytest==7.1.1" bzip2 sqlite zlib libffi exceptiongroup mkdir build @@ -94,7 +91,7 @@ jobs: -c https://repo.mamba.pm/emscripten-forge \ -c https://repo.mamba.pm/conda-forge \ --yes \ - python pytest numpy + python "pytest==7.1.1" numpy exceptiongroup - name: Test in browser-main @@ -133,7 +130,7 @@ jobs: -c https://repo.mamba.pm/emscripten-forge \ -c https://repo.mamba.pm/conda-forge \ --yes \ - python pytest + python "pytest==7.1.1" exceptiongroup - name: Test in browser-main-no-numpy run: | diff --git a/environment-dev.yml b/environment-dev.yml index 4c5f69f..a73c37b 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -7,9 +7,10 @@ dependencies: - python=3.10 - yarn - click + - empack >=3.0.1 - emsdk >=3.1.11 - - empack >=1.1.0 - microsoft::playwright - ninja - nodejs >= 18.7.0 - - pyjs_code_runner == 1.1.0 \ No newline at end of file + - pyjs_code_runner >= 2.0.1 + - exceptiongroup \ No newline at end of file diff --git a/include/pyjs/pre_js/init.js b/include/pyjs/pre_js/init.js index 13948c2..96f530e 100644 --- a/include/pyjs/pre_js/init.js +++ b/include/pyjs/pre_js/init.js @@ -176,15 +176,22 @@ _add_resolve_done_callback Module._is_initialized = true -// Module.exec(` -// import sys -// import sysconfig -// side_path = "${side_path}" -// from pathlib import Path -// Path(side_path).mkdir(parents=True, exist_ok=True) -// if True and side_path not in sys.path: -// sys.path.append(side_path) -// `) + // make sure time.sleep is working + Module.exec(` +import time +def _mock_time_sleep(): + def sleep(seconds): + """Delay execution for a given number of seconds. The argument may be + a floating point number for subsecond precision. + """ + start = now = time.time() + while now - start < seconds: + now = time.time() + + time.sleep = sleep +_mock_time_sleep() +del _mock_time_sleep +`) return p diff --git a/tests/tests/test_pyjs.py b/tests/tests/test_pyjs.py index 66b90aa..faa0df9 100644 --- a/tests/tests/test_pyjs.py +++ b/tests/tests/test_pyjs.py @@ -554,3 +554,17 @@ def test_int_container(): js_obj = jsf() py_obj = pyjs.to_py(js_obj) assert py_obj + + + +def test_sleep(): + import time + start = time.time() + time.sleep(2) + end = time.time() + + assert end - start >= 2 + + # probably we can also do more precise tests + # but lets keept it simple for now + assert end - start < 2.1 \ No newline at end of file