From 75e25e93455d1f6857c3d4bd38f181f8608cc6d4 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Thu, 28 Apr 2022 11:49:54 +0200 Subject: [PATCH 1/3] Remove debug logs --- src/xinterpreter.cpp | 2 - src/xinterpreter_raw.cpp | 94 +++++++++++++++------------------------- 2 files changed, 34 insertions(+), 62 deletions(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 63dcbfd9..934b223e 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include "nlohmann/json.hpp" @@ -41,7 +40,6 @@ namespace py = pybind11; namespace nl = nlohmann; using namespace pybind11::literals; - namespace xpyt { diff --git a/src/xinterpreter_raw.cpp b/src/xinterpreter_raw.cpp index e9f7645c..b3b8417d 100644 --- a/src/xinterpreter_raw.cpp +++ b/src/xinterpreter_raw.cpp @@ -14,8 +14,6 @@ #include #include #include -#include - #include "nlohmann/json.hpp" @@ -49,15 +47,11 @@ namespace xpyt raw_interpreter::raw_interpreter(bool redirect_output_enabled /*=true*/, bool redirect_display_enabled /*=true*/) :m_redirect_display_enabled{ redirect_display_enabled } { - std::cout<<"in ctr\n"; xeus::register_interpreter(this); - std::cout<<"in ctr 2\n"; if (redirect_output_enabled) { - std::cout<<"in ctr 2b\n"; redirect_output(); } - std::cout<<"in ctr 3\n"; } raw_interpreter::~raw_interpreter() @@ -66,68 +60,51 @@ namespace xpyt void raw_interpreter::configure_impl() { - try { - - std::cout<<"Configure IMPL 1\n"; - if (m_release_gil_at_startup) - { - std::cout<<"Configure IMPL 1a\n"; - // The GIL is not held by default by the interpreter, so every time we need to execute Python code we - // will need to acquire the GIL - m_release_gil = gil_scoped_release_ptr(new py::gil_scoped_release()); - } + if (m_release_gil_at_startup) + { + // The GIL is not held by default by the interpreter, so every time we need to execute Python code we + // will need to acquire the GIL + m_release_gil = gil_scoped_release_ptr(new py::gil_scoped_release()); + } - std::cout<<"Configure IMPL 2\n"; - py::gil_scoped_acquire acquire; + py::gil_scoped_acquire acquire; - std::cout<<"Configure IMPL 3\n"; - py::module sys = py::module::import("sys"); - std::cout<<"Configure IMPL 4\n"; - py::module jedi = py::module::import("jedi"); - std::cout<<"Configure IMPL 5\n"; - jedi.attr("api").attr("environment").attr("get_default_environment") = py::cpp_function([jedi]() { + py::module sys = py::module::import("sys"); + py::module jedi = py::module::import("jedi"); + jedi.attr("api").attr("environment").attr("get_default_environment") = py::cpp_function([jedi]() { jedi.attr("api").attr("environment").attr("SameEnvironment")(); - }); - - py::module display_module = get_display_module(true); - m_displayhook = display_module.attr("DisplayHook")(); - - if (m_redirect_display_enabled) - { - sys.attr("displayhook") = m_displayhook; - } - - // Expose display functions to Python - py::globals()["display"] = display_module.attr("display"); - py::globals()["update_display"] = display_module.attr("update_display"); - // Monkey patching "import IPython.core.display" - sys.attr("modules")["IPython.core.display"] = display_module; + }); + py::module display_module = get_display_module(true); + m_displayhook = display_module.attr("DisplayHook")(); - py::module kernel_module = get_kernel_module(true); - // Monkey patching "from ipykernel.comm import Comm" - sys.attr("modules")["ipykernel.comm"] = kernel_module; + if (m_redirect_display_enabled) + { + sys.attr("displayhook") = m_displayhook; + } - // Monkey patching "from IPython import get_ipython" - sys.attr("modules")["IPython.core.getipython"] = kernel_module; + // Expose display functions to Python + py::globals()["display"] = display_module.attr("display"); + py::globals()["update_display"] = display_module.attr("update_display"); + // Monkey patching "import IPython.core.display" + sys.attr("modules")["IPython.core.display"] = display_module; - // Add get_ipython to global namespace - py::globals()["get_ipython"] = kernel_module.attr("get_ipython"); - kernel_module.attr("get_ipython")(); + py::module kernel_module = get_kernel_module(true); + // Monkey patching "from ipykernel.comm import Comm" + sys.attr("modules")["ipykernel.comm"] = kernel_module; - py::globals()["_i"] = ""; - py::globals()["_ii"] = ""; - py::globals()["_iii"] = ""; + // Monkey patching "from IPython import get_ipython" + sys.attr("modules")["IPython.core.getipython"] = kernel_module; - } catch (std::exception &e) { - std::cout<<"ewhat "< Date: Thu, 28 Apr 2022 12:13:02 +0200 Subject: [PATCH 2/3] Advertise needing the latest xeus-python-shell --- README.md | 2 +- environment-dev.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aea7a2bf..cbdfa3b0 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ Long story short: | `xeus-python`| `xeus` | `xtl` | `cppzmq` | `nlohmann_json` | `pybind11` | `pybind11_json` | `pygments` | `debugpy` | `IPython` | `xeus-python-shell` | |--------------|------------------|-----------------|----------|-----------------|----------------|-------------------|-------------------|-----------|-----------|---------------------| -| master | >=2.0.0,<3.0 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<3.10 | >=2.6.1,<3.0 | >=0.2.8,<0.3 | >=2.3.1,<3.0.0 | >=1.1.0 | | >=0.1.5,<0.3.0 | +| master | >=2.0.0,<3.0 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<3.10 | >=2.6.1,<3.0 | >=0.2.8,<0.3 | >=2.3.1,<3.0.0 | >=1.1.0 | | >=0.3.0,<0.4.0 | | 0.13.7 | >=2.0.0,<3.0 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<3.10 | >=2.6.1,<3.0 | >=0.2.8,<0.3 | >=2.3.1,<3.0.0 | >=1.1.0 | | >=0.1.5,<0.3.0 | | 0.13.6 | >=2.0.0,<3.0 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<3.10 | >=2.6.1,<3.0 | >=0.2.8,<0.3 | >=2.3.1,<3.0.0 | >=1.1.0 | | >=0.1.5,<0.3.0 | | 0.13.5 | >=2.0.0,<3.0 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<3.10 | >=2.6.1,<3.0 | >=0.2.8,<0.3 | >=2.3.1,<3.0.0 | >=1.1.0 | | >=0.1.5,<0.2.0 | diff --git a/environment-dev.yml b/environment-dev.yml index 0ca755f0..15366587 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -12,7 +12,7 @@ dependencies: - xtl>=0.7, <0.8 - pybind11>=2.6.1,<3.0 - pybind11_json>=0.2.6,<0.3 - - xeus-python-shell>=0.1.6,<0.3 + - xeus-python-shell>=0.3.0,<0.4 - debugpy # Test dependencies - pytest From 964e8ab6ffe71dbde5eab3855ade1afa7d52aeb1 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Fri, 6 May 2022 15:49:36 +0200 Subject: [PATCH 3/3] Add CI check --- .github/workflows/main.yml | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f20a8585..1f8a2fd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -130,3 +130,67 @@ jobs: run: | micromamba activate xeus-python pytest . -vvv + + test-wasm: + + runs-on: ubuntu + + strategy: + fail-fast: false + matrix: + emsdk_ver: ["3.1.2"] + + steps: + - uses: actions/checkout@v2 + + - name: Get number of CPU cores + uses: SimenB/github-actions-cpu-cores@v1 + + - name: Install mamba + uses: mamba-org/provision-with-micromamba@main + + - name: Create micromamba wasm env + run: | + micromamba create -n xeus-python-wasm \ + --platform=emscripten-32 --yes \ + -c https://repo.mamba.pm/emscripten-forge \ + -c https://repo.mamba.pm/conda-forge \ + pip python ipython pybind11 jedi xtl nlohmann_json pybind11_json numpy xeus xeus-python-shell>=0.3.0 + + - name: Setup emsdk (TODO Install from conda-forge when available) + run: | + git clone https://github.com/emscripten-core/emsdk.git + pushd emsdk + ./emsdk install ${{matrix.emsdk_ver}} + popd + + - name: Install emboa (TODO Install from conda-forge when available) + run: | + micromamba activate xeus-python-wasm + pip install git+https://github.com/emscripten-forge/emboa + + - name: Build and pack xeus-python + run: | + micromamba activate xeus-python-wasm + + pushd emsdk + ./emsdk activate ${{matrix.emsdk_ver}} + source emsdk_env.sh + export FILE_PACKAGER=$(cwd)/upstream/emscripten/tools/file_packager.py + popd + + export CMAKE_PREFIX_PATH=$CONDA_PREFIX + export CMAKE_SYSTEM_PREFIX_PATH=$CONDA_PREFIX + + emcmake cmake \ + -DCMAKE_BUILD_TYPE=Release\ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DCMAKE_PROJECT_INCLUDE=overwriteProp.cmake \ + -DXPYT_EMSCRIPTEN_WASM_BUILD=ON \ + .. + + make -j ${{ steps.cpu-cores.outputs.count }} + + emboa pack python core $CONDA_PREFIX --version=3.10 + + # TODO Add test with node?