Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded to xeus-zmq 3 #12

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 17 additions & 32 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
unix:
Expand All @@ -22,44 +20,38 @@ jobs:


steps:
- uses: actions/checkout@v2
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
- uses: actions/checkout@v4

- name: install mamba
uses: mamba-org/provision-with-micromamba@main
- name: Install micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: env.yml
environment-name: xeusqt
environment-file: environment-dev.yml
environment-name: xeus-qt

- name: install cxx compiler
- name: Create build directory
shell: bash -l {0}
run: |
$HOME/micromamba-bin/micromamba install cxx-compiler libuuid -c conda-forge -y
run: mkdir -p build

- name: cmake configure
shell: bash -l {0}
run: |
mkdir -p build
cd build
cmake .. \
-DXEUS_BUILD_TESTS=ON \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
working-directory: build

- name: build
shell: bash -l {0}
run: |
cd build
make -j 2
# make -j ${{ steps.cpu-cores.outputs.count }}
working-directory: build


- name: install xeus-qt
shell: bash -l {0}
run: |
cd build
make install
working-directory: build

win:

Expand All @@ -71,39 +63,32 @@ jobs:
os: [ windows-2019, windows-2022 ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: install mamba
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: env.yml
environment-name: xeus

- name: micromamba shell hook
shell: powershell
run: |
micromamba shell hook -s cmd.exe -p C:\Users\runneradmin\micromamba-root
environment-file: environment-dev.yml
environment-name: xeus-qt
init-shell: cmd.exe

- name: Make build directory
run: mkdir build

- name: cmake configure
shell: cmd
shell: cmd /C call {0}
run: |
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus
cmake .. ^
-G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DXEUS_BUILD_TESTS=ON ^
-DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" ^
-DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" ^
-DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%"
working-directory: build

- name: build
shell: cmd
shell: cmd /C call {0}
run: |
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus
set CL=/MP
ninja install
working-directory: build
Expand Down
56 changes: 2 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)


# Compilation options
option(XQ_DISABLE_ARCH_NATIVE "disable -march=native flag" OFF)
option(XQ_BUILD_SHARED_LIBS "Build XQ shared library." ON)
option(XQ_BUILD_STATIC_LIBS "Build XQ static library (default if BUILD_SHARED_LIBS is OFF)." ON)
option(XQ_STATIC_DEPENDENCIES "link statically with XQ dependencies" OFF)
Expand Down Expand Up @@ -49,19 +48,11 @@ message(STATUS "xq binary version: v${XQ_BINARY_VERSION}")
# Dependencies
# ============

set(nlohmann_json_REQUIRED_VERSION 3.2.0)
set(xtl_REQUIRED_VERSION 0.7)
set(cppzmq_REQUIRED_VERSION 4.4.1)
set(zeromq_REQUIRED_VERSION 4.3.2)
set(xeus_zmq_REQUIRED_VERSION 1.0.2)
set(xeus_REQUIRED_VERSION 3.0.3)
set(nlohmann_json_REQUIRED_VERSION 3.11.3)
set(xeus_zmq_REQUIRED_VERSION 3.0)

find_package(Qt5 COMPONENTS Core REQUIRED)

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

if (NOT TARGET xeus-zmq AND NOT TARGET xeus-zmq-static)
find_package(xeus-zmq ${xeus_zmq_REQUIRED_VERSION} REQUIRED)
endif ()
Expand All @@ -70,40 +61,6 @@ if (NOT TARGET nlohmann_json)
find_package(nlohmann_json ${nlohmann_json_REQUIRED_VERSION} REQUIRED)
endif ()

if (NOT TARGET xtl)
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
endif ()

if (NOT TARGET cppzmq AND NOT TARGET cppzmq-static)
find_package(cppzmq ${cppzmq_REQUIRED_VERSION} REQUIRED)
endif ()

if (NOT TARGET libzmq AND NOT TARGET libzmq-static)
if (WIN32)
find_package(zeromq ${zeromq_REQUIRED_VERSION} REQUIRED)
else ()
find_package(zeromq ${zeromq_REQUIRED_VERSION} QUIET)

if (NOT ZeroMQ_FOUND)
message(STATUS "CMake libzmq package not found, trying again with pkg-config")
find_package(PkgConfig)
pkg_check_modules(ZeroMQ libzmq>=${zeromq_REQUIRED_VERSION} REQUIRED)
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
message(STATUS "STATIC_LIBRARY" {ZeroMQ_LIBRARY})
message(STATUS "STATIC_STATIC_LIBRARY" {ZeroMQ_STATIC_LIBRARY})
endif ()
endif ()
endif ()

