Skip to content

Commit acf7121

Browse files
authored
Update xeus (#52)
* update xeus to xeus 5
1 parent 8dd7519 commit acf7121

File tree

11 files changed

+56
-62
lines changed

11 files changed

+56
-62
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ jobs:
129129
source $CONDA_EMSDK_DIR/emsdk_env.sh
130130
131131
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
132-
133132
mkdir build
134133
pushd build
135134

CMakeLists.txt

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
1212

1313
set(XEUS_LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
1414

15+
16+
# PRINT THE COMPILER
17+
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
18+
19+
if(EMSCRIPTEN)
20+
message(STATUS "EMSCRIPTEN")
21+
else()
22+
message(STATUS "NOT EMSCRIPTEN")
23+
endif()
24+
25+
26+
1527
# Versionning
1628
# ===========
1729

@@ -77,28 +89,19 @@ endif()
7789
# Dependencies
7890
# ============
7991

80-
set(xtl_REQUIRED_VERSION 0.7.0)
81-
set(xeus_REQUIRED_VERSION 3.0.0)
82-
set(xwidgets_REQUIRED_VERSION 0.27.0)
83-
set(xcanvas_REQUIRED_VERSION 0.3.0)
84-
set(xproperty_REQUIRED_VERSION 0.11.0)
92+
93+
set(xeus_REQUIRED_VERSION 5.0.0)
94+
set(xwidgets_REQUIRED_VERSION 0.29.0)
95+
set(xcanvas_REQUIRED_VERSION 0.5.0)
96+
set(xproperty_REQUIRED_VERSION 0.12.0)
8597
set(Lua_REQUIRED_VERSION 5.3.4)
8698

87-
if (NOT TARGET xtl)
88-
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
89-
endif ()
90-
if (NOT TARGET xeus AND NOT TARGET xeus-static)
91-
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
92-
endif ()
99+
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
93100

94101
if(NOT XEUS_LUA_USE_LUAJIT)
95-
if (NOT TARGET Lua) # not sure about these lines
96-
find_package(Lua ${lua_REQUIRED_VERSION} REQUIRED)
97-
endif ()
102+
find_package(Lua ${lua_REQUIRED_VERSION} REQUIRED)
98103
else()
99-
if (NOT TARGET LuaJIT) # not sure about these lines
100-
find_package(LuaJIT REQUIRED)
101-
endif ()
104+
find_package(LuaJIT REQUIRED)
102105
endif()
103106

104107
# Flags
@@ -315,7 +318,7 @@ macro(xeus_lua_create_target target_name linkage output_name)
315318
set(XLUA_XCANVAS_TARGET "")
316319
endif()
317320

318-
target_link_libraries(${target_name} PUBLIC ${XEUS_LUA_XEUS_TARGET} xtl
321+
target_link_libraries(${target_name} PUBLIC ${XEUS_LUA_XEUS_TARGET}
319322
${XLUA_XWIDGETS_TARGET}
320323
${XLUA_XPROPERTY_TARGET}
321324
${XLUA_XCANVAS_TARGET}
@@ -373,12 +376,12 @@ endif()
373376
if(EMSCRIPTEN)
374377
include(WasmBuildOptions)
375378
find_package(xeus-lite REQUIRED)
376-
add_executable(xlua src/main_emscripten_kernel.cpp )
377-
target_link_libraries(xlua PRIVATE xeus-lite)
378-
target_compile_features(xlua PRIVATE cxx_std_17)
379-
xeus_lua_set_kernel_options(xlua)
380-
xeus_wasm_compile_options(xlua)
381-
xeus_wasm_link_options(xlua "web,worker")
379+
add_executable(xlua_wasm src/main_emscripten_kernel.cpp )
380+
target_link_libraries(xlua_wasm PRIVATE xeus-lite)
381+
target_compile_features(xlua_wasm PRIVATE cxx_std_17)
382+
xeus_lua_set_kernel_options(xlua_wasm)
383+
xeus_wasm_compile_options(xlua_wasm)
384+
xeus_wasm_link_options(xlua_wasm "web,worker")
382385
endif()
383386

384387

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,9 @@ the xeus ecosystem like [xwidgets](https://github.com/jupyter-xeus/xwidgets).
117117
`xeus-lua` depends on
118118

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

124-
| `xeus-lua` | `xeus` | `xwidgets` | `xtl` | `cppzmq` | `nlohmann_json` | `lua` |
125-
| ------------- | ------------- | ------------- | ------------ | -------- | --------------- | ------------ |
126-
| master | >=2.4.0,<3 | >=0.26.1 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<4.0 | >=5.2.0 |
127-
| 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 |
128123

129124
## Contributing
130125

environment-dev.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ dependencies:
66
- cmake
77
- cxx-compiler
88
# Host dependencies
9-
- xeus-zmq>=1.3.0, <2.0
10-
- nlohmann_json=3.11.2
9+
- xeus>=5.0,<=6
10+
- xeus-zmq
11+
- nlohmann_json
1112
- cppzmq
12-
- xtl>=0.7
1313
- lua>=5.2.0
1414
- openlibm # [linux]
15-
- xwidgets <0.29
15+
- xwidgets >=0.29
1616
- xcanvas>=0.4.2
1717
# to try it out
1818
- jupyterlab

environment-wasm-host.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ channels:
55
dependencies:
66
- lua
77
- nlohmann_json
8-
- xeus-lite <2.0
9-
- xeus >=3.2.0,<4.0
10-
- xtl >=0.7,<0.8
11-
- xcanvas >=0.4,<5.0
12-
- xwidgets >=0.27.3,<1.0
8+
- xeus-lite >=2.0
9+
- xeus>=5.0,<=6
10+
- xcanvas >=0.5,<5.0
11+
- xwidgets >=0.28.0,<1.0

include/xeus-lua/xinterpreter.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "xeus_lua_config.hpp"
2121
#include "xeus/xinterpreter.hpp"
22-
22+
#include "xeus/xrequest_context.hpp"
2323

2424
extern "C" {
2525
#ifndef XEUS_LUA_USE_LUAJIT
@@ -47,12 +47,11 @@ namespace xlua
4747

4848
void configure_impl() override;
4949

50-
nl::json execute_request_impl(int execution_counter,
51-
const std::string& code,
52-
bool silent,
53-
bool store_history,
54-
nl::json user_expressions,
55-
bool allow_stdin) override;
50+
void execute_request_impl(send_reply_callback cb,
51+
int execution_counter,
52+
const std::string& code,
53+
xeus::execute_request_config config,
54+
nl::json user_expressions) override;
5655

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

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include "xeus/xkernel.hpp"
2525
#include "xeus/xkernel_configuration.hpp"
2626
#include "xeus/xserver.hpp"
27-
#include "xeus-zmq/xserver_shell_main.hpp"
27+
28+
#include "xeus-zmq/xserver_zmq_split.hpp"
29+
#include "xeus-zmq/xzmq_context.hpp"
2830

2931

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

115117

116118

117-
using context_type = xeus::xcontext_impl<zmq::context_t>;
118-
using context_ptr = std::unique_ptr<context_type>;
119-
context_ptr context = context_ptr(new context_type());
119+
std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();
120120

121121
// Instantiating the xeus xinterpreter
122122
using interpreter_ptr = std::unique_ptr<xlua::interpreter>;

src/xdisplay.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace xlua
2323

2424

2525

26-
2726
void setup_display(
2827
sol::state_view & lua,
2928
interpreter & interp

src/xinterpreter.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,14 @@ namespace xlua
176176
{
177177
}
178178

179-
nl::json interpreter::execute_request_impl(int /*execution_count*/,
179+
void interpreter::execute_request_impl(send_reply_callback cb,
180+
int execution_count,
180181
const std::string& code,
181-
bool silent,
182-
bool /*store_history*/,
183-
nl::json /*user_expressions*/,
184-
bool allow_stdin)
182+
xeus::execute_request_config config,
183+
nl::json user_expressions)
185184
{
186185
sol::state_view lua(L);
187-
m_allow_stdin = allow_stdin;
186+
m_allow_stdin = config.allow_stdin;
188187
// reset payload
189188
nl::json kernel_res;
190189

@@ -220,7 +219,7 @@ namespace xlua
220219
sol::error err = code_result;
221220
sol::call_status status = code_result.status();
222221
const auto error_str = err.what();
223-
if (!silent)
222+
if (!config.silent)
224223
{
225224
publish_execution_error(error_str,error_str,std::vector<std::string>(1,error_str));
226225
}
@@ -231,7 +230,7 @@ namespace xlua
231230
kernel_res["traceback"] = { error_str };
232231
}
233232
}
234-
return kernel_res;
233+
cb(kernel_res);
235234
}
236235

237236
nl::json interpreter::complete_request_impl(
@@ -248,7 +247,7 @@ namespace xlua
248247
result["matches"] = matches;
249248
result["cursor_start"] = cursor_start;
250249
result["metadata"] = nl::json::object();
251-
result["cursor_end"] = cursor_pos;
250+
result["cursor_end"] = cursor_pos;
252251

253252
return result;
254253
}

src/xwidgets.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <vector>
55
#include <string>
66
#include <iostream>
7+
#include <optional>
78

89
#include "sol/sol.hpp"
910
#include "xeus/xinterpreter.hpp"
@@ -158,7 +159,7 @@ namespace xlua
158159
#define XLUA_REGISTER_OPTIONAL_INDEX_OBSERVER(CLS_OBJ, PROPERTY_TYPE, PROPERTY_NAME) \
159160
CLS_OBJ["register_observer"] = [](xwidgets_type & widget, sol::protected_function function){ \
160161
auto callback = [function](const auto& s) { \
161-
auto res = function.call(xtl::xoptional<int>(s.PROPERTY_NAME).value()+1); \
162+
auto res = function.call(std::optional<int>(s.PROPERTY_NAME).value()+1); \
162163
if (!res.valid()) \
163164
{ \
164165
auto & interpreter = xeus::get_interpreter(); \

0 commit comments

Comments
 (0)