Skip to content

Commit a2841c6

Browse files
anutosh491vgvassilev
authored andcommitted
Update to xeus 5
Fixes #108, Fixes #110
1 parent f3122ce commit a2841c6

12 files changed

+142
-77
lines changed

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,9 @@ endif()
7878
# Dependencies
7979
# ============
8080

81-
set(xtl_REQUIRED_VERSION 0.7.0)
82-
set(xeus_REQUIRED_VERSION 3.2.0)
83-
set(xeus_zmq_REQUIRED_VERSION 1.0.2)
81+
set(xeus_REQUIRED_VERSION 5.0.0)
82+
set(xeus_zmq_REQUIRED_VERSION 3.0.0)
8483

85-
if (NOT TARGET xtl)
86-
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
87-
endif ()
8884
if (NOT TARGET xeus AND NOT TARGET xeus-static)
8985
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
9086
if (xeus_FOUND)
@@ -304,7 +300,7 @@ macro(xeus_cpp_create_target target_name linkage output_name)
304300
set(XEUS_CPP_XEUS_TARGET xeus-static)
305301
endif ()
306302

307-
target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl)
303+
target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse)
308304

309305
if (WIN32 OR CYGWIN)
310306
#

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,25 @@ http://xeus-cpp.readthedocs.io
128128

129129
`xeus-cpp` depends on
130130