if (NOT DEFINED OPENSSL_LIBRARY)
set(OPENSSL_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
find_package(OpenSSL REQUIRED)
endif ()

# Source files
# ============

Expand Down Expand Up @@ -145,16 +102,11 @@ macro(xq_create_target target_name linkage output_name)

target_link_libraries(
${target_name}
PUBLIC ${CPPZMQ_TARGET_NAME}
PUBLIC nlohmann_json::nlohmann_json
PUBLIC xtl
PUBLIC xeus
PUBLIC xeus-zmq
PUBLIC Qt5::Core
)

target_link_libraries(${target_name} PUBLIC OpenSSL::Crypto)

if (UNIX)
# CMake does not compute the version number of so files as libtool
# does on Linux. Strictly speaking, we should exclude FreeBSD and
Expand Down Expand Up @@ -196,10 +148,6 @@ macro(xq_create_target target_name linkage output_name)

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

if (NOT XQ_DISABLE_ARCH_NATIVE)
target_compile_options(${target_name} PUBLIC -march=native)
endif ()

message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
endif()

Expand Down
25 changes: 0 additions & 25 deletions env.yml

This file was deleted.

22 changes: 22 additions & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: xeus-qt
channels:
- conda-forge
dependencies:
# Build dependencies
- cmake
- cxx-compiler
- pkg-config
- make
# Host dependencies
- nlohmann_json =3.11.3
- xeus-zmq >=3.0, <4.0
- qt >= 5.12.9, <6
#- git
- mesa-libgl-cos7-aarch64
- mesa-libgl-cos6-x86_64
- mesa-dri-drivers-cos6-x86_64
- libselinux-cos6-x86_64
- libxdamage-cos6-x86_64
- libxxf86vm-cos6-x86_64
- libxext-cos6-x86_64
- xorg-libxfixes
12 changes: 1 addition & 11 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -headerpad_max_install_names")
endif()

set(nlohmann_json_REQUIRED_VERSION 3.2.0)
set(xtl_REQUIRED_VERSION 0.7)
set(cppzmq_REQUIRED_VERSION 4.4.1)
set(zeromq_REQUIRED_VERSION 4.3.2)
set(nlohmann_json_REQUIRED_VERSION 3.11.3)
# set(CMAKE_C_FLAGS "lrt")

find_package(Qt5Core ${Qt5_REQUIRED_VERSION} REQUIRED)
find_package(Qt5Widgets ${Qt5_REQUIRED_VERSION} REQUIRED)
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
find_package(nlohmann_json ${nlohmann_json_REQUIRED_VERSION} REQUIRED)
find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED)
find_package(cppzmq ${cppzmq_REQUIRED_VERSION} REQUIRED)
find_package(xeus-lua REQUIRED)
find_package(xwidgets REQUIRED)
find_package(xproperty REQUIRED)
find_package(xq REQUIRED)
find_package(zeromq ${zeromq_REQUIRED_VERSION} QUIET)
find_package(xcanvas REQUIRED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -61,10 +54,7 @@ endif()

target_link_libraries(
${PROJECT_NAME}
PUBLIC ${CPPZMQ_TARGET_NAME}
PUBLIC nlohmann_json::nlohmann_json
PUBLIC xtl
PUBLIC xeus
PUBLIC xeus-lua
PUBLIC xwidgets
PUBLIC xproperty
Expand Down
4 changes: 4 additions & 0 deletions examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "xeus/xkernel.hpp"
#include "xeus/xkernel_configuration.hpp"

#include "xeus-zmq/xzmq_context.hpp"

#include "xeus-lua/xinterpreter.hpp"

void create_json_file(std::string kernel_info)
Expand All @@ -39,6 +41,8 @@ class MainWindow : public QMainWindow{
// zmq context
auto context = xeus::make_context<zmq::context_t>();

std::unique_ptr<xeus::xcontext> context = xeus::make_zmq_context();

// Create interpreter instance
interpreter_ptr interpreter = std::make_unique<xlua::interpreter>();

Expand Down
55 changes: 46 additions & 9 deletions include/xq/xq_qt_poller.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
/***************************************************************************
* Copyright (c) 2021, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XQ_POLLER_HPP
#define XQ_POLLER_HPP

#include "zmq.hpp"
#include "zmq_addon.hpp"
#include <atomic>
#include <functional>
#include <optional>

#include "xeus/xmessage.hpp"
#include "xeus/xkernel_configuration.hpp"
#include <QThread>
#include <QSharedData>

#include "xeus-zmq/xauthentication.hpp"
#include "xeus/xserver.hpp"

#include "xq.hpp"

#include <iostream>
#include <atomic>
namespace xeus
{
class XQ_API WorkerThread : public QThread
{
public:

#include <QThread>
#include <QSharedData>
Q_OBJECT

public:

using message_channel = std::pair<xmessage, channel>;
using opt_message_channel = std::optional<message_channel>;
using poller_t = std::function<opt_message_channel(long)>;

WorkerThread(QObject* parent,
poller_t poller);

void run();
void stop();

private:

poller_t m_poller;
std::atomic<bool> m_request_stop;

signals:

void received_shell_msg_signal(xeus::xmessage* msg);
void received_controll_msg_signal(xeus::xmessage* msg);
};
}

/*
class XQ_API WorkerThread : public QThread
{
public:
Expand All @@ -26,6 +61,7 @@ class XQ_API WorkerThread : public QThread

public:


WorkerThread(QObject* parent,
zmq::socket_t* p_shell,
zmq::socket_t* p_controller,
Expand All @@ -48,5 +84,6 @@ class XQ_API WorkerThread : public QThread
void received_controll_msg_signal(xeus::xmessage* msg);
};

*/
#endif

Loading