Skip to content

Commit

Permalink
Update xeus (#52)
Browse files Browse the repository at this point in the history
* update xeus to xeus 5
  • Loading branch information
DerThorsten authored Jun 3, 2024
1 parent 8dd7519 commit acf7121
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 62 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ jobs:
source $CONDA_EMSDK_DIR/emsdk_env.sh
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
mkdir build
pushd build
Expand Down
51 changes: 27 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")

set(XEUS_LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)


# PRINT THE COMPILER
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")

if(EMSCRIPTEN)
message(STATUS "EMSCRIPTEN")
else()
message(STATUS "NOT EMSCRIPTEN")
endif()



# Versionning
# ===========

Expand Down Expand Up @@ -77,28 +89,19 @@ endif()
# Dependencies
# ============

set(xtl_REQUIRED_VERSION 0.7.0)
set(xeus_REQUIRED_VERSION 3.0.0)
set(xwidgets_REQUIRED_VERSION 0.27.0)
set(xcanvas_REQUIRED_VERSION 0.3.0)
set(xproperty_REQUIRED_VERSION 0.11.0)

set(xeus_REQUIRED_VERSION 5.0.0)
set(xwidgets_REQUIRED_VERSION 0.29.0)
set(xcanvas_REQUIRED_VERSION 0.5.0)
set(xproperty_REQUIRED_VERSION 0.12.0)
set(Lua_REQUIRED_VERSION 5.3.4)

if (NOT TARGET xtl)
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
endif ()
if (NOT TARGET xeus AND NOT TARGET xeus-static)
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
endif ()
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)

if(NOT XEUS_LUA_USE_LUAJIT)
if (NOT TARGET Lua) # not sure about these lines
find_package(Lua ${lua_REQUIRED_VERSION} REQUIRED)
endif ()
find_package(Lua ${lua_REQUIRED_VERSION} REQUIRED)
else()
if (NOT TARGET LuaJIT) # not sure about these lines
find_package(LuaJIT REQUIRED)
endif ()
find_package(LuaJIT REQUIRED)
endif()

# Flags
Expand Down Expand Up @@ -315,7 +318,7 @@ macro(xeus_lua_create_target target_name linkage output_name)
set(XLUA_XCANVAS_TARGET "")
endif()