131+
131132
- [xeus-zmq](https://github.com/jupyter-xeus/xeus-zmq)
132-
- [xtl](https://github.com/xtensor-stack/xtl)
133133
- [nlohmann_json](https://github.com/nlohmann/json)
134134
- [cppzmq](https://github.com/zeromq/cppzmq)
135-
- [clang](https://github.com/llvm/llvm-project/)
136135
- [argparse](https://github.com/p-ranav/argparse)
136+
- [CppInterOp](https://github.com/compiler-research/CppInterOp)
137+
138+
| `xeus-cpp` | `xeus-zmq` | `CppInterOp` | `pugixml` | `cppzmq` | `cpp-argparse`| `nlohmann_json` |
139+
|------------|-----------------|--------------|-----------|----------|---------------|-----------------|
140+
| main | >=3.0.0,<4.0.0 | >=1.3.0 | ~1.8.1 | ~4.3.0 | <3.1 | >=3.11.3,<4.0 |
141+
142+
Versions prior to `main` have an additional dependency on [xtl](https://github.com/xtensor-stack/xtl) & [clang](https://github.com/llvm/llvm-project/).
137143

138-
| `xeus-cpp` | `xeus-zmq` | `xtl` | `CppInterOp` | `clang` | `pugixml` | `cppzmq` | `cpp-argparse`| `nlohmann_json` |
139-
|------------|-----------------|-----------------|--------------|-----------|-----------|----------|---------------|-----------------|
140-
| main | >=1.0.2,<2.0.0 | >=0.7.7,<0.8.0 | >=1.3.0 | | ~1.8.1 | ~4.3.0 | <3.1 | >=3.11.2,<4.0 |
141-
| 0.4.0 | >=1.0.0,<2.0.0 | >=0.7.7,<0.8.0 | | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
142-
| 0.3.0 | >=1.0.0,<2.0.0 | >=0.7.7,<0.8.0 | | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
143-
| 0.2.0 | >=1.0.0,<2.0.0 | >=0.7.7,<0.8.0 | | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
144-
| 0.1.0 | >=1.0.0,<2.0.0 | >=0.7.0,<0.8.0 | | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
144+
| `xeus-cpp` | `xeus-zmq` | `xtl` | `clang` | `pugixml` | `cppzmq` | `cpp-argparse`| `nlohmann_json` |
145+
|------------|-----------------|-----------------|-----------|-----------|----------|---------------|-----------------|
146+
| 0.4.0 | >=1.0.0,<2.0.0 | >=0.7.7,<0.8.0 | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
147+
| 0.3.0 | >=1.0.0,<2.0.0 | >=0.7.7,<0.8.0 | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
148+
| 0.2.0 | >=1.0.0,<2.0.0 | >=0.7.7,<0.8.0 | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
149+
| 0.1.0 | >=1.0.0,<2.0.0 | >=0.7.0,<0.8.0 | >=16,<17 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 |
145150

146151
## Contributing
147152

environment-dev.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ dependencies:
77
- cmake
88
- cxx-compiler
99
# Host dependencies
10-
- xeus-zmq >=1.0.2,<2.0
11-
- nlohmann_json=3.11.2
10+
- xeus>=5.0.0
11+
- xeus-zmq>=3.0,<4.0
12+
- nlohmann_json=3.11.3
1213
- cppzmq
13-
- xtl
1414
- CppInterOp>=1.3.0
1515
- pugixml
1616
- cpp-argparse <3.1
1717
- zlib
1818
# Test dependencies
1919
- pytest
20-
- jupyter_kernel_test>=0.4.3
20+
- jupyter_kernel_test>=0.5,<0.6
2121
- nbval
2222
- pytest-rerunfailures
2323
- doctest

environment-wasm-host.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ channels:
44
- https://repo.mamba.pm/conda-forge
55
dependencies:
66
- nlohmann_json
7-
- xeus-lite <2.0
8-
- xeus >=3.2.0,<4.0
9-
- xtl >=0.7,<0.8
7+
- xeus-lite
8+
- xeus
109
- CppInterOp>=1.3.0
1110
- cpp-argparse
1211
- pugixml

include/xeus-cpp/xinterpreter.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ namespace xcpp
4444

4545
void configure_impl() override;
4646

47-
nl::json execute_request_impl(
47+
void execute_request_impl(
48+
send_reply_callback cb,
4849
int execution_counter,
4950
const std::string& code,
50-
bool silent,
51-
bool store_history,
52-
nl::json user_expressions,
53-
bool allow_stdin
51+
xeus::execute_request_config config,
52+
nl::json user_expressions
5453
) override;
5554

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

notebooks/xeus-cpp.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@
479479
"\n",
480480
"#include \"nlohmann/json.hpp\"\n",
481481
"\n",
482-
"#include \"xtl/xbase64.hpp\"\n",
482+
"#include \"xeus/xbase64.hpp\"\n",
483483
"\n",
484484
"namespace nl = nlohmann;\n",
485485
"\n",
@@ -499,7 +499,7 @@
499499
" nl::json mime_bundle_repr(const image& i)\n",
500500
" {\n",
501501
" auto bundle = nl::json::object();\n",
502-
" bundle[\"image/png\"] = xtl::base64encode(i.m_buffer.str());\n",
502+
" bundle[\"image/png\"] = xeus::base64encode(i.m_buffer.str());\n",
503503
" return bundle;\n",
504504
" }\n",
505505
"}"
@@ -579,7 +579,7 @@
579579
"\n",
580580
"#include \"nlohmann/json.hpp\"\n",
581581
"\n",
582-
"#include \"xtl/xbase64.hpp\"\n",
582+
"#include \"xeus/xbase64.hpp\"\n",
583583
"\n",
584584
"namespace nl = nlohmann;\n",
585585
"\n",
@@ -601,7 +601,7 @@
601601
" auto bundle = nl::json::object();\n",
602602
" bundle[\"text/html\"] =\n",
603603
" std::string(\"<audio controls=\\\"controls\\\"><source src=\\\"data:audio/wav;base64,\")\n",
604-
" + xtl::base64encode(a.m_buffer.str()) +\n",
604+
" + xeus::base64encode(a.m_buffer.str()) +\n",
605605
" \"\\\" type=\\\"audio/wav\\\" /></audio>\";\n",
606606
" return bundle;\n",
607607
" }\n",

src/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <xeus/xkernel.hpp>
2424
#include <xeus/xkernel_configuration.hpp>
2525

26+
#include "xeus-zmq/xzmq_context.hpp"
2627
#include <xeus-zmq/xserver_zmq.hpp>
2728

2829
#include "xeus-cpp/xeus_cpp_config.hpp"
@@ -61,18 +62,20 @@ int main(int argc, char* argv[])
6162

6263
interpreter_ptr interpreter = xcpp::build_interpreter(argc, argv);
6364

64-
auto context = xeus::make_context<zmq::context_t>();
65+
// auto context = xeus::make_context<zmq::context_t>();
66+
std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();
6567

6668
if (!file_name.empty())
6769
{
6870
xeus::xconfiguration config = xeus::load_configuration(file_name);
6971

72+
std::clog << "Instantiating kernel" << std::endl;
7073
xeus::xkernel kernel(
7174
config,
7275
xeus::get_user_name(),
7376
std::move(context),
7477
std::move(interpreter),
75-
xeus::make_xserver_zmq,
78+
xeus::make_xserver_default,
7679
xeus::make_in_memory_history_manager(),
7780
xeus::make_console_logger(
7881
xeus::xlogger::msg_type,
@@ -94,14 +97,15 @@ int main(int argc, char* argv[])
9497
xeus::get_user_name(),
9598
std::move(context),
9699
std::move(interpreter),
97-
xeus::make_xserver_zmq,
100+
xeus::make_xserver_default,
98101
xeus::make_in_memory_history_manager(),
99102
xeus::make_console_logger(
100103
xeus::xlogger::msg_type,
101104
xeus::make_file_logger(xeus::xlogger::content, "xeus.log")
102105
)
103106
);
104107

108+
std::cout << "Getting config" << std::endl;
105109
const auto& config = kernel.get_config();
106110
std::clog << "Starting xcpp kernel...\n\n"
107111
"If you want to connect to this kernel from an other client, just copy"

src/xinspect.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
#include <pugixml.hpp>
1717

18-
#include <xtl/xsystem.hpp>
19-
2018
#include "xeus-cpp/xbuffer.hpp"
2119
#include "xeus-cpp/xpreamble.hpp"
2220

src/xinterpreter.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <string>
1717
#include <vector>
1818

19-
#include <xtl/xsystem.hpp>
19+
#include "xeus/xsystem.hpp"
2020

2121
#include <xeus/xhelper.hpp>
2222

@@ -127,27 +127,27 @@ __get_cxx_version ()
127127
restore_output();
128128
}
129129

130-
nl::json interpreter::execute_request_impl(
131-
int /*execution_counter*/,
130+
void interpreter::execute_request_impl(
131+
send_reply_callback cb,
132+
int /*execution_count*/,
132133
const std::string& code,
133-
bool silent,
134-
bool /*store_history*/,
135-
nl::json /*user_expressions*/,
136-
bool allow_stdin
134+
xeus::execute_request_config config,
135+
nl::json /*user_expressions*/
137136
)
138137
{
139138
nl::json kernel_res;
140139

141140

142-
auto input_guard = input_redirection(allow_stdin);
141+
auto input_guard = input_redirection(config.allow_stdin);
143142

144143
// Check for magics
145144
for (auto& pre : preamble_manager.preamble)
146145
{
147146
if (pre.second.is_match(code))
148147
{
149148
pre.second.apply(code, kernel_res);
150-
return kernel_res;
149+
cb(kernel_res);
150+
return;
151151
}
152152
}
153153

@@ -162,7 +162,7 @@ __get_cxx_version ()
162162
auto cout_strbuf = std::cout.rdbuf();
163163
auto cerr_strbuf = std::cerr.rdbuf();
164164

165-
if (silent)
165+
if (config.silent)
166166
{
167167
auto null = xnull();
168168
std::cout.rdbuf(&null);
@@ -202,7 +202,7 @@ __get_cxx_version ()
202202
std::cerr << std::flush;
203203

204204
// Reset non-silent output buffers
205-
if (silent)
205+
if (config.silent)
206206
{
207207
std::cout.rdbuf(cout_strbuf);
208208
std::cerr.rdbuf(cerr_strbuf);
@@ -221,7 +221,7 @@ __get_cxx_version ()
221221
ename = " ";
222222
}
223223
std::vector<std::string> traceback({ename + evalue});
224-
if (!silent)
224+
if (!config.silent)
225225
{
226226
publish_execution_error(ename, evalue, traceback);
227227
}
@@ -237,7 +237,7 @@ __get_cxx_version ()
237237
/*
238238
// Publish a mime bundle for the last return value if
239239
// the semicolon was omitted.
240-
if (!silent && output.hasValue() && trim(code).back() != ';')
240+
if (!config.silent && output.hasValue() && trim(code).back() != ';')
241241
{
242242
nl::json pub_data = mime_repr(output);
243243
publish_execution_result(execution_counter, std::move(pub_data), nl::json::object());
@@ -248,7 +248,7 @@ __get_cxx_version ()
248248
kernel_res["payload"] = nl::json::array();
249249
kernel_res["user_expressions"] = nl::json::object();
250250
}
251-
return kernel_res;
251+
cb(kernel_res);
252252
}
253253

254254
nl::json interpreter::complete_request_impl(const std::string& code, int cursor_pos)
@@ -387,7 +387,7 @@ __get_cxx_version ()
387387

388388
void interpreter::init_includes()
389389
{
390-
Cpp::AddIncludePath((xtl::prefix_path() + "/include/").c_str());
390+
Cpp::AddIncludePath((xeus::prefix_path() + "/include/").c_str());
391391
}
392392

393393
void interpreter::init_preamble()

0 commit comments

Comments
 (0)