Skip to content

Commit

Permalink
update xeus 5 (#88)
Browse files Browse the repository at this point in the history
update xeus 5
---------

Co-authored-by: Johan Mabille <[email protected]>
  • Loading branch information
DerThorsten and JohanMabille authored Dec 16, 2024
1 parent 4189a98 commit 80d9f02
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 48 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
os: [ubuntu-22.04, macos-12]
build_type: [static_build, shared_build]

steps:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]
os: [windows-2022]
build_type: [static_build, shared_build]

steps:
Expand Down Expand Up @@ -116,6 +116,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%\Library" ^
-DXEXTRA_JUPYTER_DATA_DIR=%CONDA_PREFIX%\share\jupyter ^
-D CMAKE_CXX_FLAGS=" /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR" ^
-D XSQL_BUILD_TESTS=ON ^
${{ env.CMAKE_EXTRA_ARGS }}
working-directory: build
Expand Down
18 changes: 3 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set(xeus-zmq_REQUIRED_VERSION 1.1.1)
find_package(xeus-zmq ${xeus-zmq_REQUIRED_VERSION} REQUIRED)
find_package(xvega)

find_package(tabulate REQUIRED)
#find_package(tabulate REQUIRED)
find_package(Threads REQUIRED)

find_package(Soci REQUIRED MODULE)
Expand Down Expand Up @@ -130,22 +130,10 @@ macro(xsql_set_common_options target_name)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Intel")

target_compile_options(${target_name} PUBLIC -Wunused-parameter -Wextra -Wreorder)

# C++14 flag, setting this flag is failing on Clang
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
if (HAS_CPP14_FLAG)
target_compile_features(${target_name} PRIVATE cxx_std_14)
else ()
message(FATAL_ERROR "Unsupported compiler -- xeus-sql requires C++14 support!")
endif ()
else ()
target_compile_features(${target_name} PRIVATE cxx_std_14)
endif ()
endif ()

endif ()
target_compile_features(${target_name} PRIVATE cxx_std_17)

if (APPLE)
set_target_properties(${target_name} PROPERTIES
Expand Down
10 changes: 5 additions & 5 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ dependencies:
- cppzmq
- nlohmann_json
- soci-core
- xeus-zmq=1.1.1
- xproperty=0.11.0
- xtl
- xvega-bindings=0.0.10
- xvega=0.0.10
- xeus>=5.0,<=6
- xeus-zmq
- xproperty
- xvega-bindings>=0.1.0
- xvega=>0.1.0
# Test dependencies
- doctest >= 2.4.6
11 changes: 5 additions & 6 deletions include/xeus-sql/xeus_sql_interpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ namespace xeus_sql

private:
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;
nl::json inspect_request_impl(const std::string& code,
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "xeus/xkernel.hpp"
#include "xeus/xkernel_configuration.hpp"

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

#include "xeus-sql/xeus_sql_interpreter.hpp"

Expand Down Expand Up @@ -79,7 +80,7 @@ int main(int argc, char* argv[])
// Load configuration file
std::string file_name = extract_filename(argc, argv);

auto context = xeus::make_context<zmq::context_t>();
std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();

// Create interpreter instance
using interpreter_ptr = std::unique_ptr<xeus_sql::interpreter>;
Expand Down
37 changes: 20 additions & 17 deletions src/xeus_sql_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,17 @@ namespace xeus_sql
return pub_data;
}

nl::json interpreter::execute_request_impl(int execution_counter,
const std::string& code,
bool /*silent*/,
bool /*store_history*/,
nl::json /*user_expressions*/,
bool /*allow_stdin*/)
void interpreter::execute_request_impl(send_reply_callback cb,
int execution_counter,
const std::string& code,
xeus::execute_request_config /*config*/,
nl::json user_expressions)
{
auto ok = []() {
auto ok = [&]() {
nl::json jresult;
jresult["status"] = "ok";
jresult["payload"] = nl::json::array();
jresult["user_expressions"] = nl::json::object();
jresult["user_expressions"] = user_expressions;
return jresult;
};

Expand Down Expand Up @@ -247,7 +246,8 @@ namespace xeus_sql
std::move(chart),
nl::json::object());

return ok();
cb(ok());
return;
} else if (xv_bindings::case_insentive_equals("VEGA_LITE", tokenized_input[0])) {
if (tokenized_input.size() < 2) {
throw std::runtime_error("invalid input: " + code);
Expand All @@ -269,7 +269,8 @@ namespace xeus_sql
auto bundle = nl::json::object();
bundle["text/plain"] = "SET " + spec_name + " success.";
publish_execution_result(execution_counter, std::move(bundle), nl::json::object());
return ok();
cb(ok());
return;
}
nl::json j;
auto v = specs.find(tokenized_input[1]);
Expand Down Expand Up @@ -297,7 +298,8 @@ namespace xeus_sql
auto bundle = nl::json::object();
bundle["application/vnd.vegalite.v3+json"] = j;
publish_execution_result(execution_counter, std::move(bundle), nl::json::object());
return ok();
cb(ok());
return;
}

/* Parses LOAD magic */
Expand Down Expand Up @@ -334,18 +336,18 @@ namespace xeus_sql
}
}
} catch (const std::runtime_error &err) {
return handle_exception((std::string)err.what());
cb(handle_exception((std::string)err.what()));
#ifdef USE_POSTGRE_SQL
} catch (const soci::postgresql_soci_error &err) {
return handle_exception((std::string)err.what());
cb(handle_exception((std::string)err.what()));
#endif
#ifdef USE_MYSQL
} catch (const soci::mysql_soci_error &err) {
return handle_exception((std::string)err.what());
cb(handle_exception((std::string)err.what()));
#endif
#ifdef USE_SQLITE3
} catch (const soci::sqlite3_soci_error &err) {
return handle_exception((std::string)err.what());
cb(handle_exception((std::string)err.what()));
#endif
} catch (...) {
// https: // stackoverflow.com/a/54242936/1203241
Expand All @@ -355,10 +357,11 @@ namespace xeus_sql
std::rethrow_exception(curr_excp);
}
} catch (const std::exception &err) {
return handle_exception((std::string)err.what());
cb(handle_exception((std::string)err.what()));
}
}
return ok();
cb(ok());
return;
}
nl::json interpreter::complete_request_impl(const std::string& raw_code,
int cursor_pos)
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ set_target_properties(test_xeus_sql PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
)

target_compile_features(test_xeus_sql PRIVATE cxx_std_17)

if (XSQL_BUILD_SHARED)
set(XSQL_TEST_LINK_TARGET xeus-sql)
else()
Expand Down
2 changes: 1 addition & 1 deletion xeus-sqlConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ find_dependency(mysql)
find_dependency(PostgreSQL)

find_dependency(Threads @Threads_REQUIRED_VERSION@)
find_dependency(tabulate @tabulate_REQUIRED_VERSION@)
#find_dependency(tabulate @tabulate_REQUIRED_VERSION@)

if (NOT TARGET xeus-sql)
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Expand Down

0 comments on commit 80d9f02

Please sign in to comment.