target_link_libraries(${target_name} PUBLIC ${XEUS_LUA_XEUS_TARGET} xtl
target_link_libraries(${target_name} PUBLIC ${XEUS_LUA_XEUS_TARGET}
${XLUA_XWIDGETS_TARGET}
${XLUA_XPROPERTY_TARGET}
${XLUA_XCANVAS_TARGET}
Expand Down Expand Up @@ -373,12 +376,12 @@ endif()
if(EMSCRIPTEN)
include(WasmBuildOptions)
find_package(xeus-lite REQUIRED)
add_executable(xlua src/main_emscripten_kernel.cpp )
target_link_libraries(xlua PRIVATE xeus-lite)
target_compile_features(xlua PRIVATE cxx_std_17)
xeus_lua_set_kernel_options(xlua)
xeus_wasm_compile_options(xlua)
xeus_wasm_link_options(xlua "web,worker")
add_executable(xlua_wasm src/main_emscripten_kernel.cpp )
target_link_libraries(xlua_wasm PRIVATE xeus-lite)
target_compile_features(xlua_wasm PRIVATE cxx_std_17)
xeus_lua_set_kernel_options(xlua_wasm)
xeus_wasm_compile_options(xlua_wasm)
xeus_wasm_link_options(xlua_wasm "web,worker")
endif()


Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,9 @@ the xeus ecosystem like [xwidgets](https://github.com/jupyter-xeus/xwidgets).
`xeus-lua` depends on

- [xeus](https://github.com/jupyter-xeus/xeus)
- [xtl](https://github.com/xtensor-stack/xtl)
- [xwidgets](https://github.com/jupyter-xeus/xwidgets)
- [lua](https://www.lua.org/)

| `xeus-lua` | `xeus` | `xwidgets` | `xtl` | `cppzmq` | `nlohmann_json` | `lua` |
| ------------- | ------------- | ------------- | ------------ | -------- | --------------- | ------------ |
| master | >=2.4.0,<3 | >=0.26.1 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<4.0 | >=5.2.0 |
| 0.6.2 | >=2.4.0,<3 | >=0.26.1 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<4.0 | >=5.2.0 |

## Contributing

Expand Down
8 changes: 4 additions & 4 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ dependencies:
- cmake
- cxx-compiler
# Host dependencies
- xeus-zmq>=1.3.0, <2.0
- nlohmann_json=3.11.2
- xeus>=5.0,<=6
- xeus-zmq
- nlohmann_json
- cppzmq
- xtl>=0.7
- lua>=5.2.0
- openlibm # [linux]
- xwidgets <0.29
- xwidgets >=0.29
- xcanvas>=0.4.2
# to try it out
- jupyterlab
Expand Down
9 changes: 4 additions & 5 deletions environment-wasm-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ channels:
dependencies:
- lua
- nlohmann_json
- xeus-lite <2.0
- xeus >=3.2.0,<4.0
- xtl >=0.7,<0.8
- xcanvas >=0.4,<5.0
- xwidgets >=0.27.3,<1.0
- xeus-lite >=2.0
- xeus>=5.0,<=6
- xcanvas >=0.5,<5.0
- xwidgets >=0.28.0,<1.0
13 changes: 6 additions & 7 deletions include/xeus-lua/xinterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "xeus_lua_config.hpp"
#include "xeus/xinterpreter.hpp"

#include "xeus/xrequest_context.hpp"

extern "C" {
#ifndef XEUS_LUA_USE_LUAJIT
Expand Down Expand Up @@ -47,12 +47,11 @@ namespace xlua

void configure_impl() override;

nl::json execute_request_impl(int execution_counter,
const std::string& code,
bool silent,
bool store_history,
nl::json user_expressions,
bool allow_stdin) override;
void execute_request_impl(send_reply_callback cb,
int execution_counter,
const std::string& code,
xeus::execute_request_config config,
nl::json user_expressions) override;

nl::json complete_request_impl(const std::string& code, int cursor_pos) override;

Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "xeus/xkernel.hpp"
#include "xeus/xkernel_configuration.hpp"
#include "xeus/xserver.hpp"
#include "xeus-zmq/xserver_shell_main.hpp"

#include "xeus-zmq/xserver_zmq_split.hpp"
#include "xeus-zmq/xzmq_context.hpp"


#include "xeus-lua/xinterpreter.hpp"
Expand Down Expand Up @@ -114,9 +116,7 @@ int main(int argc, char* argv[])



using context_type = xeus::xcontext_impl<zmq::context_t>;
using context_ptr = std::unique_ptr<context_type>;
context_ptr context = context_ptr(new context_type());
std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();

// Instantiating the xeus xinterpreter
using interpreter_ptr = std::unique_ptr<xlua::interpreter>;
Expand Down
1 change: 0 additions & 1 deletion src/xdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace xlua




void setup_display(
sol::state_view & lua,
interpreter & interp
Expand Down
17 changes: 8 additions & 9 deletions src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,14 @@ namespace xlua
{
}

nl::json interpreter::execute_request_impl(int /*execution_count*/,
void interpreter::execute_request_impl(send_reply_callback cb,
int execution_count,
const std::string& code,
bool silent,
bool /*store_history*/,
nl::json /*user_expressions*/,
bool allow_stdin)
xeus::execute_request_config config,
nl::json user_expressions)
{
sol::state_view lua(L);
m_allow_stdin = allow_stdin;
m_allow_stdin = config.allow_stdin;
// reset payload
nl::json kernel_res;

Expand Down Expand Up @@ -220,7 +219,7 @@ namespace xlua
sol::error err = code_result;
sol::call_status status = code_result.status();
const auto error_str = err.what();
if (!silent)
if (!config.silent)
{
publish_execution_error(error_str,error_str,std::vector<std::string>(1,error_str));
}
Expand All @@ -231,7 +230,7 @@ namespace xlua
kernel_res["traceback"] = { error_str };
}
}
return kernel_res;
cb(kernel_res);
}

nl::json interpreter::complete_request_impl(
Expand All @@ -248,7 +247,7 @@ namespace xlua
result["matches"] = matches;
result["cursor_start"] = cursor_start;
result["metadata"] = nl::json::object();
result["cursor_end"] = cursor_pos;
result["cursor_end"] = cursor_pos;

return result;
}
Expand Down
3 changes: 2 additions & 1 deletion src/xwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <vector>
#include <string>
#include <iostream>
#include <optional>

#include "sol/sol.hpp"
#include "xeus/xinterpreter.hpp"
Expand Down Expand Up @@ -158,7 +159,7 @@ namespace xlua
#define XLUA_REGISTER_OPTIONAL_INDEX_OBSERVER(CLS_OBJ, PROPERTY_TYPE, PROPERTY_NAME) \
CLS_OBJ["register_observer"] = [](xwidgets_type & widget, sol::protected_function function){ \
auto callback = [function](const auto& s) { \
auto res = function.call(xtl::xoptional<int>(s.PROPERTY_NAME).value()+1); \
auto res = function.call(std::optional<int>(s.PROPERTY_NAME).value()+1); \
if (!res.valid()) \
{ \
auto & interpreter = xeus::get_interpreter(); \
Expand Down
2 changes: 1 addition & 1 deletion xeus-luaConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR};${CMAKE_MODULE_PATH}")
@XEUS_LUA_CONFIG_CODE@

include(CMakeFindDependencyMacro)
find_dependency(xtl @xtl_REQUIRED_VERSION@)

find_dependency(xeus @xeus_REQUIRED_VERSION@)
find_dependency(cppzmq @cppzmq_REQUIRED_VERSION@)
find_dependency(Lua @Lua_REQUIRED_VERSION@)
Expand Down

0 comments on commit acf7121

Please sign in to comment.