From 39b1b13c9b700e7c01ed306cd41b0c771fd8948e Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 2 Oct 2023 13:43:32 +0000 Subject: [PATCH 01/69] Initial merge with xeus-clang-repl --- .dockerignore | 2 + CMakeLists.txt | 93 ++++-- Dockerfile | 269 ++++++++++++++++++ bash-docker.sh | 9 + include/xcpp/xdisplay.hpp | 2 + include/xeus-cpp/xinterpreter.hpp | 5 +- remove-docker.sh | 3 + run-docker.sh | 15 + .../kernels/clad-xcpp17/kernel.json.in | 18 ++ .../kernels/clad-xcpp17/logo-32x32.png | Bin 0 -> 1520 bytes .../kernels/clad-xcpp17/logo-64x64.png | Bin 0 -> 3113 bytes .../jupyter/kernels/clad-xcpp17/logo-svg.svg | 25 ++ .../kernels/cppinterop-xcpp17/kernel.json.in | 18 ++ .../jupyter/kernels/omp-xcpp17/kernel.json.in | 18 ++ .../jupyter/kernels/omp-xcpp17/logo-32x32.png | Bin 0 -> 1520 bytes .../jupyter/kernels/omp-xcpp17/logo-64x64.png | Bin 0 -> 3113 bytes share/jupyter/kernels/omp-xcpp17/logo-svg.svg | 25 ++ share/jupyter/kernels/xcpp/kernel.json.in | 16 +- share/jupyter/kernels/xcpp11/kernel.json.in | 17 ++ share/jupyter/kernels/xcpp11/logo-32x32.png | Bin 0 -> 1520 bytes share/jupyter/kernels/xcpp11/logo-64x64.png | Bin 0 -> 3113 bytes share/jupyter/kernels/xcpp11/logo-svg.svg | 25 ++ share/jupyter/kernels/xcpp14/kernel.json.in | 20 ++ share/jupyter/kernels/xcpp14/logo-32x32.png | Bin 0 -> 1520 bytes share/jupyter/kernels/xcpp14/logo-64x64.png | Bin 0 -> 3113 bytes share/jupyter/kernels/xcpp14/logo-svg.svg | 25 ++ share/jupyter/kernels/xcpp17/kernel.json.in | 17 ++ share/jupyter/kernels/xcpp17/logo-32x32.png | Bin 0 -> 1520 bytes share/jupyter/kernels/xcpp17/logo-64x64.png | Bin 0 -> 3113 bytes share/jupyter/kernels/xcpp17/logo-svg.svg | 25 ++ src/main.cpp | 71 ++++- src/xinterpreter.cpp | 84 +++--- 32 files changed, 743 insertions(+), 59 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 bash-docker.sh create mode 100755 remove-docker.sh create mode 100755 run-docker.sh create mode 100644 share/jupyter/kernels/clad-xcpp17/kernel.json.in create mode 100644 share/jupyter/kernels/clad-xcpp17/logo-32x32.png create mode 100644 share/jupyter/kernels/clad-xcpp17/logo-64x64.png create mode 100644 share/jupyter/kernels/clad-xcpp17/logo-svg.svg create mode 100644 share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in create mode 100644 share/jupyter/kernels/omp-xcpp17/kernel.json.in create mode 100644 share/jupyter/kernels/omp-xcpp17/logo-32x32.png create mode 100644 share/jupyter/kernels/omp-xcpp17/logo-64x64.png create mode 100644 share/jupyter/kernels/omp-xcpp17/logo-svg.svg create mode 100644 share/jupyter/kernels/xcpp11/kernel.json.in create mode 100644 share/jupyter/kernels/xcpp11/logo-32x32.png create mode 100644 share/jupyter/kernels/xcpp11/logo-64x64.png create mode 100644 share/jupyter/kernels/xcpp11/logo-svg.svg create mode 100644 share/jupyter/kernels/xcpp14/kernel.json.in create mode 100644 share/jupyter/kernels/xcpp14/logo-32x32.png create mode 100644 share/jupyter/kernels/xcpp14/logo-64x64.png create mode 100644 share/jupyter/kernels/xcpp14/logo-svg.svg create mode 100644 share/jupyter/kernels/xcpp17/kernel.json.in create mode 100644 share/jupyter/kernels/xcpp17/logo-32x32.png create mode 100644 share/jupyter/kernels/xcpp17/logo-64x64.png create mode 100644 share/jupyter/kernels/xcpp17/logo-svg.svg diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..0dab1ed1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +build/**/* +build diff --git a/CMakeLists.txt b/CMakeLists.txt index 66833cb1..0c977704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,10 +42,50 @@ if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH) set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/") endif () -configure_file ( - "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp/kernel.json.in" - "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp/kernel.json" -) +set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}") +set(CMAKE_PATH "$ENV{PATH}") +set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") +set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}") +set(CMAKE_VENV_PATH "$ENV{VENV}") + +message(STATUS "Debug: Replace in kernels") +message(STATUS "Debug: CMAKE_CPLUS_INCLUDE_PATH=${CMAKE_CPLUS_INCLUDE_PATH}") +message(STATUS "Debug: CMAKE_PATH=${CMAKE_PATH}") +message(STATUS "Debug: CMAKE_LD_LIBRARY_PATH=${CMAKE_LD_LIBRARY_PATH}") +message(STATUS "Debug: CMAKE_PYTHONPATH=${CMAKE_PYTHONPATH}") +message(STATUS "Debug: CMAKE_VENV_PATH=${CMAKE_VENV_PATH}") +message(STATUS "Debug: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}") +message(STATUS "Debug: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}") + + +function(configure_kernel kernel) + configure_file ( + "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/kernel.json.in" + "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/kernel.json" + ) + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.png") + foreach(file ${files}) + configure_file( + "${file}" + "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/" + COPYONLY + ) + endforeach() + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.svg") + foreach(file ${files}) + configure_file( + "${file}" + "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/" + COPYONLY + ) + endforeach() +endfunction() + +file(GLOB _kernels LIST_DIRECTORIES true RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "share/jupyter/kernels/*") +foreach(_kernel IN LISTS _kernels) + message("Configure kernel: ${_kernel}") + configure_kernel("${_kernel}") +endforeach() # Build options # ============= @@ -121,12 +161,12 @@ if(EMSCRIPTEN) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") endif() -find_package(Clang REQUIRED) -include(AddLLVM) -include(HandleLLVMOptions) -add_definitions(${LLVM_DEFINITIONS}) +#find_package(Clang REQUIRED) +find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") find_package(argparse REQUIRED) find_package(pugixml REQUIRED) +##set(Python_FIND_VIRTUALENV ONLY) +##find_package(Python COMPONENTS Interpreter Development) # Source files # ============ @@ -226,7 +266,6 @@ macro(xeus_cpp_set_kernel_options target_name) find_package(Threads) target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endif() - endmacro() # Common macro for shared and static library @@ -262,7 +301,8 @@ macro(xeus_cpp_create_target target_name linkage output_name) set(XEUS_CPP_XEUS_TARGET xeus-static) endif () - target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangInterpreter pugixml argparse::argparse xtl) +## target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangInterpreter pugixml argparse::argparse xtl) + target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl) if (WIN32 OR CYGWIN) # elseif (APPLE) @@ -272,7 +312,7 @@ macro(xeus_cpp_create_target target_name linkage output_name) find_package(Threads) # TODO: add Threads as a dependence of xeus-static? target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endif() - + endmacro() # xeus-cpp-headers @@ -319,6 +359,23 @@ if (XEUS_CPP_BUILD_EXECUTABLE) xeus_cpp_set_common_options(xcpp) xeus_cpp_set_kernel_options(xcpp) target_link_libraries(xcpp PRIVATE xeus-zmq) + +##set_target_properties(xcpp PROPERTIES +## ENABLE_EXPORTS 1 +## CXX_STANDARD ${CMAKE_CXX_STANDARD} +##) +##target_link_libraries(xcpp PUBLIC xeus-cpp pthread Python::Python) +## +###TODO: We may be need sse RPATH +###set_target_properties(xcpp clangCppInterOp PROPERTIES +### INSTALL_RPATH_USE_LINK_PATH TRUE +###) +##if(APPLE) +## target_link_libraries(xcpp PUBLIC -Wl,-w -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup) +##elseif(NOT MSVC) +## target_link_libraries(xcpp PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files) +##endif() + endif() if(EMSCRIPTEN) @@ -361,20 +418,20 @@ endif () # Install xcpp if (XEUS_CPP_BUILD_EXECUTABLE) install(TARGETS xcpp - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif() +# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + RUNTIME DESTINATION ${CMAKE_VENV_PATH}/bin) +endif(XEUS_CPP_BUILD_EXECUTABLE) if(XEUS_CPP_BUILD_EXECUTABLE OR EMSCRIPTEN) # Configuration and data directories for jupyter and xeus-cpp set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory") - # Install xcpp Jupyter kernelspec - set(KERNELSPEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels) + set(KERNELSPEC_DIR ${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels) install(DIRECTORY ${KERNELSPEC_DIR} DESTINATION ${XJUPYTER_DATA_DIR} +# DESTINATION ${CMAKE_INSTALL_PREFIX}/${XJUPYTER_DATA_DIR} PATTERN "*.in" EXCLUDE) - # Extra path for installing Jupyter kernelspec if (XEXTRA_JUPYTER_DATA_DIR) install(DIRECTORY ${KERNELSPEC_DIR} @@ -439,3 +496,7 @@ if(EMSCRIPTEN) "$/xcpp.wasm" DESTINATION ${CMAKE_INSTALL_BINDIR}) endif () + +if(XEUS_CPP_INCLUDE_DOCS) + add_subdirectory(docs) +endif() diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bf8833a7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,269 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +# https://hub.docker.com/r/jupyter/base-notebook/tags +ARG BASE_CONTAINER=jupyter/base-notebook +ARG BASE_TAG=latest +ARG BUILD_TYPE=Release + +FROM $BASE_CONTAINER:$BASE_TAG + +LABEL maintainer="Xeus-cpp Project" + +SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"] + +USER root + +ENV TAG="$BASE_TAG" + +ENV LC_ALL=en_US.UTF-8 \ + LANG=en_US.UTF-8 \ + LANGUAGE=en_US.UTF-8 + +# Install all OS dependencies for notebook server that starts but lacks all +# features (e.g., download as all possible file formats) +RUN \ + set -x && \ + apt-get update --yes && \ + apt-get install --yes --no-install-recommends pciutils && \ + export _CUDA_="$(lspci -nn | grep '\[03' | grep NVIDIA)" && \ + apt-get install --yes --no-install-recommends \ + #fonts-liberation, pandoc, run-one are inherited from base-notebook container image + # Other "our" apt installs + unzip \ + curl \ + jq \ + ###libomp-dev \ + # Other "our" apt installs (development and testing) + build-essential \ + git \ + nano-tiny \ + less \ + gdb valgrind \ + emacs \ + # CUDA + #cuda \ + $([ -n "$_CUDA_" ] && echo nvidia-cuda-toolkit) \ + && \ + apt-get clean && rm -rf /var/lib/apt/lists/* && \ + echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ + locale-gen + +ENV LC_ALL=en_US.UTF-8 \ + LANG=en_US.UTF-8 \ + LANGUAGE=en_US.UTF-8 + +# Create alternative for nano -> nano-tiny +#RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10 + +USER ${NB_UID} + +# Copy git repository to home directory of container +COPY --chown=${NB_UID}:${NB_GID} . "${HOME}"/ + +EXPOSE 8888 + +# Configure container startup +CMD ["start-notebook.sh", "--debug", "&>/home/jovyan/log.txt"] + +USER root + +# Fix start-notebook.sh +RUN sed -i '2 i source /home/jovyan/.conda.init && conda activate .venv' /usr/local/bin/start-notebook.sh + +### Make /home/runner directory and fix permisions +##RUN mkdir /home/runner && fix-permissions /home/runner + +# Switch back to jovyan to avoid accidental container runs as root +USER ${NB_UID} + +ENV NB_PYTHON_PREFIX=${CONDA_DIR} \ + KERNEL_PYTHON_PREFIX=${CONDA_DIR} \ +# CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/${NB_USER}/include:/home/runner/work/xeus-clang-repl/xeus-clang-repl/clang-dev/clang/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" + CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/${NB_USER}/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" + +WORKDIR "${HOME}" + +# CUDA +ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility +ENV NVIDIA_REQUIRE_CUDA "cuda>=12.1.1 driver>=530" + +# VENV + +# Jupyter Notebook, Lab, and Hub are installed in base image +# ReGenerate a notebook server config +# Cleanup temporary files +# Correct permissions +# Do all this in a single RUN command to avoid duplicating all of the +# files across image layers when the permissions change +#RUN mamba update --all --quiet --yes -c conda-forge && \ +RUN \ + set -x && \ + # setup virtual environment + mamba create -y -n .venv python=3.10.6 && \ + # + #echo "echo \"@ @ @ PROFILE @ @ @ \"" >> ~/.profile && \ + #echo "echo \"@ @ @ BASHRC @ @ @ \"" >> /home/jovyan/.bashrc && \ + mv /home/jovyan/.bashrc /home/jovyan/.bashrc.tmp && \ + touch /home/jovyan/.bashrc && \ + conda init bash && \ + mv /home/jovyan/.bashrc /home/jovyan/.conda.init && \ + mv /home/jovyan/.bashrc.tmp /home/jovyan/.bashrc && \ + conda init bash && \ + echo "source /home/jovyan/.conda.init && conda activate .venv" >> /home/jovyan/.bashrc && \ + # + source /home/jovyan/.conda.init && \ + conda activate .venv && \ + fix-permissions "${CONDA_DIR}" && \ + # + mamba install --quiet --yes -c conda-forge \ + # notebook, jpyterhub, jupyterlab are inherited from base-notebook container image + # Other "our" conda installs + # + # Build dependencies + make \ + cmake \ + cxx-compiler \ + # Host dependencies + 'xeus-zmq>=1.0.2,<2.0' \ + nlohmann_json \ + cppzmq \ + xtl \ + 'clangdev>=17' \ + pugixml \ + cpp-argparse \ + zlib \ + # + ipykernel \ + # Test dependencies + pytest \ + 'jupyter_kernel_test>=0.4.3' \ + nbval \ + pytest-rerunfailures \ + && \ + hash -r && \ + pip install ipython && \ + #rm /home/jovyan/.jupyter/jupyter_notebook_config.py && \ + jupyter notebook --generate-config -y && \ + mamba clean --all -f -y && \ + npm cache clean --force && \ + jupyter lab clean && \ + rm -rf "/home/${NB_USER}/.cache/yarn" && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +### Post Build +RUN \ + set -x && \ + source /home/jovyan/.conda.init && \ + conda activate .venv && \ + source /home/jovyan/.conda.init && \ + conda activate .venv && \ + # + export VENV=${CONDA_DIR}/envs/.venv && \ + export PATH_TO_LLVM_BUILD=${VENV} && \ + #export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH_TO_LLVM_BUILD/bin:$PATH && \ + export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH && \ + export LD_LIBRARY_PATH=$PATH_TO_LLVM_BUILD/lib:$LD_LIBRARY_PATH && \ + echo "export VENV=$VENV" >> ~/.profile && \ + echo "export PATH=$PATH" >> ~/.profile && \ + echo "export EDITOR=emacs" >> ~/.profile && \ + # + # Build CppInterOp + # + sys_incs=$(LC_ALL=C c++ -xc++ -E -v /dev/null 2>&1 | LC_ALL=C sed -ne '/starts here/,/End of/p' | LC_ALL=C sed '/^ /!d' | cut -c2- | tr '\n' ':') && \ + export CPLUS_INCLUDE_PATH="${PATH_TO_LLVM_BUILD}/include/llvm:${PATH_TO_LLVM_BUILD}/include/clange:$CPLUS_INCLUDE_PATH:${sys_incs%:}" && \ + git clone https://github.com/compiler-research/CppInterOp.git && \ + export CB_PYTHON_DIR="$PWD/cppyy-backend/python" && \ + export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend" && \ + cd CppInterOp && \ + mkdir build && \ + cd build && \ + export CPPINTEROP_BUILD_DIR=$PWD && \ + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_CLING=OFF -DUSE_REPL=ON -DLLVM_DIR=$PATH_TO_LLVM_BUILD -DLLVM_CONFIG_EXTRA_PATH_HINTS=${PATH_TO_LLVM_BUILD}/lib -DLLVM_USE_LINKER=gold -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR .. && \ + cmake --build . --parallel $(nproc --all) && \ + #make install -j$(nproc --all) + export CPLUS_INCLUDE_PATH="$CPPINTEROP_DIR/include:$CPLUS_INCLUDE_PATH" && \ + export LD_LIBRARY_PATH="${VENV}/lib:${CONDA_DIR}/lib:$CPPINTEROP_DIR/lib:$LD_LIBRARY_PATH" && \ + echo "export LD_LIBRARY_PATH=$CPPINTEROP_DIR/lib:$LD_LIBRARY_PATH" >> ~/.profile && \ + cd ../.. && \ + # + # Build and Install cppyy-backend + # + git clone https://github.com/compiler-research/cppyy-backend.git && \ + cd cppyy-backend && \ + mkdir -p $CPPINTEROP_DIR/lib build && cd build && \ + # Install CppInterOp + (cd $CPPINTEROP_BUILD_DIR && cmake --build . --target install --parallel $(nproc --all)) && \ + # Build and Install cppyy-backend + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCppInterOp_DIR=$CPPINTEROP_DIR .. && \ + cmake --build . --parallel $(nproc --all) && \ + cp libcppyy-backend.so $CPPINTEROP_DIR/lib/ && \ + cd ../.. && \ + # + # Build and Install CPyCppyy + # + # Install CPyCppyy + git clone https://github.com/compiler-research/CPyCppyy.git && \ + cd CPyCppyy && \ + mkdir build && cd build && \ + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && \ + cmake --build . --parallel $(nproc --all) && \ + export CPYCPPYY_DIR=$PWD && \ + cd ../.. && \ + # + # Build and Install cppyy + # + # Install cppyy + git clone https://github.com/compiler-research/cppyy.git && \ + cd cppyy && \ + python -m pip install --upgrade . --no-deps && \ + cd .. && \ + # Run cppyy + #TODO: Fix cppyy path (/home/jovyan) to path to installed module + export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR:/home/jovyan && \ + echo "export PYTHONPATH=$PYTHONPATH" >> ~/.profile && \ + export CPLUS_INCLUDE_PATH="/home/jovyan/CPyCppyy/include/:$CPLUS_INCLUDE_PATH" && \ + # FIXME: Remove the hardcoded version of python here. + export CPLUS_INCLUDE_PATH="/home/jovyan/clad/include:$CPLUS_INCLUDE_PATH" && \ + export CPLUS_INCLUDE_PATH="${VENV}/include:${VENV}/include/python3.10:$CPLUS_INCLUDE_PATH" && \ + python -c "import cppyy" && \ + # + # Build and Install xeus-cpp + # + mkdir build && \ + cd build && \ + echo "export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> ~/.profile && \ + ##echo "conda activate .venv" >> ~/.profile + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$KERNEL_PYTHON_PREFIX -DCMAKE_INSTALL_PREFIX=$KERNEL_PYTHON_PREFIX -DCMAKE_INSTALL_LIBDIR=lib -DCPPINTEROP_DIR=$CPPINTEROP_BUILD_DIR .. && \ + make install -j$(nproc --all) && \ + cd .. && \ + # + # Build and Install Clad + # + git clone --depth=1 https://github.com/vgvassilev/clad.git && \ + cd clad && \ + mkdir build && \ + cd build && \ + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. -DClang_DIR=${PATH_TO_LLVM_BUILD}/lib/cmake/clang/ -DLLVM_DIR=${PATH_TO_LLVM_BUILD}/lib/cmake/llvm/ -DCMAKE_INSTALL_PREFIX=${CONDA_DIR} -DLLVM_EXTERNAL_LIT="$(which lit)" && \ + #make -j$(nproc --all) && \ + make && \ + make install && \ + # + # xtensor + # + git clone https://github.com/xtensor-stack/xtensor.git && \ + cd xtensor && \ + mkdir build && cd build && \ + cmake -DCMAKE_INSTALL_PREFIX=$KERNEL_PYTHON_PREFIX .. && \ + make install && \ + # + # Fixes and patches + # + # Web password and token set to "" + echo "c.NotebookApp.token = ''" >> /home/jovyan/.jupyter/jupyter_notebook_config.py && \ + echo "c.NotebookApp.password = ''" >> /home/jovyan/.jupyter/jupyter_notebook_config.py && \ + # Patch /opt/conda/share/jupyter/kernels/python3/kernel.json to use .venv + k="/opt/conda/share/jupyter/kernels/python3/kernel.json" && \ + jq ".argv[0] = \"${VENV}/bin/python\"" $k > $k.$$.tmp && mv $k.$$.tmp $k diff --git a/bash-docker.sh b/bash-docker.sh new file mode 100755 index 00000000..52d413d2 --- /dev/null +++ b/bash-docker.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "$#" -eq 0 ]; then + user="root" +else + user="$1" +fi + +docker exec -u "$user" -t -i xeus-cpp-c /bin/bash --login diff --git a/include/xcpp/xdisplay.hpp b/include/xcpp/xdisplay.hpp index 1cb1d443..05acdccf 100644 --- a/include/xcpp/xdisplay.hpp +++ b/include/xcpp/xdisplay.hpp @@ -14,6 +14,8 @@ #include "xcpp/xmime.hpp" +#include "xeus/xinterpreter.hpp" + namespace nl = nlohmann; namespace xcpp diff --git a/include/xeus-cpp/xinterpreter.hpp b/include/xeus-cpp/xinterpreter.hpp index bec47613..833e9f3e 100644 --- a/include/xeus-cpp/xinterpreter.hpp +++ b/include/xeus-cpp/xinterpreter.hpp @@ -16,7 +16,8 @@ #include #include -#include +//#include +#include "clang/Interpreter/CppInterOp.h" #include @@ -78,7 +79,7 @@ namespace xcpp std::string get_stdopt(int argc, const char* const* argv); - std::unique_ptr m_interpreter; +// std::unique_ptr m_interpreter; std::string m_version; diff --git a/remove-docker.sh b/remove-docker.sh new file mode 100755 index 00000000..15a5b419 --- /dev/null +++ b/remove-docker.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker rm xeus-cpp-c -f +docker rmi xeus-cpp diff --git a/run-docker.sh b/run-docker.sh new file mode 100755 index 00000000..e64d7116 --- /dev/null +++ b/run-docker.sh @@ -0,0 +1,15 @@ +#!/bin/bash +docker container run --rm -i hadolint/hadolint hadolint - < Dockerfile + +jupyter-repo2docker \ + --no-run \ + --user-name=jovyan \ + --image-name xeus-cpp \ + . + +#docker run --gpus all --publish 8888:8888 --name xeus-cpp-c -i -t xeus-cpp "start-notebook.sh" +docker run --rm --runtime=nvidia --gpus all --publish 8888:8888 --name xeus-cpp-c -i -t xeus-cpp "start-notebook.sh" + +# --editable \ +# --ref InterOpIntegration \ +# https://github.com/alexander-penev/xeus-cpp.git \ diff --git a/share/jupyter/kernels/clad-xcpp17/kernel.json.in b/share/jupyter/kernels/clad-xcpp17/kernel.json.in new file mode 100644 index 00000000..bd8836ad --- /dev/null +++ b/share/jupyter/kernels/clad-xcpp17/kernel.json.in @@ -0,0 +1,18 @@ +{ + "display_name": "C++17 (+Clad)", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, + "argv": [ + "@CMAKE_VENV_PATH@/bin/xcpp", + "-f", + "{connection_file}", + "-fplugin=/opt/conda/lib/clad.so", + "-std=c++17"@CMAKE_OMP@ + ], + "language": "C++17", + "metadata": {"debugger": false} +} diff --git a/share/jupyter/kernels/clad-xcpp17/logo-32x32.png b/share/jupyter/kernels/clad-xcpp17/logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c458544bb83b9e3ff4d38f5758bda10ceebe8 GIT binary patch literal 1520 zcmV`fj+1!di&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Ml#roqP}$Ii|6~@9 zgNbc}RC*dRc_LiACzpgdN*gZ~7FXn!l=Y;kD|Vg0l<|=+KRtJ0vaon|+hG{G0-hk~ zbq_#qs6>Fg6%yY`eD(140fw4}#>{=+9QDsFE}POjNAEP4@kr`dXx8xa2c7_>z~b$P zaiOH{mKJUVv~82ns>%Utso|r`h5(Ks)?3Hw=Hits1J`YNDx3>2FV?zKXw4(dBg|(Lakaa%);P)BR zI&_^8&J4SJwE@#seu|3vHeNR(1O}58i#C6aoriPyhAkUOo>`&TwnH-VT?qHem7g?@&AHy4~HHcmmX z0Y9d0vc2R8GdIoy$Y*f#hzvsr9-A7Al)3SkdG82_T=?>QrMwZJp2$P`u`AFS`Ry+C z0}jA8Oy$-=sqFuVOb`B`3aUty%+G zw0aa)HR00L2AsTd4P~_+%YAY{u^cB;&pT>#{zzsi?*V1f0Q9?Ac^jf0z*=Oi-w*U% zeZqfE&ffSixZlJE{COY1q`zSCtg48YDf3#1s>Xz0EVW4l3(k%yc&dTM&Ov8I5ddI_fLW^b2))2{{wp=5@|3jCCMo0QDlirHHt z!O^V%^?cD3C9809{q0#aWrv40&H!Q30P23(93gK)EKkF+Ww(FXoDGyp24|S30SGLd zBnQB-f5Qo-zzoPa2B&s--Wx$Mnb!b>Z|UsM5Mc$5r~bA}XYDX!^B9O|-^J4ewV+t% zEPVAO2A6 + + + + + + + + + + + + + + + + diff --git a/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in b/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in new file mode 100644 index 00000000..904a375c --- /dev/null +++ b/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in @@ -0,0 +1,18 @@ +{ + "display_name": "CppInterOp (C++17)", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, + "argv": [ + "@CMAKE_VENV_PATH@/bin/xcpp", + "-f", + "{connection_file}", + "-cuda", + "-std=c++17"@CMAKE_OMP@ + ], + "language": "CUDA", + "metadata": {"debugger": false} +} diff --git a/share/jupyter/kernels/omp-xcpp17/kernel.json.in b/share/jupyter/kernels/omp-xcpp17/kernel.json.in new file mode 100644 index 00000000..3583b275 --- /dev/null +++ b/share/jupyter/kernels/omp-xcpp17/kernel.json.in @@ -0,0 +1,18 @@ +{ + "display_name": "C++17 (+OpenMP)", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, + "argv": [ + "@CMAKE_VENV_PATH@/bin/xcpp", + "-f", + "{connection_file}", + "-fopenmp", + "-std=c++17" + ], + "language": "C++17", + "metadata": {"debugger": false} +} diff --git a/share/jupyter/kernels/omp-xcpp17/logo-32x32.png b/share/jupyter/kernels/omp-xcpp17/logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c458544bb83b9e3ff4d38f5758bda10ceebe8 GIT binary patch literal 1520 zcmV`fj+1!di&IS(aK;ELYw|L~OnvC0l61ks3o346fp`H$NMM0omj!m; z_kH@H6w9)^K>k0T=Y7uqf1dN4=RHR-3_SCt%^Kb<)&MU7;Zlg5y2-oY^X2I+L-i$w zx?#n~wk$=V07O#1r4C?Ac(>)lg4HQKH(Wq=p)FksC6OXrNjh{uNT#gE{aMoakX3XTk{(FnV(Oe z@2s~w9%t9`^9n$i$CVI>+-wrO`tbNclf$)>dTY@HMq2(mOewM3E;b(gqU`v@`quU| z&?f^Z0J=#DSPf5QBrs{LbN<3m*yuT1l|^h>)_7v6XNK(hD<51m$Gp!i2?Hs zFyZD1GE)5`@AeoRtZC!y-<<#?jkYj5HI~Q-Uw67;ILoSQ?bVI#nSnTh3V0+f&aX}z z+PcZ#S4T&u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`3aUty%+G zw0aa)HR00L2AsTd4P~_+%YAY{u^cB;&pT>#{zzsi?*V1f0Q9?Ac^jf0z*=Oi-w*U% zeZqfE&ffSixZlJE{COY1q`zSCtg48YDf3#1s>Xz0EVW4l3(k%yc&dTM&Ov8I5ddI_fLW^b2))2{{wp=5@|3jCCMo0QDlirHHt z!O^V%^?cD3C9809{q0#aWrv40&H!Q30P23(93gK)EKkF+Ww(FXoDGyp24|S30SGLd zBnQB-f5Qo-zzoPa2B&s--Wx$Mnb!b>Z|UsM5Mc$5r~bA}XYDX!^B9O|-^J4ewV+t% zEPVAO2A6 + + + + + + + + + + + + + + + + diff --git a/share/jupyter/kernels/xcpp/kernel.json.in b/share/jupyter/kernels/xcpp/kernel.json.in index f053f27c..556bd429 100644 --- a/share/jupyter/kernels/xcpp/kernel.json.in +++ b/share/jupyter/kernels/xcpp/kernel.json.in @@ -1,11 +1,17 @@ { - "display_name": "cpp 14 (xcpp)", + "display_name": "C++17 (xcpp)", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, "argv": [ - "@XEUS_CPP_KERNELSPEC_PATH@xcpp", + "@CMAKE_VENV_PATH@/bin/xcpp", "-f", - "{connection_file}" + "{connection_file}", + "-std=c++17"@CMAKE_OMP@ ], "language": "cpp", - "metadata": {"debugger": false - } + "metadata": {"debugger": false} } diff --git a/share/jupyter/kernels/xcpp11/kernel.json.in b/share/jupyter/kernels/xcpp11/kernel.json.in new file mode 100644 index 00000000..c7440e47 --- /dev/null +++ b/share/jupyter/kernels/xcpp11/kernel.json.in @@ -0,0 +1,17 @@ +{ + "display_name": "C++11", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, + "argv": [ + "@CMAKE_VENV_PATH@/bin/xcpp", + "-f", + "{connection_file}", + "-std=c++11"@CMAKE_OMP@ + ], + "language": "C++11", + "metadata": {"debugger": false} +} diff --git a/share/jupyter/kernels/xcpp11/logo-32x32.png b/share/jupyter/kernels/xcpp11/logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c458544bb83b9e3ff4d38f5758bda10ceebe8 GIT binary patch literal 1520 zcmV`fj+1!di&IS(aK;ELYw|L~OnvC0l61ks3o346fp`H$NMM0omj!m; z_kH@H6w9)^K>k0T=Y7uqf1dN4=RHR-3_SCt%^Kb<)&MU7;Zlg5y2-oY^X2I+L-i$w zx?#n~wk$=V07O#1r4C?Ac(>)lg4HQKH(Wq=p)FksC6OXrNjh{uNT#gE{aMoakX3XTk{(FnV(Oe z@2s~w9%t9`^9n$i$CVI>+-wrO`tbNclf$)>dTY@HMq2(mOewM3E;b(gqU`v@`quU| z&?f^Z0J=#DSPf5QBrs{LbN<3m*yuT1l|^h>)_7v6XNK(hD<51m$Gp!i2?Hs zFyZD1GE)5`@AeoRtZC!y-<<#?jkYj5HI~Q-Uw67;ILoSQ?bVI#nSnTh3V0+f&aX}z z+PcZ#S4T&u_g`COos*JNt-LrdktqoyXmNVH?|fTz?!E6TCllfg2`C^uOkv8n5k5AL zX0Ua?FL^KAJv!TdtaGQ2w_aYgqb#wjN1GgsIHZ82Q5MW5-}n!o?V!!&PYxJuo$f<> zZ8eh$O1vq(#>ehTqQ`6S!^ukkJbCX#nw?#gRyBqe5M@>UY!{l{eztCpX4`+NHoVz+ zHKVWnvAdF3yXa0lngKwhMP*IaRN7oU2;jh}#^3@%K}wpARsDJXWX;)VB4aevn}+2l zpa91Jd7cm#!S6Ng?hBV1Dt@V`yj#=sYf*RD4b1BAM2(t+qKpCfrlKCeCj~+XzZ58e z1k|^7q3OO4>OINP#*q^h&I5;z&CxX7(q~CQ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json.in b/share/jupyter/kernels/xcpp14/kernel.json.in new file mode 100644 index 00000000..3c9a47f4 --- /dev/null +++ b/share/jupyter/kernels/xcpp14/kernel.json.in @@ -0,0 +1,20 @@ +{ + "display_name": "C++14", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, + "argv": [ + "@CMAKE_VENV_PATH@/bin/xcpp", + "-f", + "{connection_file}", + "-std=c++14", + "-fno-exceptions", + "-O2", + "-v"@CMAKE_OMP@ + ], + "language": "C++14", + "metadata": {"debugger": false} +} diff --git a/share/jupyter/kernels/xcpp14/logo-32x32.png b/share/jupyter/kernels/xcpp14/logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c458544bb83b9e3ff4d38f5758bda10ceebe8 GIT binary patch literal 1520 zcmV`fj+1!di&IS(aK;ELYw|L~OnvC0l61ks3o346fp`H$NMM0omj!m; z_kH@H6w9)^K>k0T=Y7uqf1dN4=RHR-3_SCt%^Kb<)&MU7;Zlg5y2-oY^X2I+L-i$w zx?#n~wk$=V07O#1r4C?Ac(>)lg4HQKH(Wq=p)FksC6OXrNjh{uNT#gE{aMoakX3XTk{(FnV(Oe z@2s~w9%t9`^9n$i$CVI>+-wrO`tbNclf$)>dTY@HMq2(mOewM3E;b(gqU`v@`quU| z&?f^Z0J=#DSPf5QBrs{LbN<3m*yuT1l|^h>)_7v6XNK(hD<51m$Gp!i2?Hs zFyZD1GE)5`@AeoRtZC!y-<<#?jkYj5HI~Q-Uw67;ILoSQ?bVI#nSnTh3V0+f&aX}z z+PcZ#S4T&u_g`COos*JNt-LrdktqoyXmNVH?|fTz?!E6TCllfg2`C^uOkv8n5k5AL zX0Ua?FL^KAJv!TdtaGQ2w_aYgqb#wjN1GgsIHZ82Q5MW5-}n!o?V!!&PYxJuo$f<> zZ8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yc&dTM&Ov8I5ddI_fLW^b2))2{{wp=5@|3jCCMo0QDlirHHt z!O^V%^?cD3C9809{q0#aWrv40&H!Q30P23(93gK)EKkF+Ww(FXoDGyp24|S30SGLd zBnQB-f5Qo-zzoPa2B&s--Wx$Mnb!b>Z|UsM5Mc$5r~bA}XYDX!^B9O|-^J4ewV+t% zEPVAO2A6 + + + + + + + + + + + + + + + + diff --git a/share/jupyter/kernels/xcpp17/kernel.json.in b/share/jupyter/kernels/xcpp17/kernel.json.in new file mode 100644 index 00000000..ee116fc5 --- /dev/null +++ b/share/jupyter/kernels/xcpp17/kernel.json.in @@ -0,0 +1,17 @@ +{ + "display_name": "C++17", + "env": { + "CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@", + "PATH":"@CMAKE_PATH@", + "LD_LIBRARY_PATH":"@CMAKE_LD_LIBRARY_PATH@", + "PYTHONPATH":"@CMAKE_PYTHONPATH@" + }, + "argv": [ + "@CMAKE_VENV_PATH@/bin/xcpp", + "-f", + "{connection_file}", + "-std=c++17"@CMAKE_OMP@ + ], + "language": "C++17", + "metadata": {"debugger": false} +} diff --git a/share/jupyter/kernels/xcpp17/logo-32x32.png b/share/jupyter/kernels/xcpp17/logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c458544bb83b9e3ff4d38f5758bda10ceebe8 GIT binary patch literal 1520 zcmV`fj+1!di&IS(aK;ELYw|L~OnvC0l61ks3o346fp`H$NMM0omj!m; z_kH@H6w9)^K>k0T=Y7uqf1dN4=RHR-3_SCt%^Kb<)&MU7;Zlg5y2-oY^X2I+L-i$w zx?#n~wk$=V07O#1r4C?Ac(>)lg4HQKH(Wq=p)FksC6OXrNjh{uNT#gE{aMoakX3XTk{(FnV(Oe z@2s~w9%t9`^9n$i$CVI>+-wrO`tbNclf$)>dTY@HMq2(mOewM3E;b(gqU`v@`quU| z&?f^Z0J=#DSPf5QBrs{LbN<3m*yuT1l|^h>)_7v6XNK(hD<51m$Gp!i2?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0vc2R8GdIoy$Y*f#hzvsr9-A7Al)3SkdG82_T=?>QrMwZJp2$P`u`AFS`Ry+C z0}jA8Oy$-=sqFuVOb`B`3aUty%+G zw0aa)HR00L2AsTd4P~_+%YAY{u^cB;&pT>#{zzsi?*V1f0Q9?Ac^jf0z*=Oi-w*U% zeZqfE&ffSixZlJE{COY1q`zSCtg48YDf3#1s>Xz0EVW4l3(k%yc&dTM&Ov8I5ddI_fLW^b2))2{{wp=5@|3jCCMo0QDlirHHt z!O^V%^?cD3C9809{q0#aWrv40&H!Q30P23(93gK)EKkF+Ww(FXoDGyp24|S30SGLd zBnQB-f5Qo-zzoPa2B&s--Wx$Mnb!b>Z|UsM5Mc$5r~bA}XYDX!^B9O|-^J4ewV+t% zEPVAO2A6 + + + + + + + + + + + + + + + + diff --git a/src/main.cpp b/src/main.cpp index 83f6f73f..31a18aba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,73 @@ #include "xeus-cpp/xinterpreter.hpp" #include "xeus-cpp/xutils.hpp" +#ifdef __GNUC__ +void handler(int sig) +{ + void* array[10]; + + // get void*'s for all entries on the stack + std::size_t size = backtrace(array, 10); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} +#endif + +void stop_handler(int /*sig*/) +{ + exit(0); +} + +bool should_print_version(int argc, char* argv[]) +{ + for (int i = 0; i < argc; ++i) + { + if (std::string(argv[i]) == "--version") + { + return true; + } + } + return false; +} + +std::string extract_filename(int& argc, char* argv[]) +{ + std::string res = ""; + for (int i = 0; i < argc; ++i) + { + if ((std::string(argv[i]) == "-f") && (i + 1 < argc)) + { + res = argv[i + 1]; + for (int j = i; j < argc - 2; ++j) + { + argv[j] = argv[j + 2]; + } + argc -= 2; + break; + } + } + return res; +} + +using interpreter_ptr = std::unique_ptr; + +interpreter_ptr build_interpreter(int argc, char** argv) +{ + std::vector interpreter_args; + for (int i = 1; i < argc; i++) { + if (argv[i] == "-f") { + i++; // skip the value of -f which is a json file. + continue; + } + interpreter_args.push_back(argv[i]); + } + interpreter_ptr interp_ptr = interpreter_ptr(new xcpp::interpreter(interpreter_args.size(), interpreter_args.data())); + return interp_ptr; +} + int main(int argc, char* argv[]) { if (xcpp::should_print_version(argc, argv)) @@ -97,8 +164,8 @@ int main(int argc, char* argv[]) xeus::make_xserver_zmq, xeus::make_in_memory_history_manager(), xeus::make_console_logger( - xeus::xlogger::msg_type, - xeus::make_file_logger(xeus::xlogger::content, "xeus.log") + xeus::xlogger::msg_type, + xeus::make_file_logger(xeus::xlogger::content, "xeus.log") ) ); diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 09fb27ce..0fe2fced 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -28,20 +28,6 @@ #include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -//#include - - - #include #include // required before including llvm/ExecutionEngine/Orc/LLJIT.h because missing llvm/Object/SymbolicFile.h #include @@ -52,6 +38,7 @@ #include #include +/* std::string DiagnosticOutput; llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput); auto DiagPrinter = std::make_unique(DiagnosticsOS, new clang::DiagnosticOptions()); @@ -119,9 +106,11 @@ process_code(clang::Interpreter& Interp, const std::string& code, llvm::raw_stri } return false; } +*/ using Args = std::vector; +/* static std::unique_ptr create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client = nullptr) { @@ -130,21 +119,30 @@ create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client Args ClangArgs = {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end()); - auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs)); + auto CI = llvm::cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs)); if (Client) { - CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false); + CI->getDiagnostics().setClient(Client, / *ShouldOwnClient=* /false); } - return cantFail(clang::Interpreter::create(std::move(CI))); + return llvm::cantFail(clang::Interpreter::create(std::move(CI))); +} +*/ +void* createInterpreter(const Args &ExtraArgs = {}) { + Args ClangArgs = {/*"-xc++"*/}; + ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end()); + // FIXME: We should process the kernel input options and conditionally pass + // the gpu args here. + return Cpp::CreateInterpreter(ClangArgs, {"-cuda"}); } +/* static void inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAddr, clang::Interpreter& Interp) { using namespace llvm; using namespace llvm::orc; - auto Symbol = Interp.getSymbolAddress(LinkerMangledName); //, /*IncludeFromHost=*/true); + auto Symbol = Interp.getSymbolAddress(LinkerMangledName); //, / *IncludeFromHost=* /true); if (Error Err = Symbol.takeError()) { @@ -188,7 +186,8 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed3: "); } } - +*/ +/* namespace utils { void AddIncludePath(llvm::StringRef Path, clang::HeaderSearchOptions& HOpts) @@ -206,7 +205,7 @@ namespace utils return; } - HOpts.AddPath(Path, clang::frontend::Angled, false /* IsFramework */, true /* IsSysRootRelative */); + HOpts.AddPath(Path, clang::frontend::Angled, false / * IsFramework * /, true / * IsSysRootRelative * /); if (HOpts.Verbose) { @@ -243,13 +242,14 @@ void AddIncludePath(clang::Interpreter& Interp, llvm::StringRef Path) } } } - +*/ using namespace std::placeholders; namespace xcpp { void interpreter::configure_impl() { +/* // todo: why is error_stream necessary std::string error_message; llvm::raw_string_ostream error_stream(error_message); @@ -258,11 +258,12 @@ namespace xcpp std::string code = "xeus::register_interpreter(static_cast((void*)" + std::to_string(intptr_t(this)) + "));"; process_code(*m_interpreter, code.c_str(), error_stream); +*/ } interpreter::interpreter(int argc, const char* const* argv) - : m_interpreter(create_interpreter(Args() /*argv + 1, argv + argc)*/, DiagPrinter.get())) - , m_version(get_stdopt(argc, argv)) +// : m_interpreter(std::move(create_interpreter(Args() /*argv + 1, argv + argc)*/, DiagPrinter.get()))) + : m_version(get_stdopt(argc, argv)) , // Extract C++ language standard version from command-line option xmagics() , p_cout_strbuf(nullptr) @@ -270,7 +271,9 @@ namespace xcpp , m_cout_buffer(std::bind(&interpreter::publish_stdout, this, _1)) , m_cerr_buffer(std::bind(&interpreter::publish_stderr, this, _1)) { + createInterpreter(Args(argv, argv + argc)); redirect_output(); + // Bootstrap the execution engine init_includes(); init_preamble(); init_magic(); @@ -322,13 +325,25 @@ namespace xcpp // Scope guard performing the temporary redirection of input requests. auto input_guard = input_redirection(allow_stdin); - std::string error_message; - llvm::raw_string_ostream error_stream(error_message); + std::string err; + std::string out; + // Attempt normal evaluation - try { - compilation_result = process_code(*m_interpreter, code, error_stream); + std::string exp = R"(\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)"; + std::regex re(R"((\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)(\.?)*$)"); + auto inspect_request = is_inspect_request(code, re); + if (inspect_request.first) + inspect(inspect_request.second[0], kernel_res, *m_interpreter); + + Cpp::BeginStdStreamCapture(Cpp::kStdErr); + Cpp::BeginStdStreamCapture(Cpp::kStdOut); + //compilation_result = Cpp::Process(block.c_str()); + compilation_result = Cpp::Process(code.c_str()); + out = Cpp::EndStdStreamCapture(); + err = Cpp::EndStdStreamCapture(); + std::cout << out; } catch (std::exception& e) { @@ -345,12 +360,13 @@ namespace xcpp if (compilation_result) { errorlevel = 1; - ename = "Error :"; - evalue = error_stream.str(); + ename = "Error"; +// evalue = error_stream.str(); + std::cerr << err; } - error_stream.str().clear(); - DiagnosticsOS.str().clear(); +// error_stream.str().clear(); +// DiagnosticsOS.str().clear(); // Flush streams std::cout << std::flush; @@ -551,8 +567,8 @@ namespace xcpp // Inject versions of printf and fprintf that output to std::cout // and std::cerr (see implementation above). - inject_symbol("printf", llvm::pointerToJITTargetAddress(printf_jit), *m_interpreter); - inject_symbol("fprintf", llvm::pointerToJITTargetAddress(fprintf_jit), *m_interpreter); +// inject_symbol("printf", llvm::pointerToJITTargetAddress(printf_jit), *m_interpreter); +// inject_symbol("fprintf", llvm::pointerToJITTargetAddress(fprintf_jit), *m_interpreter); } void interpreter::restore_output() @@ -576,7 +592,7 @@ namespace xcpp void interpreter::init_includes() { - AddIncludePath(*m_interpreter, xtl::prefix_path() + "/include/"); +// AddIncludePath(*m_interpreter, xtl::prefix_path() + "/include/"); } void interpreter::init_preamble() From 10d02c4733157c0a2241aff1e03e2fd437a5044c Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 2 Oct 2023 14:06:52 +0000 Subject: [PATCH 02/69] Source cleanup --- CMakeLists.txt | 4 - include/xeus-cpp/xinterpreter.hpp | 2 - src/xinterpreter.cpp | 297 +----------------------------- 3 files changed, 9 insertions(+), 294 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c977704..c700e68a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,7 +161,6 @@ if(EMSCRIPTEN) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") endif() -#find_package(Clang REQUIRED) find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") find_package(argparse REQUIRED) find_package(pugixml REQUIRED) @@ -301,7 +300,6 @@ macro(xeus_cpp_create_target target_name linkage output_name) set(XEUS_CPP_XEUS_TARGET xeus-static) endif () -## target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangInterpreter pugixml argparse::argparse xtl) target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl) if (WIN32 OR CYGWIN) # @@ -418,7 +416,6 @@ endif () # Install xcpp if (XEUS_CPP_BUILD_EXECUTABLE) install(TARGETS xcpp -# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) RUNTIME DESTINATION ${CMAKE_VENV_PATH}/bin) endif(XEUS_CPP_BUILD_EXECUTABLE) @@ -429,7 +426,6 @@ if(XEUS_CPP_BUILD_EXECUTABLE OR EMSCRIPTEN) set(KERNELSPEC_DIR ${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels) install(DIRECTORY ${KERNELSPEC_DIR} DESTINATION ${XJUPYTER_DATA_DIR} -# DESTINATION ${CMAKE_INSTALL_PREFIX}/${XJUPYTER_DATA_DIR} PATTERN "*.in" EXCLUDE) # Extra path for installing Jupyter kernelspec diff --git a/include/xeus-cpp/xinterpreter.hpp b/include/xeus-cpp/xinterpreter.hpp index 833e9f3e..92ccbbe8 100644 --- a/include/xeus-cpp/xinterpreter.hpp +++ b/include/xeus-cpp/xinterpreter.hpp @@ -79,8 +79,6 @@ namespace xcpp std::string get_stdopt(int argc, const char* const* argv); -// std::unique_ptr m_interpreter; - std::string m_version; xmagics_manager xmagics; diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 0fe2fced..78ee99b5 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -7,262 +7,41 @@ * The full license is in the file LICENSE, distributed with this software. * ************************************************************************************/ -#include "xeus-cpp/xinterpreter.hpp" - -#include "xinput.hpp" -#include "xinspect.hpp" -// #include "xmagics/executable.hpp" -// #include "xmagics/execution.hpp" -#include "xmagics/os.hpp" -#include "xparser.hpp" -#include "xsystem.hpp" - -#include - -#include "xeus-cpp/xbuffer.hpp" -#include "xeus-cpp/xeus_cpp_config.hpp" - -#include "xeus-cpp/xmagics.hpp" - -#include - -#include - #include #include // required before including llvm/ExecutionEngine/Orc/LLJIT.h because missing llvm/Object/SymbolicFile.h #include #include #include -#include #include #include #include -/* -std::string DiagnosticOutput; -llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput); -auto DiagPrinter = std::make_unique(DiagnosticsOS, new clang::DiagnosticOptions()); +#include -///\returns true on error. -static bool -process_code(clang::Interpreter& Interp, const std::string& code, llvm::raw_string_ostream& error_stream) -{ - - if (code.substr(0, 1) == "?") - { - error_stream << " "; - return true; - } - else { - auto PTU = Interp.Parse(code); - if (!PTU) - { - auto Err = PTU.takeError(); - error_stream << DiagnosticsOS.str(); - // avoid printing the "Parsing failed error" - // llvm::logAllUnhandledErrors(std::move(Err), error_stream, "error: "); - return true; - } - if (PTU->TheModule) - { - llvm::Error ex = Interp.Execute(*PTU); - error_stream << DiagnosticsOS.str(); - if (code.substr(0, 3) == "int") - { - for (clang::Decl* D : PTU->TUPart->decls()) - { - if (clang::VarDecl* VD = llvm::dyn_cast(D)) - { - auto Name = VD->getNameAsString(); - auto Addr = Interp.getSymbolAddress(clang::GlobalDecl(VD)); - if (!Addr) - { - llvm::logAllUnhandledErrors(Addr.takeError(), error_stream, "error: "); - return true; - } - } - } - } - else if (code.substr(0, 16) == "std::vector") - { - for (clang::Decl* D : PTU->TUPart->decls()) - { - if (clang::VarDecl* VD = llvm::dyn_cast(D)) - { - auto Name = VD->getNameAsString(); - auto Addr = Interp.getSymbolAddress(clang::GlobalDecl(VD)); - if (!Addr) - { - llvm::logAllUnhandledErrors(Addr.takeError(), error_stream, "error: "); - return true; - } - } - } - } +#include - llvm::logAllUnhandledErrors(std::move(ex), error_stream, "error: "); - return false; - } - } - return false; -} -*/ +#include "xeus-cpp/xbuffer.hpp" +#include "xeus-cpp/xeus_cpp_config.hpp" using Args = std::vector; -/* -static std::unique_ptr -create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client = nullptr) -{ - llvm::InitializeNativeTarget(); - llvm::InitializeNativeTargetAsmPrinter(); - - Args ClangArgs = {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; - ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end()); - auto CI = llvm::cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs)); - if (Client) - { - CI->getDiagnostics().setClient(Client, / *ShouldOwnClient=* /false); - } - return llvm::cantFail(clang::Interpreter::create(std::move(CI))); -} -*/ void* createInterpreter(const Args &ExtraArgs = {}) { - Args ClangArgs = {/*"-xc++"*/}; + Args ClangArgs = {/*"-xc++"*/}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end()); // FIXME: We should process the kernel input options and conditionally pass // the gpu args here. return Cpp::CreateInterpreter(ClangArgs, {"-cuda"}); } -/* -static void -inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAddr, clang::Interpreter& Interp) -{ - using namespace llvm; - using namespace llvm::orc; - - auto Symbol = Interp.getSymbolAddress(LinkerMangledName); //, / *IncludeFromHost=* /true); - - if (Error Err = Symbol.takeError()) - { - logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed1: "); - return; - } - - // Nothing to define, we are redefining the same function. FIXME: Diagnose. - if (*Symbol && (JITTargetAddress) *Symbol == KnownAddr) - { - return; - } - - // Let's inject it - bool Inserted; - SymbolMap::iterator It; - static llvm::orc::SymbolMap m_InjectedSymbols; - - llvm::orc::LLJIT* Jit = const_cast(Interp.getExecutionEngine()); - JITDylib& DyLib = Jit->getMainJITDylib(); - - std::tie(It, Inserted) = m_InjectedSymbols.try_emplace( - Jit->getExecutionSession().intern(LinkerMangledName), - JITEvaluatedSymbol(KnownAddr, JITSymbolFlags::Exported) - ); - assert(Inserted && "Why wasn't this found in the initial Jit lookup?"); - - // We want to replace a symbol with a custom provided one. - if (Symbol && KnownAddr) - { - // The symbol be in the DyLib or in-process. - if (auto Err = DyLib.remove({It->first})) - { - logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed2: "); - return; - } - } - - if (Error Err = DyLib.define(absoluteSymbols({*It}))) - { - logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed3: "); - } -} -*/ -/* -namespace utils -{ - void AddIncludePath(llvm::StringRef Path, clang::HeaderSearchOptions& HOpts) - { - bool Exists = false; - for (const clang::HeaderSearchOptions::Entry& E : HOpts.UserEntries) - { - if ((Exists = E.Path == Path)) - { - break; - } - } - if (Exists) - { - return; - } - - HOpts.AddPath(Path, clang::frontend::Angled, false / * IsFramework * /, true / * IsSysRootRelative * /); - - if (HOpts.Verbose) - { - // std::clog << "Added include paths " << Path << std::endl; - } - } -} - -void AddIncludePath(clang::Interpreter& Interp, llvm::StringRef Path) -{ - clang::CompilerInstance* CI = const_cast(Interp.getCompilerInstance()); - clang::HeaderSearchOptions& HOpts = CI->getHeaderSearchOpts(); - - // Save the current number of entries - std::size_t Idx = HOpts.UserEntries.size(); - utils::AddIncludePath(Path, HOpts); - - clang::Preprocessor& PP = CI->getPreprocessor(); - clang::SourceManager& SM = CI->getSourceManager(); - clang::FileManager& FM = SM.getFileManager(); - clang::HeaderSearch& HSearch = PP.getHeaderSearchInfo(); - const bool isFramework = false; - - // Add all the new entries into Preprocessor - for (; Idx < HOpts.UserEntries.size(); ++Idx) - { - const clang::HeaderSearchOptions::Entry& E = HOpts.UserEntries[Idx]; - if (auto DE = FM.getOptionalDirectoryRef(E.Path)) - { - HSearch.AddSearchPath( - clang::DirectoryLookup(*DE, clang::SrcMgr::C_User, isFramework), - E.Group == clang::frontend::Angled - ); - } - } -} -*/ using namespace std::placeholders; namespace xcpp { void interpreter::configure_impl() { -/* - // todo: why is error_stream necessary - std::string error_message; - llvm::raw_string_ostream error_stream(error_message); - // Expose xinterpreter instance to interpreted C++ - process_code(*m_interpreter, "#include \"xeus/xinterpreter.hpp\"", error_stream); - std::string code = "xeus::register_interpreter(static_cast((void*)" - + std::to_string(intptr_t(this)) + "));"; - process_code(*m_interpreter, code.c_str(), error_stream); -*/ } interpreter::interpreter(int argc, const char* const* argv) -// : m_interpreter(std::move(create_interpreter(Args() /*argv + 1, argv + argc)*/, DiagPrinter.get()))) : m_version(get_stdopt(argc, argv)) , // Extract C++ language standard version from command-line option xmagics() @@ -325,6 +104,7 @@ namespace xcpp // Scope guard performing the temporary redirection of input requests. auto input_guard = input_redirection(allow_stdin); + std::string err; std::string out; @@ -339,7 +119,6 @@ namespace xcpp Cpp::BeginStdStreamCapture(Cpp::kStdErr); Cpp::BeginStdStreamCapture(Cpp::kStdOut); - //compilation_result = Cpp::Process(block.c_str()); compilation_result = Cpp::Process(code.c_str()); out = Cpp::EndStdStreamCapture(); err = Cpp::EndStdStreamCapture(); @@ -361,13 +140,9 @@ namespace xcpp { errorlevel = 1; ename = "Error"; -// evalue = error_stream.str(); std::cerr << err; } -// error_stream.str().clear(); -// DiagnosticsOS.str().clear(); - // Flush streams std::cout << std::flush; std::cerr << std::flush; @@ -514,49 +289,6 @@ namespace xcpp return s; } - static int printf_jit(const char* format, ...) - { - std::va_list args; - va_start(args, format); - - std::string buf = c_format(format, args); - std::cout << buf; - - va_end(args); - - return buf.size(); - } - - static int fprintf_jit(std::FILE* stream, const char* format, ...) - { - std::va_list args; - va_start(args, format); - - int ret; - if (stream == stdout || stream == stderr) - { - std::string buf = c_format(format, args); - if (stream == stdout) - { - std::cout << buf; - } - else if (stream == stderr) - { - std::cerr << buf; - } - ret = buf.size(); - } - else - { - // Just forward to vfprintf. - ret = vfprintf(stream, format, args); - } - - va_end(args); - - return ret; - } - void interpreter::redirect_output() { p_cout_strbuf = std::cout.rdbuf(); @@ -564,20 +296,12 @@ namespace xcpp std::cout.rdbuf(&m_cout_buffer); std::cerr.rdbuf(&m_cerr_buffer); - - // Inject versions of printf and fprintf that output to std::cout - // and std::cerr (see implementation above). -// inject_symbol("printf", llvm::pointerToJITTargetAddress(printf_jit), *m_interpreter); -// inject_symbol("fprintf", llvm::pointerToJITTargetAddress(fprintf_jit), *m_interpreter); } void interpreter::restore_output() { std::cout.rdbuf(p_cout_strbuf); std::cerr.rdbuf(p_cerr_strbuf); - - // No need to remove the injected versions of [f]printf: As they forward - // to std::cout and std::cerr, these are handled implicitly. } void interpreter::publish_stdout(const std::string& s) @@ -592,7 +316,6 @@ namespace xcpp void interpreter::init_includes() { -// AddIncludePath(*m_interpreter, xtl::prefix_path() + "/include/"); } void interpreter::init_preamble() @@ -604,11 +327,9 @@ namespace xcpp void interpreter::init_magic() { - // preamble_manager["magics"].get_cast().register_magic("executable", - // executable(m_interpreter)); - // preamble_manager["magics"].get_cast().register_magic("file", writefile()); - // preamble_manager["magics"].get_cast().register_magic("timeit", - // timeit(&m_interpreter)); + // preamble_manager["magics"].get_cast().register_magic("executable", executable(m_interpreter)); + // preamble_manager["magics"].get_cast().register_magic("file", writefile()); + // preamble_manager["magics"].get_cast().register_magic("timeit", timeit(&m_interpreter)); } std::string interpreter::get_stdopt(int argc, const char* const* argv) From 30db5ced9318e53f6fabf2155f6a8d452ea8bf16 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 3 Oct 2023 18:55:09 +0000 Subject: [PATCH 03/69] Add python magic --- CMakeLists.txt | 55 ++++++---- Dockerfile | 8 +- src/xinterpreter.cpp | 13 +++ src/xmagics/pythonexec.cpp | 210 +++++++++++++++++++++++++++++++++++++ src/xmagics/pythonexec.hpp | 55 ++++++++++ 5 files changed, 316 insertions(+), 25 deletions(-) create mode 100644 src/xmagics/pythonexec.cpp create mode 100644 src/xmagics/pythonexec.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c700e68a..5b661734 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,8 +94,8 @@ option(XEUS_CPP_BUILD_STATIC "Build xeus-cpp static library" ON) OPTION(XEUS_CPP_BUILD_SHARED "Split xcpp build into executable and library" ON) OPTION(XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON) -OPTION(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON) -OPTION(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON) +OPTION(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON) +OPTION(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON) # Test options OPTION(XEUS_CPP_BUILD_TESTS "xeus-cpp test suite" ON) @@ -150,8 +150,11 @@ else() add_compile_options(-fexceptions) endif () -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - if(NOT EMSCRIPTEN) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR + CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR + CMAKE_CXX_COMPILER_ID MATCHES "Intel") + + if(NOT XEUS_CPP_EMSCRIPTEN_WASM_BUILD) add_compile_options(-Wunused-parameter -Wextra -Wreorder) endif() endif () @@ -164,8 +167,8 @@ endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") find_package(argparse REQUIRED) find_package(pugixml REQUIRED) -##set(Python_FIND_VIRTUALENV ONLY) -##find_package(Python COMPONENTS Interpreter Development) +set(Python_FIND_VIRTUALENV ONLY) +find_package(Python COMPONENTS Interpreter Development) # Source files # ============ @@ -194,6 +197,7 @@ set(XEUS_CPP_SRC src/xoptions.cpp src/xparser.cpp src/xutils.cpp + src/xmagics/pythonexec.cpp ) if(EMSCRIPTEN) @@ -357,23 +361,30 @@ if (XEUS_CPP_BUILD_EXECUTABLE) xeus_cpp_set_common_options(xcpp) xeus_cpp_set_kernel_options(xcpp) target_link_libraries(xcpp PRIVATE xeus-zmq) + set_target_properties(xcpp PROPERTIES + ENABLE_EXPORTS 1 + CXX_STANDARD ${CMAKE_CXX_STANDARD}) + target_link_libraries(xcpp PUBLIC xeus-cpp pthread Python::Python) + + ##TODO: We may be need sse RPATH + set_target_properties(xcpp clangCppInterOp PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) + if(APPLE) + target_link_libraries(xcpp PUBLIC -Wl,-w -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup) + elseif(NOT MSVC) + target_link_libraries(xcpp PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files) + endif() -##set_target_properties(xcpp PROPERTIES -## ENABLE_EXPORTS 1 -## CXX_STANDARD ${CMAKE_CXX_STANDARD} -##) -##target_link_libraries(xcpp PUBLIC xeus-cpp pthread Python::Python) -## -###TODO: We may be need sse RPATH -###set_target_properties(xcpp clangCppInterOp PROPERTIES -### INSTALL_RPATH_USE_LINK_PATH TRUE -###) -##if(APPLE) -## target_link_libraries(xcpp PUBLIC -Wl,-w -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup) -##elseif(NOT MSVC) -## target_link_libraries(xcpp PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files) -##endif() - + target_include_directories(xeus-cpp PUBLIC ${Python_INCLUDE_DIRS}) + target_link_libraries(xeus-cpp PUBLIC ${PYTHON_LIBRARIES}) + target_link_libraries(xeus-cpp ${PYTHON_LIBRARIES_Development_Main}) + set_target_properties(xeus-cpp PROPERTIES + PUBLIC_HEADER "${XEUS_CPP_HEADERS}" + COMPILE_DEFINITIONS "XEUS_CPP_EXPORTS" + PREFIX "" + VERSION ${${PROJECT_NAME}_VERSION} + SOVERSION ${XEUS_CPP_VERSION_MAJOR} + OUTPUT_NAME "libxeus-cpp" + CXX_STANDARD ${CMAKE_CXX_STANDARD}) endif() if(EMSCRIPTEN) diff --git a/Dockerfile b/Dockerfile index bf8833a7..8dee1d1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ # https://hub.docker.com/r/jupyter/base-notebook/tags ARG BASE_CONTAINER=jupyter/base-notebook ARG BASE_TAG=latest -ARG BUILD_TYPE=Release +ARG BUILD_TYPE=Debug FROM $BASE_CONTAINER:$BASE_TAG @@ -80,7 +80,7 @@ USER ${NB_UID} ENV NB_PYTHON_PREFIX=${CONDA_DIR} \ KERNEL_PYTHON_PREFIX=${CONDA_DIR} \ # CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/${NB_USER}/include:/home/runner/work/xeus-clang-repl/xeus-clang-repl/clang-dev/clang/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" - CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/${NB_USER}/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" + CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" WORKDIR "${HOME}" @@ -131,6 +131,7 @@ RUN \ cppzmq \ xtl \ 'clangdev>=17' \ + 'llvm-openmp' \ pugixml \ cpp-argparse \ zlib \ @@ -173,7 +174,8 @@ RUN \ # Build CppInterOp # sys_incs=$(LC_ALL=C c++ -xc++ -E -v /dev/null 2>&1 | LC_ALL=C sed -ne '/starts here/,/End of/p' | LC_ALL=C sed '/^ /!d' | cut -c2- | tr '\n' ':') && \ - export CPLUS_INCLUDE_PATH="${PATH_TO_LLVM_BUILD}/include/llvm:${PATH_TO_LLVM_BUILD}/include/clange:$CPLUS_INCLUDE_PATH:${sys_incs%:}" && \ + #/usr/include/x86_64-linux-gnu:/usr/include: + export CPLUS_INCLUDE_PATH="${PATH_TO_LLVM_BUILD}/include/llvm:${PATH_TO_LLVM_BUILD}/include/clang:$CPLUS_INCLUDE_PATH:${sys_incs%:}" && \ git clone https://github.com/compiler-research/CppInterOp.git && \ export CB_PYTHON_DIR="$PWD/cppyy-backend/python" && \ export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend" && \ diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 78ee99b5..0cef2a93 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -23,6 +23,18 @@ #include "xeus-cpp/xbuffer.hpp" #include "xeus-cpp/xeus_cpp_config.hpp" +#include "xeus-cpp/xinterpreter.hpp" +#include "xeus-cpp/xmagics.hpp" + +#include "xinput.hpp" +// #include "xinspect.hpp" +// #include "xmagics/executable.hpp" +// #include "xmagics/execution.hpp" +#include "xmagics/os.hpp" +#include "xmagics/pythonexec.hpp" +#include "xparser.hpp" +#include "xsystem.hpp" + using Args = std::vector; void* createInterpreter(const Args &ExtraArgs = {}) { @@ -330,6 +342,7 @@ namespace xcpp // preamble_manager["magics"].get_cast().register_magic("executable", executable(m_interpreter)); // preamble_manager["magics"].get_cast().register_magic("file", writefile()); // preamble_manager["magics"].get_cast().register_magic("timeit", timeit(&m_interpreter)); + preamble_manager["magics"].get_cast().register_magic("python", pythonexec()); } std::string interpreter::get_stdopt(int argc, const char* const* argv) diff --git a/src/xmagics/pythonexec.cpp b/src/xmagics/pythonexec.cpp new file mode 100644 index 00000000..ccd308c0 --- /dev/null +++ b/src/xmagics/pythonexec.cpp @@ -0,0 +1,210 @@ +//===------------ pythonexec.hpp - Python/C++ Interoperability ------------===// +// +// Licensed under the Apache License v2.0. +// SPDX-License-Identifier: Apache-2.0 +// +// The full license is in the file LICENSE, distributed with this software. +// +//===----------------------------------------------------------------------===// +// +// This file defines the Python/C++ interoperability in which two cells within +// the same notebook can be in a either language. +// +//===----------------------------------------------------------------------===// + +#include "Python.h" + +#include "pythonexec.hpp" +#include "../xparser.hpp" + +#include +#include +#include +#include +#include +#include + +namespace xcpp { +static PyObject *gMainDict = 0; + +void pythonexec::startup() { + static bool isInitialized = false; + if (isInitialized) + return; + + Py_Initialize(); + + PyRun_SimpleString("import sys\nprint(sys.path)"); + + // Import cppyy module + PyObject* cppyyModule = PyImport_ImportModule("cppyy"); + if (!cppyyModule) { + PyErr_Print(); + Py_Finalize(); + return; // Handle import error as needed + } + + PyObject* mainModule = PyImport_AddModule("__main__"); + PyObject_SetAttrString(mainModule, "cppyy", cppyyModule); + Py_XDECREF(cppyyModule); + isInitialized = true; + // gMainDict = PyModule_GetDict(mainModule); + // Py_INCREF(gMainDict); + // if (!gMainDict) + // printf("Could not add module __main__"); + + + // // Retrieve the dictionary of cppyy module + // PyObject* cppyyDict = PyModule_GetDict(cppyyModule); + // Py_DECREF(cppyyModule); + // if (!cppyyDict) { + // PyErr_Print(); + // Py_Finalize(); + // return; // Handle retrieval error as needed + // } + + // // Add cppyyDict to gMainDict (if needed for further usage) + // PyDict_Update(gMainDict, cppyyDict); + + // Py_DECREF(cppyyDict); + // PyRun_SimpleString("import cppyy"); +} + +argparser pythonexec::get_options() { + argparser argpars{"python", "Start executing Python Cell"}; + return argpars; +} + +void pythonexec::execute(std::string &line, std::string &cell) { + // std::istringstream iss(line); + // std::vector results((std::istream_iterator(iss)), + // std::istream_iterator()); + startup(); + +// auto argpars = get_options(); +// argpars.parse(line); + + std::string code; + + code += cell; + if (trim(code).empty()) + return; + // PyRun_SimpleString( + // "globals_copy_lists = " + // "globals().copy()\nfirst_dict_ints={k:globals_copy_lists[k] for k in " + // "set(globals_copy_lists) if type(globals_copy_lists[k]) == " + // "int}\nfirst_dict_lists={k:globals_copy_lists[k] for k in " + // "set(globals_copy_lists) if type(globals_copy_lists[k]) == list}"); + + // PyRun_SimpleString("tmp = globals().copy()\nvars = [f'int {k} = {v};' for + // k,v in tmp.items() if type(v) == int and not k.startswith('_') and k!='tmp' + // and k!='In' and k!='Out' and k!='sys' and not hasattr(v, + // '__call__')]\nprint(vars)"); PyRun_SimpleString("b = + // globals().copy()\nnew_ints = ' '.join([f'int {k} = {b[k]};' for k in set(b) + // - set(first_dict) if type(b[k]) == int])\nprint('new_ints: ', new_ints)"); + + Cpp::BeginStdStreamCapture(Cpp::kStdErr); + Cpp::BeginStdStreamCapture(Cpp::kStdOut); + + PyRun_SimpleString(code.c_str()); + + std::cout << Cpp::EndStdStreamCapture(); + std::cerr << Cpp::EndStdStreamCapture(); + + // PyObject* objectsRepresentation = PyObject_Repr(gMainDict); + // const char* s = PyUnicode_AsUTF8(objectsRepresentation); + // printf("REPR of global dict: %s\n", s); +} + +void pythonexec::update_python_dict_var(const char *name, int value) { + if (!gMainDict) + startup(); + PyObject *s; + s = PyLong_FromLong(value); + PyDict_SetItemString(gMainDict, name, s); + Py_DECREF(s); +} + +void pythonexec::update_python_dict_var_vector(const char *name, + std::vector &data) { + if (!gMainDict) + startup(); + PyObject *listObj = PyList_New(data.size()); + if (!listObj) + throw std::logic_error("Unable to allocate memory for Python list"); + for (unsigned int i = 0; i < data.size(); i++) { + PyObject *num = PyLong_FromLong((int)data[i]); + if (!num) { + Py_DECREF(listObj); + throw std::logic_error("Unable to allocate memory for Python list"); + } + PyList_SET_ITEM(listObj, i, num); + } + PyDict_SetItemString(gMainDict, name, listObj); +} + +// check python globals +void pythonexec::check_python_globals() { + if (!Py_IsInitialized()) + return; + // execute the command + PyRun_SimpleString("print(globals())"); +} + +// execute a python comand +void pythonexec::exec_python_simple_command(const std::string code) { + if (!Py_IsInitialized()) + return; + // execute the command + PyRun_SimpleString(code.c_str()); +} + +std::string pythonexec::transfer_python_ints_utility() { + if (!Py_IsInitialized()) + return " "; + // transfer ints utility + PyRun_SimpleString( + "def getNewInts():\n glob_ints_utils = globals().copy()\n new_ints " + "= ' '.join([f'int {k} = {glob_ints_utils[k]};' for k in " + "set(glob_ints_utils) - set(first_dict_ints) if type(glob_ints_utils[k]) " + "== int])\n return new_ints"); + PyObject *ints_result = + PyObject_CallFunction(PyDict_GetItemString(gMainDict, "getNewInts"), 0); + if (!ints_result) { + printf("Could not retrieve Python integers!\n"); + return " "; + } else { + std::string newPythonInts = PyUnicode_AsUTF8(ints_result); + // printf("new ints %s\n", PyUnicode_AsUTF8(ints_result)); + Py_DECREF(ints_result); + return newPythonInts; + } +} + +std::string pythonexec::transfer_python_lists_utility() { + if (!Py_IsInitialized()) + return " "; + // transfer lists utility + PyRun_SimpleString("def getNewLists():\n l = globals().copy()\n " + "new_lists = ' '.join([f'int {k}() = {l[k]};' for k in " + "set(l) - set(first_dict_lists) if type(l[k]) == " + "list]).replace('[','{').replace(']','}').replace('(','[')" + ".replace(')',']')\n return new_lists"); + PyObject *lists_result = + PyObject_CallFunction(PyDict_GetItemString(gMainDict, "getNewLists"), 0); + if (!lists_result) { + printf("Could not retrieve Python lists!\n"); + return " "; + } else { + std::string newPythonLists = PyUnicode_AsUTF8(lists_result); + Py_DECREF(lists_result); + return newPythonLists; + } +} + +bool pythonexec::python_check_for_initialisation() { + if (!Py_IsInitialized()) + return false; + return true; +} +} // namespace xcpp diff --git a/src/xmagics/pythonexec.hpp b/src/xmagics/pythonexec.hpp new file mode 100644 index 00000000..7b56d9a3 --- /dev/null +++ b/src/xmagics/pythonexec.hpp @@ -0,0 +1,55 @@ +//===------- pythonexec.hpp - Python/C++ Interoperability -------*- C++ -*-===// +// +// Licensed under the Apache License v2.0. +// SPDX-License-Identifier: Apache-2.0 +// +// The full license is in the file LICENSE, distributed with this software. +// +//===----------------------------------------------------------------------===// +// +// This file defines the Python/C++ interoperability in which two cells within +// the same notebook can be in a either language. +// +//===----------------------------------------------------------------------===// + +#ifndef XMAGICS_PYTHONEXEC_HPP +#define XMAGICS_PYTHONEXEC_HPP + +#include "xeus-cpp/xbuffer.hpp" +#include "xeus-cpp/xinterpreter.hpp" +#include "xeus-cpp/xmagics.hpp" +#include "xeus-cpp/xoptions.hpp" + +#include +#include + +namespace xcpp { + + class pythonexec: public xmagic_cell + { + public: + + argparser get_options(); + virtual void operator()(const std::string& line, const std::string& cell) override { + std::string cline = line; + std::string ccell = cell; + execute(cline, ccell); + }; + + static void update_python_dict_var(const char *name, int value); + static void update_python_dict_var_vector(const char *name, + std::vector &data); + void check_python_globals(); + void exec_python_simple_command(const std::string code); + static std::string transfer_python_ints_utility(); + static std::string transfer_python_lists_utility(); + static bool python_check_for_initialisation(); + + private: + + static void startup(); + void execute(std::string &line, std::string &cell); + }; + +} // namespace xcpp +#endif From 959eb07a0788cf544291dc71c9d79b3c45e9bd44 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Thu, 5 Oct 2023 20:45:41 +0000 Subject: [PATCH 04/69] Fix rich results display --- CMakeLists.txt | 7 ++++++ Dockerfile | 57 ++++++++++++++++++++++++-------------------- src/xinterpreter.cpp | 1 + 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b661734..5479b319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,13 @@ set(XEUS_CPP_SRC src/xoptions.cpp src/xparser.cpp src/xutils.cpp + src/xdemangle.hpp + src/xinspect.hpp + src/xsystem.hpp + src/xparser.hpp + src/xmagics/os.hpp + src/xmagics/os.cpp + src/xmagics/pythonexec.hpp src/xmagics/pythonexec.cpp ) diff --git a/Dockerfile b/Dockerfile index 8dee1d1c..fddb6ffe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,17 +77,39 @@ RUN sed -i '2 i source /home/jovyan/.conda.init && conda activate .venv' /usr/lo # Switch back to jovyan to avoid accidental container runs as root USER ${NB_UID} +WORKDIR "${HOME}" + ENV NB_PYTHON_PREFIX=${CONDA_DIR} \ KERNEL_PYTHON_PREFIX=${CONDA_DIR} \ -# CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/${NB_USER}/include:/home/runner/work/xeus-clang-repl/xeus-clang-repl/clang-dev/clang/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" - CPLUS_INCLUDE_PATH="${CONDA_DIR}/include:/home/jovyan/clad/include:/home/jovyan/CppInterOp/include" - -WORKDIR "${HOME}" + VENV=${CONDA_DIR}/envs/.venv \ + # CUDA + NVIDIA_VISIBLE_DEVICES=all \ + NVIDIA_DRIVER_CAPABILITIES=compute,utility \ + NVIDIA_REQUIRE_CUDA="cuda>=12.1.1 driver>=530" \ + # + PATH=/opt/conda/envs/.venv/bin:/opt/conda/bin:/opt/conda/envs/.venv/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ + LD_LIBRARY_PATH=/home/jovyan/cppyy-backend/python/cppyy_backend/lib:/opt/conda/envs/.venv/lib:/opt/conda/lib:/home/jovyan/cppyy-backend/python/cppyy_backend/lib:/opt/conda/envs/.venv/lib \ + PYTHONPATH=/home/jovyan/CPyCppyy/build:/home/jovyan/cppyy-backend/python:/home/jovyan \ + CPLUS_INCLUDE_PATH=/opt/conda/envs/.venv/include:\ +/opt/conda/envs/.venv/include/python3.10:\ +/home/jovyan/clad/include:\ +/home/jovyan/CPyCppyy/include:\ +/home/jovyan/cppyy-backend/python/cppyy_backend/include:\ +/opt/conda/envs/.venv/include/llvm:\ +/opt/conda/envs/.venv/include/clang:\ +/opt/conda/include:\ +/home/jovyan/clad/include:\ +/home/jovyan/CppInterOp/include:\ +/opt/conda/include:\ +# +/opt/conda/envs/.venv/lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:\ +/opt/conda/envs/.venv/lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:\ +/opt/conda/envs/.venv/lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:\ +/opt/conda/envs/.venv/x86_64-conda-linux-gnu/include/c++/12.3.0:\ +/opt/conda/envs/.venv/x86_64-conda-linux-gnu/include/c++/12.3.0/x86_64-conda-linux-gnu:\ +/opt/conda/envs/.venv/x86_64-conda-linux-gnu/include/c++/12.3.0/backward:\ +/opt/conda/envs/.venv/x86_64-conda-linux-gnu/sysroot/usr/include -# CUDA -ENV NVIDIA_VISIBLE_DEVICES=all -ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility -ENV NVIDIA_REQUIRE_CUDA "cuda>=12.1.1 driver>=530" # VENV @@ -162,20 +184,14 @@ RUN \ source /home/jovyan/.conda.init && \ conda activate .venv && \ # - export VENV=${CONDA_DIR}/envs/.venv && \ export PATH_TO_LLVM_BUILD=${VENV} && \ #export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH_TO_LLVM_BUILD/bin:$PATH && \ export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH && \ - export LD_LIBRARY_PATH=$PATH_TO_LLVM_BUILD/lib:$LD_LIBRARY_PATH && \ - echo "export VENV=$VENV" >> ~/.profile && \ - echo "export PATH=$PATH" >> ~/.profile && \ echo "export EDITOR=emacs" >> ~/.profile && \ # # Build CppInterOp # - sys_incs=$(LC_ALL=C c++ -xc++ -E -v /dev/null 2>&1 | LC_ALL=C sed -ne '/starts here/,/End of/p' | LC_ALL=C sed '/^ /!d' | cut -c2- | tr '\n' ':') && \ - #/usr/include/x86_64-linux-gnu:/usr/include: - export CPLUS_INCLUDE_PATH="${PATH_TO_LLVM_BUILD}/include/llvm:${PATH_TO_LLVM_BUILD}/include/clang:$CPLUS_INCLUDE_PATH:${sys_incs%:}" && \ + #sys_incs=$(LC_ALL=C c++ -xc++ -E -v /dev/null 2>&1 | LC_ALL=C sed -ne '/starts here/,/End of/p' | LC_ALL=C sed '/^ /!d' | cut -c2- | tr '\n' ':') && \ git clone https://github.com/compiler-research/CppInterOp.git && \ export CB_PYTHON_DIR="$PWD/cppyy-backend/python" && \ export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend" && \ @@ -186,9 +202,6 @@ RUN \ cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_CLING=OFF -DUSE_REPL=ON -DLLVM_DIR=$PATH_TO_LLVM_BUILD -DLLVM_CONFIG_EXTRA_PATH_HINTS=${PATH_TO_LLVM_BUILD}/lib -DLLVM_USE_LINKER=gold -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR .. && \ cmake --build . --parallel $(nproc --all) && \ #make install -j$(nproc --all) - export CPLUS_INCLUDE_PATH="$CPPINTEROP_DIR/include:$CPLUS_INCLUDE_PATH" && \ - export LD_LIBRARY_PATH="${VENV}/lib:${CONDA_DIR}/lib:$CPPINTEROP_DIR/lib:$LD_LIBRARY_PATH" && \ - echo "export LD_LIBRARY_PATH=$CPPINTEROP_DIR/lib:$LD_LIBRARY_PATH" >> ~/.profile && \ cd ../.. && \ # # Build and Install cppyy-backend @@ -224,20 +237,12 @@ RUN \ cd .. && \ # Run cppyy #TODO: Fix cppyy path (/home/jovyan) to path to installed module - export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR:/home/jovyan && \ - echo "export PYTHONPATH=$PYTHONPATH" >> ~/.profile && \ - export CPLUS_INCLUDE_PATH="/home/jovyan/CPyCppyy/include/:$CPLUS_INCLUDE_PATH" && \ - # FIXME: Remove the hardcoded version of python here. - export CPLUS_INCLUDE_PATH="/home/jovyan/clad/include:$CPLUS_INCLUDE_PATH" && \ - export CPLUS_INCLUDE_PATH="${VENV}/include:${VENV}/include/python3.10:$CPLUS_INCLUDE_PATH" && \ python -c "import cppyy" && \ # # Build and Install xeus-cpp # mkdir build && \ cd build && \ - echo "export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> ~/.profile && \ - ##echo "conda activate .venv" >> ~/.profile cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$KERNEL_PYTHON_PREFIX -DCMAKE_INSTALL_PREFIX=$KERNEL_PYTHON_PREFIX -DCMAKE_INSTALL_LIBDIR=lib -DCPPINTEROP_DIR=$CPPINTEROP_BUILD_DIR .. && \ make install -j$(nproc --all) && \ cd .. && \ diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 0cef2a93..f1b4277e 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -51,6 +51,7 @@ namespace xcpp { void interpreter::configure_impl() { + xeus::register_interpreter(this); } interpreter::interpreter(int argc, const char* const* argv) From a2ac8c23e871d88f43507a3a0e70f0b1363257c4 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 29 Oct 2023 21:13:34 +0000 Subject: [PATCH 05/69] Move docker container to port 9999 and some other minor fixes --- Dockerfile | 13 ++++++++----- run-docker.sh | 2 +- share/jupyter/kernels/xcpp/kernel.json.in | 1 + src/xmagics/pythonexec.cpp | 1 - 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fddb6ffe..1020b0cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ ARG BASE_CONTAINER=jupyter/base-notebook ARG BASE_TAG=latest ARG BUILD_TYPE=Debug + FROM $BASE_CONTAINER:$BASE_TAG LABEL maintainer="Xeus-cpp Project" @@ -61,7 +62,8 @@ USER ${NB_UID} # Copy git repository to home directory of container COPY --chown=${NB_UID}:${NB_GID} . "${HOME}"/ -EXPOSE 8888 +EXPOSE 9999 +ENV JUPYTER_PORT=9999 # Configure container startup CMD ["start-notebook.sh", "--debug", "&>/home/jovyan/log.txt"] @@ -108,8 +110,9 @@ ENV NB_PYTHON_PREFIX=${CONDA_DIR} \ /opt/conda/envs/.venv/x86_64-conda-linux-gnu/include/c++/12.3.0:\ /opt/conda/envs/.venv/x86_64-conda-linux-gnu/include/c++/12.3.0/x86_64-conda-linux-gnu:\ /opt/conda/envs/.venv/x86_64-conda-linux-gnu/include/c++/12.3.0/backward:\ -/opt/conda/envs/.venv/x86_64-conda-linux-gnu/sysroot/usr/include - +/opt/conda/envs/.venv/x86_64-conda-linux-gnu/sysroot/usr/include:\ +# +/usr/include # VENV @@ -185,8 +188,8 @@ RUN \ conda activate .venv && \ # export PATH_TO_LLVM_BUILD=${VENV} && \ - #export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH_TO_LLVM_BUILD/bin:$PATH && \ - export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH && \ + ###export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH_TO_LLVM_BUILD/bin:$PATH && \ + ##export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH && \ echo "export EDITOR=emacs" >> ~/.profile && \ # # Build CppInterOp diff --git a/run-docker.sh b/run-docker.sh index e64d7116..2d7f7506 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -8,7 +8,7 @@ jupyter-repo2docker \ . #docker run --gpus all --publish 8888:8888 --name xeus-cpp-c -i -t xeus-cpp "start-notebook.sh" -docker run --rm --runtime=nvidia --gpus all --publish 8888:8888 --name xeus-cpp-c -i -t xeus-cpp "start-notebook.sh" +docker run --rm --runtime=nvidia --gpus all --publish 9999:9999 --name xeus-cpp-c -i -t xeus-cpp "start-notebook.sh" # --editable \ # --ref InterOpIntegration \ diff --git a/share/jupyter/kernels/xcpp/kernel.json.in b/share/jupyter/kernels/xcpp/kernel.json.in index 556bd429..70c99e20 100644 --- a/share/jupyter/kernels/xcpp/kernel.json.in +++ b/share/jupyter/kernels/xcpp/kernel.json.in @@ -10,6 +10,7 @@ "@CMAKE_VENV_PATH@/bin/xcpp", "-f", "{connection_file}", + "-cuda", "-std=c++17"@CMAKE_OMP@ ], "language": "cpp", diff --git a/src/xmagics/pythonexec.cpp b/src/xmagics/pythonexec.cpp index ccd308c0..152b36cb 100644 --- a/src/xmagics/pythonexec.cpp +++ b/src/xmagics/pythonexec.cpp @@ -53,7 +53,6 @@ void pythonexec::startup() { // if (!gMainDict) // printf("Could not add module __main__"); - // // Retrieve the dictionary of cppyy module // PyObject* cppyyDict = PyModule_GetDict(cppyyModule); // Py_DECREF(cppyyModule); From 61e1a8ea3533cec48e5d78baf056f41ea6db9e7d Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 19 Nov 2023 14:21:40 +0000 Subject: [PATCH 06/69] Fix build paths. Fix inspect to work with CppInterOp --- CMakeLists.txt | 26 ++++++++++--- include/xeus-cpp/xinterpreter.hpp | 2 +- src/xinspect.hpp | 63 +++++++++++++++++++++++-------- src/xinterpreter.cpp | 14 +++---- 4 files changed, 76 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5479b319..b4beabdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,16 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") set(XEUS_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +if ("${CMAKE_INSTALL_INCLUDEDIR}" STREQUAL "") + set(CMAKE_INSTALL_INCLUDEDIR "include") +endif() +if ("${CMAKE_INSTALL_LIBDIR}" STREQUAL "") + set(CMAKE_INSTALL_LIBDIR "lib") +endif() +if ("${CMAKE_INSTALL_BINDIR}" STREQUAL "") + set(CMAKE_INSTALL_BINDIR "bin") +endif() + # Versionning # =========== @@ -222,7 +232,8 @@ include(CheckCXXCompilerFlag) string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib; ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +list(REMOVE_DUPLICATES CMAKE_INSTALL_RPATH) macro(xeus_cpp_set_common_options target_name) if (MSVC) @@ -311,7 +322,7 @@ macro(xeus_cpp_create_target target_name linkage output_name) set(XEUS_CPP_XEUS_TARGET xeus-static) endif () - target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl) + target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl Python::Python) if (WIN32 OR CYGWIN) # elseif (APPLE) @@ -421,10 +432,10 @@ set(XEUS_CPP_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NA if (XEUS_CPP_BUILD_SHARED) install(TARGETS ${XEUS_CPP_TARGETS} EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xeus-cpp) + ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/xeus-cpp) # Makes the project importable from the build directory export(EXPORT ${PROJECT_NAME}-targets @@ -432,6 +443,9 @@ if (XEUS_CPP_BUILD_SHARED) endif () # Install xcpp +if ("${CMAKE_VENV_PATH}" STREQUAL "") + set(CMAKE_VENV_PATH "${CMAKE_INSTALL_PREFIX}") +endif() if (XEUS_CPP_BUILD_EXECUTABLE) install(TARGETS xcpp RUNTIME DESTINATION ${CMAKE_VENV_PATH}/bin) diff --git a/include/xeus-cpp/xinterpreter.hpp b/include/xeus-cpp/xinterpreter.hpp index 92ccbbe8..c8cddca2 100644 --- a/include/xeus-cpp/xinterpreter.hpp +++ b/include/xeus-cpp/xinterpreter.hpp @@ -17,7 +17,7 @@ #include //#include -#include "clang/Interpreter/CppInterOp.h" +#include "clang/Interpreter/CppInterOp.h" // from CppInterOp package #include diff --git a/src/xinspect.hpp b/src/xinspect.hpp index 15b8d523..13dac4eb 100644 --- a/src/xinspect.hpp +++ b/src/xinspect.hpp @@ -9,10 +9,10 @@ #ifndef XEUS_CPP_INSPECT_HPP #define XEUS_CPP_INSPECT_HPP +#include #include #include - #include #include @@ -23,8 +23,11 @@ #include "xdemangle.hpp" #include "xparser.hpp" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Path.h" +//#include "llvm/Support/FileSystem.h" +//#include "llvm/Support/Path.h" + +//#include "clang/Interpreter/CppInterOp.h" + namespace xcpp { @@ -81,7 +84,27 @@ namespace xcpp } }; - std::string find_type(const std::string& expression, clang::Interpreter& interpreter) + + std::string find_type_slow(const std::string& expression) { + static unsigned long long var_count = 0; + + if (auto type = Cpp::GetType(expression)) + return Cpp::GetQualifiedName(type); + + // Here we might need to deal with integral types such as 3.14. + + std::string id = "__Xeus_GetType_" + std::to_string(var_count++); + std::string using_clause = "using " + id + " = __typeof__(" + expression + ");\n"; + + if (!Cpp::Declare(using_clause.c_str(), /*silent=*/false)) { + Cpp::TCppScope_t lookup = Cpp::GetNamed(id, 0); + Cpp::TCppType_t lookup_ty = Cpp::GetTypeFromScope(lookup); + return Cpp::GetQualifiedCompleteName(Cpp::GetCanonicalType(lookup_ty)); + } + return ""; + } +/* + std::string find_type(const std::string& expression) { auto PTU = interpreter.Parse(expression + ";"); if (llvm::Error Err = PTU.takeError()) { @@ -89,19 +112,29 @@ namespace xcpp return ""; } - clang::Decl *D = *PTU->TUPart->decls_begin(); - if (!llvm::isa(D)) - return ""; + clang::Decl *D = *PTU->TUPart->decls_begin(); + if (!llvm::isa(D)) + return ""; - clang::Expr *E = llvm::cast(llvm::cast(D)->getStmt()); + clang::Expr *E = llvm::cast(llvm::cast(D)->getStmt()); - clang::QualType QT = E->getType(); + clang::QualType QT = E->getType(); return QT.getAsString(); } - +*/ static nl::json read_tagconfs(const char* path) { nl::json result = nl::json::array(); + for (auto &entry: std::filesystem::directory_iterator(path)) { + if (entry.path().extension() != ".json") + continue; + std::ifstream i(entry.path()); + nl::json json_entry; + i >> json_entry; + result.emplace_back(std::move(json_entry)); + } + return result; +/* std::error_code EC; for (llvm::sys::fs::directory_iterator File(path, EC), FileEnd; File != FileEnd && !EC; File.increment(EC)) { @@ -115,19 +148,19 @@ namespace xcpp result.emplace_back(std::move(entry)); } return result; +*/ } - std::pair is_inspect_request(const std::string code, std::regex re) + std::pair is_inspect_request(const std::string code, std::regex re) { std::smatch inspect; if (std::regex_search(code, inspect, re)){ return std::make_pair(true, inspect); } return std::make_pair(false, inspect); - } - void inspect(const std::string& code, nl::json& kernel_res, clang::Interpreter& interpreter) + void inspect(const std::string& code, nl::json& kernel_res) { std::string tagconf_dir = XCPP_TAGCONFS_DIR; std::string tagfiles_dir = XCPP_TAGFILES_DIR; @@ -150,7 +183,7 @@ namespace xcpp // Method or variable of class found (xxxx.yyyy) if (std::regex_search(to_inspect, method, std::regex(R"((.*)\.(\w*)$)"))) { - std::string typename_ = find_type(method[1], interpreter); + std::string typename_ = find_type_slow(method[1]); if (!typename_.empty()) { @@ -184,7 +217,7 @@ namespace xcpp } else { - std::string typename_ = find_type(to_inspect, interpreter); + std::string typename_ = find_type_slow(to_inspect); find_string = (typename_.empty()) ? to_inspect : typename_; } diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index f1b4277e..159af207 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -27,7 +27,7 @@ #include "xeus-cpp/xmagics.hpp" #include "xinput.hpp" -// #include "xinspect.hpp" +#include "xinspect.hpp" // #include "xmagics/executable.hpp" // #include "xmagics/execution.hpp" #include "xmagics/os.hpp" @@ -124,12 +124,12 @@ namespace xcpp // Attempt normal evaluation try { - std::string exp = R"(\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)"; - std::regex re(R"((\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)(\.?)*$)"); + std::string exp = R"(\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)"; + std::regex re(R"((\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)(\.?)*$)"); auto inspect_request = is_inspect_request(code, re); if (inspect_request.first) - inspect(inspect_request.second[0], kernel_res, *m_interpreter); - + inspect(inspect_request.second[0], kernel_res); + Cpp::BeginStdStreamCapture(Cpp::kStdErr); Cpp::BeginStdStreamCapture(Cpp::kStdOut); compilation_result = Cpp::Process(code.c_str()); @@ -148,7 +148,7 @@ namespace xcpp errorlevel = 1; ename = "Error :"; } - + if (compilation_result) { errorlevel = 1; @@ -227,7 +227,7 @@ namespace xcpp auto inspect_request = is_inspect_request(code.substr(0, cursor_pos), re); if (inspect_request.first) { - inspect(inspect_request.second[0], kernel_res, *m_interpreter); + inspect(inspect_request.second[0], kernel_res); } return kernel_res; } From 365a6f6830d402009f924f4c599b1965406049de Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 20:26:54 +0200 Subject: [PATCH 07/69] Add mamba install of CppInterOp --- environment-dev.yml | 1 + environment-wasm-host.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/environment-dev.yml b/environment-dev.yml index 0c2df603..de3e53be 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -15,6 +15,7 @@ dependencies: - pugixml - cpp-argparse - zlib + - CppInterOp # Test dependencies - pytest - jupyter_kernel_test>=0.4.3 diff --git a/environment-wasm-host.yml b/environment-wasm-host.yml index 4bb96d48..048ad328 100644 --- a/environment-wasm-host.yml +++ b/environment-wasm-host.yml @@ -10,3 +10,4 @@ dependencies: - llvm =16.0.6 - cpp-argparse - pugixml + - CppInterOp From d493445e2c7d40e45de69b3e9e8162d0e740915b Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 20:32:37 +0200 Subject: [PATCH 08/69] Remove clang-dev dep --- environment-dev.yml | 1 - environment-wasm-host.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index de3e53be..8aeee0e0 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -11,7 +11,6 @@ dependencies: - nlohmann_json - cppzmq - xtl - - clangdev >=16,<17 - pugixml - cpp-argparse - zlib diff --git a/environment-wasm-host.yml b/environment-wasm-host.yml index 048ad328..2434910c 100644 --- a/environment-wasm-host.yml +++ b/environment-wasm-host.yml @@ -7,7 +7,6 @@ dependencies: - xeus-lite - xeus >=3.0.5,<4.0 - xtl >=0.7,<0.8 - - llvm =16.0.6 - cpp-argparse - pugixml - CppInterOp From ba87e6970ad74e32871b74ef4244eda78cc6a772 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 20:45:08 +0200 Subject: [PATCH 09/69] Fix CppInterOp package find --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4beabdb..0cb652cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,10 @@ if(EMSCRIPTEN) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") endif() -find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") +find_package(CppInterOp REQUIRED) +if(NOT CppInterOp_FOUND) + find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") +endif() find_package(argparse REQUIRED) find_package(pugixml REQUIRED) set(Python_FIND_VIRTUALENV ONLY) From 39eddea27cf2566182a6ff9d7a7d8f270b405325 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 20:48:09 +0200 Subject: [PATCH 10/69] Fix CppInterOp package find --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cb652cd..83c53dcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,7 @@ if(EMSCRIPTEN) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") endif() -find_package(CppInterOp REQUIRED) +find_package(CppInterOp) if(NOT CppInterOp_FOUND) find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") endif() From 286687f928707eab89d09ffa0add49f3f429c6f1 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 21:00:54 +0200 Subject: [PATCH 11/69] Fix CppInterOp package find --- .github/workflows/main.yml | 1 + CMakeLists.txt | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 67c3f15a..d3cb9220 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,6 +52,7 @@ jobs: run: | mkdir -p build cd build + find $CONDA_PREFIX | grep -i "CppInterOp" cmake .. \ -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \ -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 83c53dcc..fcf9f571 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,10 +174,8 @@ if(EMSCRIPTEN) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") endif() -find_package(CppInterOp) -if(NOT CppInterOp_FOUND) - find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") -endif() +find_package(CppInterOp REQUIRED) +#find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") find_package(argparse REQUIRED) find_package(pugixml REQUIRED) set(Python_FIND_VIRTUALENV ONLY) From 66b9b4b6d8a23c2745ec6585f5c900e911bb843c Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 21:33:52 +0200 Subject: [PATCH 12/69] Fix CppInterOp package find --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcf9f571..9b27b298 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ endif () set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}") set(CMAKE_PATH "$ENV{PATH}") +set(CMAKE_PATH "${CMAKE_PREFIX_PATH}:${CMAKE_PATH}") set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}") set(CMAKE_VENV_PATH "$ENV{VENV}") From ed8dc76bb8a44a61a8dc2a92646004dd0077dbd7 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 21:57:59 +0200 Subject: [PATCH 13/69] Fix CppInterOp package find --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b27b298..9a217909 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,6 @@ endif () set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}") set(CMAKE_PATH "$ENV{PATH}") -set(CMAKE_PATH "${CMAKE_PREFIX_PATH}:${CMAKE_PATH}") set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}") set(CMAKE_VENV_PATH "$ENV{VENV}") @@ -175,8 +174,7 @@ if(EMSCRIPTEN) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") endif() -find_package(CppInterOp REQUIRED) -#find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") +find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") find_package(argparse REQUIRED) find_package(pugixml REQUIRED) set(Python_FIND_VIRTUALENV ONLY) From 696324157708a526f98c73bf2a75f98211435b47 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 12 Feb 2024 23:15:58 +0200 Subject: [PATCH 14/69] Fix CppInterOp package find --- CMakeLists.txt | 4 ++++ src/xinspect.hpp | 6 ++++-- src/xinterpreter.cpp | 2 +- src/xsystem.hpp | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a217909..d6dfed9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,10 @@ if(EMSCRIPTEN) endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") +if(CppInterOp_FOUND) + message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} (found version=${CppInterOp_VERSION})") +endif() + find_package(argparse REQUIRED) find_package(pugixml REQUIRED) set(Python_FIND_VIRTUALENV ONLY) diff --git a/src/xinspect.hpp b/src/xinspect.hpp index 13dac4eb..0faff970 100644 --- a/src/xinspect.hpp +++ b/src/xinspect.hpp @@ -193,7 +193,7 @@ namespace xcpp tagfile = it->at("tagfile"); std::string filename = tagfiles_dir + "/" + tagfile; pugi::xml_document doc; - doc.load_file(filename.c_str()); + pugi::xml_parse_result result = doc.load_file(filename.c_str()); class_member_predicate predicate{typename_, "function", method[2]}; auto node = doc.find_node(predicate); if (!node.empty()) @@ -227,7 +227,7 @@ namespace xcpp tagfile = it->at("tagfile"); std::string filename = tagfiles_dir + "/" + tagfile; pugi::xml_document doc; - doc.load_file(filename.c_str()); + pugi::xml_parse_result result = doc.load_file(filename.c_str()); for (auto c : check) { node_predicate predicate{c, find_string}; @@ -298,6 +298,7 @@ namespace xcpp } } +/* class xintrospection : public xpreamble { public: @@ -328,5 +329,6 @@ namespace xcpp clang::Interpreter& m_interpreter; }; +*/ } #endif diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 159af207..eba17e50 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -333,7 +333,7 @@ namespace xcpp void interpreter::init_preamble() { - preamble_manager.register_preamble("introspection", new xintrospection(*m_interpreter)); + //preamble_manager.register_preamble("introspection", new xintrospection(*m_interpreter)); preamble_manager.register_preamble("magics", new xmagics_manager()); preamble_manager.register_preamble("shell", new xsystem()); } diff --git a/src/xsystem.hpp b/src/xsystem.hpp index 99d67b1e..c43abfc4 100644 --- a/src/xsystem.hpp +++ b/src/xsystem.hpp @@ -32,6 +32,8 @@ namespace xcpp std::smatch to_execute; std::regex_search(code, to_execute, re); + int ret = 1; // ??? + // Redirection of stderr to stdout std::string command = to_execute.str(1) + " 2>&1"; @@ -43,6 +45,9 @@ namespace xcpp if (shell_result) { char buff[512]; + + ret = 0; // ??? + while (fgets(buff, sizeof(buff), shell_result)) { std::cout << buff; From 2996647504ae4a84f1a5f6128b65d3edfafff60c Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 00:16:56 +0200 Subject: [PATCH 15/69] Fix CppInterOp package find --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6dfed9d..3c32094b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,7 +176,7 @@ endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") if(CppInterOp_FOUND) - message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} (found version=${CppInterOp_VERSION})") + message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} dir=${CppInterOp_DIR} (found version=${CppInterOp_VERSION})") endif() find_package(argparse REQUIRED) From 82f94ba2ca07c08d379ba580330e3844c833e0cc Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 00:22:32 +0200 Subject: [PATCH 16/69] Fix CppInterOp package find --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c32094b..32b42aff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,6 +176,7 @@ endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") if(CppInterOp_FOUND) + set(CppInterOp_DIR "/home/runner/micromamba-root/envs/xeus-cpp/lib/cmake/CppInterOp") message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} dir=${CppInterOp_DIR} (found version=${CppInterOp_VERSION})") endif() From cac2f6407963f694d196294ef225db9f7b42e6bc Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 00:27:21 +0200 Subject: [PATCH 17/69] Fix CppInterOp package find --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32b42aff..de2e845d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,7 @@ endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") if(CppInterOp_FOUND) set(CppInterOp_DIR "/home/runner/micromamba-root/envs/xeus-cpp/lib/cmake/CppInterOp") + set(CppInterOp_VERSION "1.1.0") message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} dir=${CppInterOp_DIR} (found version=${CppInterOp_VERSION})") endif() From 9eaf1a7fc0746cabea2ae20450fb5ce0df6e379e Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 00:32:17 +0200 Subject: [PATCH 18/69] Fix CppInterOp package find --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de2e845d..930e4a2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,7 +176,7 @@ endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") if(CppInterOp_FOUND) - set(CppInterOp_DIR "/home/runner/micromamba-root/envs/xeus-cpp/lib/cmake/CppInterOp") + set(CppInterOp_DIR "/home/runner/micromamba-root/envs/xeus-cpp/lib") set(CppInterOp_VERSION "1.1.0") message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} dir=${CppInterOp_DIR} (found version=${CppInterOp_VERSION})") endif() From 8431dafcc52840f9418a13937eebb32bb356f9aa Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 00:38:04 +0200 Subject: [PATCH 19/69] Fix CppInterOp package find --- CMakeLists.txt | 2 -- environment-dev.yml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 930e4a2a..3c32094b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,8 +176,6 @@ endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") if(CppInterOp_FOUND) - set(CppInterOp_DIR "/home/runner/micromamba-root/envs/xeus-cpp/lib") - set(CppInterOp_VERSION "1.1.0") message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} dir=${CppInterOp_DIR} (found version=${CppInterOp_VERSION})") endif() diff --git a/environment-dev.yml b/environment-dev.yml index 8aeee0e0..3c1622d6 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -12,7 +12,7 @@ dependencies: - cppzmq - xtl - pugixml - - cpp-argparse + - cpp-argparse <3.0 - zlib - CppInterOp # Test dependencies From 4a99c80072535390a64bccdc4a6254aadfd959a8 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 08:19:00 +0000 Subject: [PATCH 20/69] Fix CppInterOp package find --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c32094b..7dca7311 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,7 +326,7 @@ macro(xeus_cpp_create_target target_name linkage output_name) set(XEUS_CPP_XEUS_TARGET xeus-static) endif () - target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl Python::Python) + target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} ${CPPINTEROP_INSTALL_PREFIX}/lib/libclangCppInterOp.so pugixml argparse::argparse xtl Python::Python) if (WIN32 OR CYGWIN) # elseif (APPLE) From f4da8bc2a74690f9517f19587e0edb8fb7c67c90 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 09:20:01 +0000 Subject: [PATCH 21/69] Fix CppInterOp package find --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d3cb9220..25d1104b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,6 @@ jobs: run: | mkdir -p build cd build - find $CONDA_PREFIX | grep -i "CppInterOp" cmake .. \ -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \ -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ @@ -75,6 +74,7 @@ jobs: shell: bash -l {0} run: | cd build/test + export ./test_xeus_cpp timeout-minutes: 4 From 27bd9c161cf380bd16b914945ae13263fade75b2 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 09:49:22 +0000 Subject: [PATCH 22/69] Fix CppInterOp package find --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 25d1104b..3e1040cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,6 +74,7 @@ jobs: shell: bash -l {0} run: | cd build/test + export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include export ./test_xeus_cpp timeout-minutes: 4 From 182b0d7ac503178a34d0ac28c5f8f0f846e85795 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 09:59:40 +0000 Subject: [PATCH 23/69] Fix CppInterOp package find --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e1040cc..5a6eca37 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,7 +74,8 @@ jobs: shell: bash -l {0} run: | cd build/test - export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include + export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include + ls -la $CONDA_BUILD_SYSROOT export ./test_xeus_cpp timeout-minutes: 4 From b0f2b8052eed32dc8b0edabbd125e8776bf85390 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 10:37:45 +0000 Subject: [PATCH 24/69] Fix CppInterOp package find --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a6eca37..2d2deed6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,8 +74,9 @@ jobs: shell: bash -l {0} run: | cd build/test - export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include + export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include ls -la $CONDA_BUILD_SYSROOT + echo | gcc -E -Wp,-v - export ./test_xeus_cpp timeout-minutes: 4 From 0aa3d4a14bec0f753d3d009f4c29619d0414b427 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 10:40:13 +0000 Subject: [PATCH 25/69] Fix CppInterOp package find --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d2deed6..8e2f7b78 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,9 +74,9 @@ jobs: shell: bash -l {0} run: | cd build/test - export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include - ls -la $CONDA_BUILD_SYSROOT echo | gcc -E -Wp,-v - + ls -la $CONDA_BUILD_SYSROOT + export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include export ./test_xeus_cpp timeout-minutes: 4 From bca994914b7c1d65f75d2eb73b9170adaeccffcf Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 13 Feb 2024 10:45:23 +0000 Subject: [PATCH 26/69] Fix CppInterOp package find --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e2f7b78..ebd27082 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,7 +76,7 @@ jobs: cd build/test echo | gcc -E -Wp,-v - ls -la $CONDA_BUILD_SYSROOT - export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include + export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../x86_64-conda-linux-gnu/sysroot/usr/include export ./test_xeus_cpp timeout-minutes: 4 From d0f9af039e2ef429492301200df5755a98a9cbd1 Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:58:29 +0200 Subject: [PATCH 27/69] Update main.yml --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebd27082..a197b303 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,7 +77,6 @@ jobs: echo | gcc -E -Wp,-v - ls -la $CONDA_BUILD_SYSROOT export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../x86_64-conda-linux-gnu/sysroot/usr/include - export ./test_xeus_cpp timeout-minutes: 4 From 4297c1b40e4d8a11345d8d94796b3f6acdf057f9 Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:44:28 +0200 Subject: [PATCH 28/69] Update main.yml From dc1c374efee7a9fdd1b2be502a7450b229186420 Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:54:02 +0200 Subject: [PATCH 29/69] Update main.yml --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a197b303..f6b65a58 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: mamba update all + shell: bash -l {0} + run: | + $HOME/micromamba-bin/micromamb update --all + - name: install mamba uses: mamba-org/provision-with-micromamba@main with: From d8a4b4c5c81faa79c7838a3790329861f07a058d Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:55:35 +0200 Subject: [PATCH 30/69] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f6b65a58..57571a11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,7 @@ jobs: - name: mamba update all shell: bash -l {0} run: | - $HOME/micromamba-bin/micromamb update --all + $HOME/micromamba-bin/micromamba update --all - name: install mamba uses: mamba-org/provision-with-micromamba@main From 395c95a7f3bb741b1de12385096b5e009053125e Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 5 Mar 2024 13:25:29 +0200 Subject: [PATCH 31/69] Update main.yml --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57571a11..c56663c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,17 +36,17 @@ jobs: steps: - uses: actions/checkout@v3 - - name: mamba update all - shell: bash -l {0} - run: | - $HOME/micromamba-bin/micromamba update --all - - name: install mamba uses: mamba-org/provision-with-micromamba@main with: environment-file: environment-dev.yml environment-name: xeus-cpp + - name: mamba update all + shell: bash -l {0} + run: | + $HOME/micromamba-bin/micromamba update --all + - name: install cxx compiler shell: bash -l {0} run: | From 31f7f36e0b53feefbfe92a192635ddb1bb7d534a Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 5 Mar 2024 12:45:03 +0000 Subject: [PATCH 32/69] Fix argpars --- src/xmagics/pythonexec.cpp | 5 ++--- src/xmagics/pythonexec.hpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/xmagics/pythonexec.cpp b/src/xmagics/pythonexec.cpp index 152b36cb..03d5a488 100644 --- a/src/xmagics/pythonexec.cpp +++ b/src/xmagics/pythonexec.cpp @@ -69,9 +69,7 @@ void pythonexec::startup() { // PyRun_SimpleString("import cppyy"); } -argparser pythonexec::get_options() { - argparser argpars{"python", "Start executing Python Cell"}; - return argpars; +void pythonexec::get_options(argparser &argpars) { } void pythonexec::execute(std::string &line, std::string &cell) { @@ -80,6 +78,7 @@ void pythonexec::execute(std::string &line, std::string &cell) { // std::istream_iterator()); startup(); +// argparser argpars{"python", "Start executing Python Cell"}; // auto argpars = get_options(); // argpars.parse(line); diff --git a/src/xmagics/pythonexec.hpp b/src/xmagics/pythonexec.hpp index 7b56d9a3..bd8a69ce 100644 --- a/src/xmagics/pythonexec.hpp +++ b/src/xmagics/pythonexec.hpp @@ -29,7 +29,7 @@ namespace xcpp { { public: - argparser get_options(); + void get_options(argparser &argpars); virtual void operator()(const std::string& line, const std::string& cell) override { std::string cline = line; std::string ccell = cell; From 1a933f418c9c1b65d2866c7fc7cace2aed1b8168 Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Wed, 6 Mar 2024 01:03:24 +0200 Subject: [PATCH 33/69] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c56663c0..74bc2ba2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,7 +81,7 @@ jobs: cd build/test echo | gcc -E -Wp,-v - ls -la $CONDA_BUILD_SYSROOT - export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../x86_64-conda-linux-gnu/sysroot/usr/include + export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0/include:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../x86_64-conda-linux-gnu/sysroot/usr/include ./test_xeus_cpp timeout-minutes: 4 From eae4c10060fae8039c9c05834665ac02f070194d Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Wed, 6 Mar 2024 08:25:02 +0000 Subject: [PATCH 34/69] Fix 1 --- src/xinterpreter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index eba17e50..d4139bd2 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -124,11 +124,11 @@ namespace xcpp // Attempt normal evaluation try { - std::string exp = R"(\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)"; - std::regex re(R"((\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)(\.?)*$)"); - auto inspect_request = is_inspect_request(code, re); - if (inspect_request.first) - inspect(inspect_request.second[0], kernel_res); + // std::string exp = R"(\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)"; + // std::regex re(R"((\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)(\.?)*$)"); + // auto inspect_request = is_inspect_request(code, re); + // if (inspect_request.first) + // inspect(inspect_request.second[0], kernel_res); Cpp::BeginStdStreamCapture(Cpp::kStdErr); Cpp::BeginStdStreamCapture(Cpp::kStdOut); From 9d5e285be2a01b1f06678dd1d8e97287b0134665 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sat, 9 Mar 2024 18:38:02 +0000 Subject: [PATCH 35/69] Fix '?std::vector' error --- src/xinspect.hpp | 12 +++--------- src/xinterpreter.cpp | 8 +------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/xinspect.hpp b/src/xinspect.hpp index 0faff970..b7c22c8c 100644 --- a/src/xinspect.hpp +++ b/src/xinspect.hpp @@ -298,7 +298,6 @@ namespace xcpp } } -/* class xintrospection : public xpreamble { public: @@ -306,8 +305,7 @@ namespace xcpp using xpreamble::pattern; const std::string spattern = R"(^\?)"; - xintrospection(clang::Interpreter& p) - : m_interpreter{p} + xintrospection() { pattern = spattern; } @@ -317,18 +315,14 @@ namespace xcpp std::regex re(spattern + R"((.*))"); std::smatch to_inspect; std::regex_search(code, to_inspect, re); - inspect(to_inspect[1], kernel_res, m_interpreter); + inspect(to_inspect[1], kernel_res); } virtual xpreamble* clone() const override { return new xintrospection(*this); } - - private: - - clang::Interpreter& m_interpreter; }; -*/ + } #endif diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index d4139bd2..1a6b1a10 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -124,12 +124,6 @@ namespace xcpp // Attempt normal evaluation try { - // std::string exp = R"(\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)"; - // std::regex re(R"((\w*(?:\:{2}|\<.*\>|\(.*\)|\[.*\])?)(\.?)*$)"); - // auto inspect_request = is_inspect_request(code, re); - // if (inspect_request.first) - // inspect(inspect_request.second[0], kernel_res); - Cpp::BeginStdStreamCapture(Cpp::kStdErr); Cpp::BeginStdStreamCapture(Cpp::kStdOut); compilation_result = Cpp::Process(code.c_str()); @@ -333,7 +327,7 @@ namespace xcpp void interpreter::init_preamble() { - //preamble_manager.register_preamble("introspection", new xintrospection(*m_interpreter)); + preamble_manager.register_preamble("introspection", new xintrospection()); preamble_manager.register_preamble("magics", new xmagics_manager()); preamble_manager.register_preamble("shell", new xsystem()); } From 7f9ffb9c66cbffb7f112124ad1108916300a5717 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 10 Mar 2024 06:37:02 +0000 Subject: [PATCH 36/69] Debug 1 --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 74bc2ba2..d560ce50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,6 +89,10 @@ jobs: shell: bash -l {0} run: | cd test + echo $CONDA_PREFIX + echo $PREFIX + echo $BUILD_PREFIX + find / | grep xcpp pytest . --reruns 5 - name: Prepare code coverage report From 76e6180e428bedbc2910daaecf9bae5da499ca77 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 10 Mar 2024 21:02:02 +0000 Subject: [PATCH 37/69] Fix xcpp crash --- src/xinterpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 1a6b1a10..7ff8919c 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -63,7 +63,7 @@ namespace xcpp , m_cout_buffer(std::bind(&interpreter::publish_stdout, this, _1)) , m_cerr_buffer(std::bind(&interpreter::publish_stderr, this, _1)) { - createInterpreter(Args(argv, argv + argc)); + createInterpreter(Args(argv + 1, argv + argc)); redirect_output(); // Bootstrap the execution engine init_includes(); From 0ef7b7599d74816e9ee85788258aad8c53c7221a Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 10 Mar 2024 21:49:38 +0000 Subject: [PATCH 38/69] Fix argv crash 2 --- src/xinterpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 7ff8919c..257016b8 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -63,7 +63,7 @@ namespace xcpp , m_cout_buffer(std::bind(&interpreter::publish_stdout, this, _1)) , m_cerr_buffer(std::bind(&interpreter::publish_stderr, this, _1)) { - createInterpreter(Args(argv + 1, argv + argc)); + createInterpreter(Args(argv ? argv + 1 : argv, argv + argc)); redirect_output(); // Bootstrap the execution engine init_includes(); From 5abd0eebdb335bbff1d39de883b546a173cbcbfa Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 10 Mar 2024 21:55:00 +0000 Subject: [PATCH 39/69] Cleanup debuging commands --- .github/workflows/main.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d560ce50..ebf724f4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,8 +79,6 @@ jobs: shell: bash -l {0} run: | cd build/test - echo | gcc -E -Wp,-v - - ls -la $CONDA_BUILD_SYSROOT export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0/include:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../x86_64-conda-linux-gnu/sysroot/usr/include ./test_xeus_cpp timeout-minutes: 4 @@ -89,10 +87,6 @@ jobs: shell: bash -l {0} run: | cd test - echo $CONDA_PREFIX - echo $PREFIX - echo $BUILD_PREFIX - find / | grep xcpp pytest . --reruns 5 - name: Prepare code coverage report From 3fb19d95d3502d7fbf6e20c7506191c1abe7b17f Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Sun, 10 Mar 2024 22:01:27 +0000 Subject: [PATCH 40/69] Try fix pytest run --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebf724f4..b5b944f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,8 +86,7 @@ jobs: - name: test shell: bash -l {0} run: | - cd test - pytest . --reruns 5 + pytest test --reruns 5 - name: Prepare code coverage report if: ${{ success() && (matrix.coverage == true) }} From 471830484f83bacbd035f877a1f2a064aa8f1731 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 05:59:08 +0000 Subject: [PATCH 41/69] Try fix --- .github/workflows/main.yml | 4 +++- test/pytest.ini | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5b944f9..3a8c2ad2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,9 @@ jobs: - name: test shell: bash -l {0} run: | - pytest test --reruns 5 + export + conda info --envs + $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report if: ${{ success() && (matrix.coverage == true) }} diff --git a/test/pytest.ini b/test/pytest.ini index 5aacf83b..20d103d6 100644 --- a/test/pytest.ini +++ b/test/pytest.ini @@ -1,3 +1,4 @@ [pytest] testpaths = test -addopts = --nbval --current-env +#addopts = --nbval --current-env +addopts = --nbval --nbval-current-env \ No newline at end of file From af0d85aa815c2257c746fa1f4fb00678bd324b46 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 06:12:28 +0000 Subject: [PATCH 42/69] Try to fix 2 --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a8c2ad2..f9622a53 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,6 +88,8 @@ jobs: run: | export conda info --envs + echo "!!! $CONDA_PREFIX" + sudo ln -s $CONDA_PREFIX/bin/xcpp /bin/xcpp $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report From 04f36638159812350d55c1bf5b226325d54e1ca8 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 06:28:23 +0000 Subject: [PATCH 43/69] Try to fix 3 --- .github/workflows/main.yml | 2 +- CMakeLists.txt | 80 +++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 45 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f9622a53..4efa15ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,7 +89,7 @@ jobs: export conda info --envs echo "!!! $CONDA_PREFIX" - sudo ln -s $CONDA_PREFIX/bin/xcpp /bin/xcpp + #sudo ln -s $CONDA_PREFIX/bin/xcpp /bin/xcpp $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dca7311..7131f125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,15 +19,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") set(XEUS_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) -if ("${CMAKE_INSTALL_INCLUDEDIR}" STREQUAL "") - set(CMAKE_INSTALL_INCLUDEDIR "include") -endif() -if ("${CMAKE_INSTALL_LIBDIR}" STREQUAL "") - set(CMAKE_INSTALL_LIBDIR "lib") -endif() -if ("${CMAKE_INSTALL_BINDIR}" STREQUAL "") - set(CMAKE_INSTALL_BINDIR "bin") -endif() +enable_language(CXX) +set(CMAKE_CXX_EXTENSIONS NO) + +include(GNUInstallDirs) # Versionning # =========== @@ -46,49 +41,46 @@ message(STATUS "Building xeus-cpp v${${PROJECT_NAME}_VERSION}") # Configuration # ============= -include(GNUInstallDirs) - if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH) set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/") endif () -set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}") -set(CMAKE_PATH "$ENV{PATH}") -set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") -set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}") -set(CMAKE_VENV_PATH "$ENV{VENV}") - -message(STATUS "Debug: Replace in kernels") -message(STATUS "Debug: CMAKE_CPLUS_INCLUDE_PATH=${CMAKE_CPLUS_INCLUDE_PATH}") -message(STATUS "Debug: CMAKE_PATH=${CMAKE_PATH}") -message(STATUS "Debug: CMAKE_LD_LIBRARY_PATH=${CMAKE_LD_LIBRARY_PATH}") -message(STATUS "Debug: CMAKE_PYTHONPATH=${CMAKE_PYTHONPATH}") -message(STATUS "Debug: CMAKE_VENV_PATH=${CMAKE_VENV_PATH}") -message(STATUS "Debug: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}") -message(STATUS "Debug: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}") - - function(configure_kernel kernel) - configure_file ( + set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}") + set(CMAKE_PATH "$ENV{PATH}") + set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") + set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}") + set(CMAKE_VENV_PATH "$ENV{VENV}") + + message(STATUS "Debug: Replace in kernels") + message(STATUS "Debug: CMAKE_CPLUS_INCLUDE_PATH=${CMAKE_CPLUS_INCLUDE_PATH}") + message(STATUS "Debug: CMAKE_PATH=${CMAKE_PATH}") + message(STATUS "Debug: CMAKE_LD_LIBRARY_PATH=${CMAKE_LD_LIBRARY_PATH}") + message(STATUS "Debug: CMAKE_PYTHONPATH=${CMAKE_PYTHONPATH}") + message(STATUS "Debug: CMAKE_VENV_PATH=${CMAKE_VENV_PATH}") + message(STATUS "Debug: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}") + message(STATUS "Debug: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}") + + configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/kernel.json.in" "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/kernel.json" ) - file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.png") - foreach(file ${files}) - configure_file( - "${file}" - "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/" - COPYONLY - ) - endforeach() - file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.svg") - foreach(file ${files}) - configure_file( - "${file}" - "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/" - COPYONLY - ) - endforeach() + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.png") + foreach(file ${files}) + configure_file( + "${file}" + "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/" + COPYONLY + ) + endforeach() + file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.svg") + foreach(file ${files}) + configure_file( + "${file}" + "${CMAKE_CURRENT_BINARY_DIR}/${kernel}/" + COPYONLY + ) + endforeach() endfunction() file(GLOB _kernels LIST_DIRECTORIES true RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "share/jupyter/kernels/*") From 8ea96928a9373a92752050f42eecbd7cff51cc63 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 07:02:40 +0000 Subject: [PATCH 44/69] Try to fix 4 --- share/jupyter/kernels/clad-xcpp17/kernel.json.in | 2 +- share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in | 2 +- share/jupyter/kernels/omp-xcpp17/kernel.json.in | 2 +- share/jupyter/kernels/xcpp/kernel.json.in | 2 +- share/jupyter/kernels/xcpp11/kernel.json.in | 2 +- share/jupyter/kernels/xcpp14/kernel.json.in | 2 +- share/jupyter/kernels/xcpp17/kernel.json.in | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/share/jupyter/kernels/clad-xcpp17/kernel.json.in b/share/jupyter/kernels/clad-xcpp17/kernel.json.in index bd8836ad..5f3303e6 100644 --- a/share/jupyter/kernels/clad-xcpp17/kernel.json.in +++ b/share/jupyter/kernels/clad-xcpp17/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-fplugin=/opt/conda/lib/clad.so", diff --git a/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in b/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in index 904a375c..c17e6f59 100644 --- a/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in +++ b/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-cuda", diff --git a/share/jupyter/kernels/omp-xcpp17/kernel.json.in b/share/jupyter/kernels/omp-xcpp17/kernel.json.in index 3583b275..1e13edb1 100644 --- a/share/jupyter/kernels/omp-xcpp17/kernel.json.in +++ b/share/jupyter/kernels/omp-xcpp17/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-fopenmp", diff --git a/share/jupyter/kernels/xcpp/kernel.json.in b/share/jupyter/kernels/xcpp/kernel.json.in index 70c99e20..2d38915a 100644 --- a/share/jupyter/kernels/xcpp/kernel.json.in +++ b/share/jupyter/kernels/xcpp/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-cuda", diff --git a/share/jupyter/kernels/xcpp11/kernel.json.in b/share/jupyter/kernels/xcpp11/kernel.json.in index c7440e47..dfbdaf2a 100644 --- a/share/jupyter/kernels/xcpp11/kernel.json.in +++ b/share/jupyter/kernels/xcpp11/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-std=c++11"@CMAKE_OMP@ diff --git a/share/jupyter/kernels/xcpp14/kernel.json.in b/share/jupyter/kernels/xcpp14/kernel.json.in index 3c9a47f4..1a3dc5ef 100644 --- a/share/jupyter/kernels/xcpp14/kernel.json.in +++ b/share/jupyter/kernels/xcpp14/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-std=c++14", diff --git a/share/jupyter/kernels/xcpp17/kernel.json.in b/share/jupyter/kernels/xcpp17/kernel.json.in index ee116fc5..79f3dc32 100644 --- a/share/jupyter/kernels/xcpp17/kernel.json.in +++ b/share/jupyter/kernels/xcpp17/kernel.json.in @@ -7,7 +7,7 @@ "PYTHONPATH":"@CMAKE_PYTHONPATH@" }, "argv": [ - "@CMAKE_VENV_PATH@/bin/xcpp", + "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", "-std=c++17"@CMAKE_OMP@ From 424b47954019735cb3b8f99af7386e39b2de8ed6 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 08:00:59 +0000 Subject: [PATCH 45/69] Try to fix 5 --- CMakeLists.txt | 1 + share/jupyter/kernels/clad-xcpp17/kernel.json.in | 1 + share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in | 1 + share/jupyter/kernels/omp-xcpp17/kernel.json.in | 1 + share/jupyter/kernels/xcpp/kernel.json.in | 1 + share/jupyter/kernels/xcpp11/kernel.json.in | 1 + share/jupyter/kernels/xcpp14/kernel.json.in | 1 + share/jupyter/kernels/xcpp17/kernel.json.in | 1 + test/pytest.ini | 2 +- test/test_interpreter.cpp | 4 ++-- 10 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7131f125..a839e21e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ message(STATUS "Building xeus-cpp v${${PROJECT_NAME}_VERSION}") if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH) set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/") + set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/17) endif () function(configure_kernel kernel) diff --git a/share/jupyter/kernels/clad-xcpp17/kernel.json.in b/share/jupyter/kernels/clad-xcpp17/kernel.json.in index 5f3303e6..84b82da0 100644 --- a/share/jupyter/kernels/clad-xcpp17/kernel.json.in +++ b/share/jupyter/kernels/clad-xcpp17/kernel.json.in @@ -10,6 +10,7 @@ "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-fplugin=/opt/conda/lib/clad.so", "-std=c++17"@CMAKE_OMP@ ], diff --git a/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in b/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in index c17e6f59..45edb421 100644 --- a/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in +++ b/share/jupyter/kernels/cppinterop-xcpp17/kernel.json.in @@ -11,6 +11,7 @@ "-f", "{connection_file}", "-cuda", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-std=c++17"@CMAKE_OMP@ ], "language": "CUDA", diff --git a/share/jupyter/kernels/omp-xcpp17/kernel.json.in b/share/jupyter/kernels/omp-xcpp17/kernel.json.in index 1e13edb1..fe906d03 100644 --- a/share/jupyter/kernels/omp-xcpp17/kernel.json.in +++ b/share/jupyter/kernels/omp-xcpp17/kernel.json.in @@ -10,6 +10,7 @@ "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-fopenmp", "-std=c++17" ], diff --git a/share/jupyter/kernels/xcpp/kernel.json.in b/share/jupyter/kernels/xcpp/kernel.json.in index 2d38915a..ab65403a 100644 --- a/share/jupyter/kernels/xcpp/kernel.json.in +++ b/share/jupyter/kernels/xcpp/kernel.json.in @@ -11,6 +11,7 @@ "-f", "{connection_file}", "-cuda", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-std=c++17"@CMAKE_OMP@ ], "language": "cpp", diff --git a/share/jupyter/kernels/xcpp11/kernel.json.in b/share/jupyter/kernels/xcpp11/kernel.json.in index dfbdaf2a..6cf70935 100644 --- a/share/jupyter/kernels/xcpp11/kernel.json.in +++ b/share/jupyter/kernels/xcpp11/kernel.json.in @@ -10,6 +10,7 @@ "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-std=c++11"@CMAKE_OMP@ ], "language": "C++11", diff --git a/share/jupyter/kernels/xcpp14/kernel.json.in b/share/jupyter/kernels/xcpp14/kernel.json.in index 1a3dc5ef..a4dcf764 100644 --- a/share/jupyter/kernels/xcpp14/kernel.json.in +++ b/share/jupyter/kernels/xcpp14/kernel.json.in @@ -10,6 +10,7 @@ "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-std=c++14", "-fno-exceptions", "-O2", diff --git a/share/jupyter/kernels/xcpp17/kernel.json.in b/share/jupyter/kernels/xcpp17/kernel.json.in index 79f3dc32..c0852cfb 100644 --- a/share/jupyter/kernels/xcpp17/kernel.json.in +++ b/share/jupyter/kernels/xcpp17/kernel.json.in @@ -10,6 +10,7 @@ "@XEUS_CPP_KERNELSPEC_PATH@xcpp", "-f", "{connection_file}", + "-resource-dir", "@XEUS_CPP_RESOURCE_DIR@", "-std=c++17"@CMAKE_OMP@ ], "language": "C++17", diff --git a/test/pytest.ini b/test/pytest.ini index 20d103d6..e580d2bc 100644 --- a/test/pytest.ini +++ b/test/pytest.ini @@ -1,4 +1,4 @@ [pytest] testpaths = test #addopts = --nbval --current-env -addopts = --nbval --nbval-current-env \ No newline at end of file +addopts = --nbval --nbval-current-env diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 392b58d9..ed453dca 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -14,8 +14,8 @@ TEST_SUITE("execute_request") { TEST_CASE("fetch_documentation") { - - xcpp::interpreter interpreter(0, nullptr); + std::vector Args = {"-v", "resource-dir", "....."}; + xcpp::interpreter interpreter(Args.size(), Args.data()); std::string code = "?std::vector"; std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector"; From c6c0de46d345db002caba256872e73ce8d692158 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 10:46:23 +0000 Subject: [PATCH 46/69] Try to fix 6 --- test/test_interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index ed453dca..96ffa477 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -14,7 +14,7 @@ TEST_SUITE("execute_request") { TEST_CASE("fetch_documentation") { - std::vector Args = {"-v", "resource-dir", "....."}; + std::vector Args = {/*"-v", "resource-dir", "....."*/}; xcpp::interpreter interpreter(Args.size(), Args.data()); std::string code = "?std::vector"; From 76ad13c69331b03e2c0a64485f6ef56510dace5b Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 20:02:34 +0200 Subject: [PATCH 47/69] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a839e21e..b8f76e97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,7 +319,7 @@ macro(xeus_cpp_create_target target_name linkage output_name) set(XEUS_CPP_XEUS_TARGET xeus-static) endif () - target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} ${CPPINTEROP_INSTALL_PREFIX}/lib/libclangCppInterOp.so pugixml argparse::argparse xtl Python::Python) + target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl Python::Python) if (WIN32 OR CYGWIN) # elseif (APPLE) From bf968639b9913b3eb884b00446efd807418df240 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 18:22:45 +0000 Subject: [PATCH 48/69] Allow debugging wasm --- .github/workflows/main.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4efa15ee..10762d74 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,11 +42,6 @@ jobs: environment-file: environment-dev.yml environment-name: xeus-cpp - - name: mamba update all - shell: bash -l {0} - run: | - $HOME/micromamba-bin/micromamba update --all - - name: install cxx compiler shell: bash -l {0} run: | From d300c9573925903fd76b6b4dd3f3eebd1695b4c6 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 18:44:03 +0000 Subject: [PATCH 49/69] Emscripten finds Development.Embed and not Python::Python --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8f76e97..53645c67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,7 +319,14 @@ macro(xeus_cpp_create_target target_name linkage output_name) set(XEUS_CPP_XEUS_TARGET xeus-static) endif () - target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl Python::Python) + target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl) + if (EMSCRIPTEN) + # For some reason emscripten cannot find Python::Python. + target_link_libraries(${target_name} PUBLIC Development.Embed) + else() + target_link_libraries(${target_name} PUBLIC Python::Python) + endif() + if (WIN32 OR CYGWIN) # elseif (APPLE) From 0859ed0acf60f600d1628b0e776a2beedf2c0fc3 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 19:31:46 +0000 Subject: [PATCH 50/69] Don't build the pythonexec just yet --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53645c67..05c9fb37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,12 +210,12 @@ set(XEUS_CPP_SRC src/xparser.hpp src/xmagics/os.hpp src/xmagics/os.cpp - src/xmagics/pythonexec.hpp - src/xmagics/pythonexec.cpp ) if(EMSCRIPTEN) list(APPEND XEUS_CPP_SRC src/xinterpreter_wasm.cpp) +else() + list(APPEND XEUS_CPP_SRC src/xmagics/pythonexec.hpp src/xmagics/pythonexec.cpp) endif() set(XEUS_CPP_MAIN_SRC From eae965041ba98cae57e789ae45dcf6ac50126444 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 20:19:37 +0000 Subject: [PATCH 51/69] More wasm fixes --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05c9fb37..0dd536dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ set(XEUS_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) enable_language(CXX) set(CMAKE_CXX_EXTENSIONS NO) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) include(GNUInstallDirs) @@ -320,10 +321,7 @@ macro(xeus_cpp_create_target target_name linkage output_name) endif () target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl) - if (EMSCRIPTEN) - # For some reason emscripten cannot find Python::Python. - target_link_libraries(${target_name} PUBLIC Development.Embed) - else() + if (NOT EMSCRIPTEN) target_link_libraries(${target_name} PUBLIC Python::Python) endif() From 8bda4fea90198d0142b7e6a93e7ebbf33b8f8583 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 20:48:27 +0000 Subject: [PATCH 52/69] Try setting the lib suffix --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dd536dc..84c594d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,6 +166,7 @@ endif () if(EMSCRIPTEN) # ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") From eb55cd6e6263a3268a98175f25113042497a9e0f Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 21:59:17 +0000 Subject: [PATCH 53/69] Fix pytest --- .github/workflows/main.yml | 5 +---- Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10762d74..5777a1a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,10 +81,7 @@ jobs: - name: test shell: bash -l {0} run: | - export - conda info --envs - echo "!!! $CONDA_PREFIX" - #sudo ln -s $CONDA_PREFIX/bin/xcpp /bin/xcpp + ln -s $CONDA_PREFIX/share/jupyter/kernels/xcpp $CONDA_PREFIX/envs/xeus-xcpp/share/jupyter/kernels/xcpp $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report diff --git a/Dockerfile b/Dockerfile index 1020b0cb..9fec1e7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -167,6 +167,7 @@ RUN \ 'jupyter_kernel_test>=0.4.3' \ nbval \ pytest-rerunfailures \ + doctest \ && \ hash -r && \ pip install ipython && \ @@ -240,7 +241,7 @@ RUN \ cd .. && \ # Run cppyy #TODO: Fix cppyy path (/home/jovyan) to path to installed module - python -c "import cppyy" && \ + ###python -c "import cppyy" && \ # # Build and Install xeus-cpp # From dba64eac6af1b5feeec927e176cbb13f3a6162d7 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 22:05:34 +0000 Subject: [PATCH 54/69] Fix pytest 1 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5777a1a6..7da47f56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,7 +81,7 @@ jobs: - name: test shell: bash -l {0} run: | - ln -s $CONDA_PREFIX/share/jupyter/kernels/xcpp $CONDA_PREFIX/envs/xeus-xcpp/share/jupyter/kernels/xcpp + ln -s /opt/conda/share/jupyter/kernels/xcpp $CONDA_PREFIX/share/jupyter/kernels/xcpp $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report From 36b3e729a9b30c643fc6ac0c08ff1ca38d85d2ca Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Mon, 11 Mar 2024 23:02:49 +0000 Subject: [PATCH 55/69] Fix --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7da47f56..b6f86607 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,7 +81,9 @@ jobs: - name: test shell: bash -l {0} run: | - ln -s /opt/conda/share/jupyter/kernels/xcpp $CONDA_PREFIX/share/jupyter/kernels/xcpp + pwd + export + ls -l $CONDA_PREFIX/share/jupyter/kernels $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report From c17f736636d3d5ecef535c74e3ea0c7f1e531edb Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 12 Mar 2024 06:39:09 +0000 Subject: [PATCH 56/69] Try 1 --- test/test_interpreter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 96ffa477..48d671d9 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -17,8 +17,10 @@ TEST_SUITE("execute_request") std::vector Args = {/*"-v", "resource-dir", "....."*/}; xcpp::interpreter interpreter(Args.size(), Args.data()); - std::string code = "?std::vector"; - std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector"; + //std::string code = "?std::vector"; + //std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector"; + std::string code = "#include \\n#include \"xcpp/xdisplay.hpp\"\\nstd::string test(\"foobar\");\\nxcpp::display(test);"; + std::string inspect_result = "foobar"; nl::json user_expressions = nl::json::object(); nl::json result = interpreter.execute_request( From cc90a16dce6faa36a73b7b963fc5b7d24d169691 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Tue, 12 Mar 2024 18:48:05 +0000 Subject: [PATCH 57/69] Fix --- test/test_interpreter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 48d671d9..e422b3ae 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -17,10 +17,10 @@ TEST_SUITE("execute_request") std::vector Args = {/*"-v", "resource-dir", "....."*/}; xcpp::interpreter interpreter(Args.size(), Args.data()); - //std::string code = "?std::vector"; - //std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector"; - std::string code = "#include \\n#include \"xcpp/xdisplay.hpp\"\\nstd::string test(\"foobar\");\\nxcpp::display(test);"; - std::string inspect_result = "foobar"; + std::string code = "?std::vector"; + std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector"; + //std::string code = "#include \\n#include \"xcpp/xdisplay.hpp\"\\nstd::string test(\"foobar\");\\nxcpp::display(test);"; + //std::string inspect_result = "foobar"; nl::json user_expressions = nl::json::object(); nl::json result = interpreter.execute_request( From 1e3a995f3f6aee6658a0a9e88e99d72dd442f3a4 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Wed, 13 Mar 2024 11:34:44 +0000 Subject: [PATCH 58/69] Extend debug time --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b6f86607..750735cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -180,7 +180,7 @@ jobs: emsdk activate ${{matrix.emsdk_ver}} source $CONDA_EMSDK_DIR/emsdk_env.sh micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32 - + mkdir build pushd build @@ -202,4 +202,4 @@ jobs: if: ${{ failure() && runner.debug }} uses: mxschmitt/action-tmate@v3 # When debugging increase to a suitable value! - timeout-minutes: 30 + timeout-minutes: 90 From 7bf6909d4d10b51da05b062e86c1d1619e1a6d4a Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Wed, 13 Mar 2024 12:36:34 +0000 Subject: [PATCH 59/69] Debug 90 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 750735cd..171733f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -111,7 +111,7 @@ jobs: if: ${{ failure() && runner.debug }} uses: mxschmitt/action-tmate@v3 # When debugging increase to a suitable value! - timeout-minutes: 30 + timeout-minutes: 90 win: runs-on: ${{ matrix.os }} @@ -202,4 +202,4 @@ jobs: if: ${{ failure() && runner.debug }} uses: mxschmitt/action-tmate@v3 # When debugging increase to a suitable value! - timeout-minutes: 90 + timeout-minutes: 30 From 3990230f4414fb6734fab31fbf985df15b8c1a0d Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Wed, 13 Mar 2024 12:51:32 +0000 Subject: [PATCH 60/69] Debug 60 --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 171733f8..f15db1de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,9 @@ concurrency: jobs: unix: - + runs-on: ${{ matrix.os }} - + strategy: fail-fast: false matrix: @@ -111,11 +111,12 @@ jobs: if: ${{ failure() && runner.debug }} uses: mxschmitt/action-tmate@v3 # When debugging increase to a suitable value! - timeout-minutes: 90 + timeout-minutes: 60 + win: - + runs-on: ${{ matrix.os }} - + strategy: fail-fast: false matrix: From f65cd089914310fb53706f08bbf783ab2aadcf45 Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Wed, 13 Mar 2024 14:06:32 +0000 Subject: [PATCH 61/69] Debug 30 --- .github/workflows/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f15db1de..d939f797 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,9 +81,6 @@ jobs: - name: test shell: bash -l {0} run: | - pwd - export - ls -l $CONDA_PREFIX/share/jupyter/kernels $CONDA_PREFIX/bin/pytest test --reruns 5 - name: Prepare code coverage report @@ -111,7 +108,7 @@ jobs: if: ${{ failure() && runner.debug }} uses: mxschmitt/action-tmate@v3 # When debugging increase to a suitable value! - timeout-minutes: 60 + timeout-minutes: 30 win: From 4ad7dc04634910b5596a9639526a417493f21b70 Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:44:28 +0200 Subject: [PATCH 62/69] Update main.yml From 7ccb22836e1087f11c8fe99e4052de2145b3d749 Mon Sep 17 00:00:00 2001 From: Alexander Penev <7923188+alexander-penev@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:54:02 +0200 Subject: [PATCH 63/69] Update main.yml --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d939f797..788ebcc9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: mamba update all + shell: bash -l {0} + run: | + $HOME/micromamba-bin/micromamb update --all + - name: install mamba uses: mamba-org/provision-with-micromamba@main with: From 483e047b7225b59541f91ff9e534b84082c94779 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 5 Mar 2024 13:25:29 +0200 Subject: [PATCH 64/69] Update main.yml --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 788ebcc9..58d19ae9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,17 +36,17 @@ jobs: steps: - uses: actions/checkout@v3 - - name: mamba update all - shell: bash -l {0} - run: | - $HOME/micromamba-bin/micromamb update --all - - name: install mamba uses: mamba-org/provision-with-micromamba@main with: environment-file: environment-dev.yml environment-name: xeus-cpp + - name: mamba update all + shell: bash -l {0} + run: | + $HOME/micromamba-bin/micromamba update --all + - name: install cxx compiler shell: bash -l {0} run: | From 040d30732e08b157ca76991062a6f5ac3bd2e271 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 18:22:45 +0000 Subject: [PATCH 65/69] Allow debugging wasm --- .github/workflows/main.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 58d19ae9..d939f797 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,11 +42,6 @@ jobs: environment-file: environment-dev.yml environment-name: xeus-cpp - - name: mamba update all - shell: bash -l {0} - run: | - $HOME/micromamba-bin/micromamba update --all - - name: install cxx compiler shell: bash -l {0} run: | From 02e79816a1edc9db93c1350c720ea1c327d3f5b2 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 18:44:03 +0000 Subject: [PATCH 66/69] Emscripten finds Development.Embed and not Python::Python --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84c594d5..7d9b0377 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,7 +322,10 @@ macro(xeus_cpp_create_target target_name linkage output_name) endif () target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl) - if (NOT EMSCRIPTEN) + if (EMSCRIPTEN) + # For some reason emscripten cannot find Python::Python. + target_link_libraries(${target_name} PUBLIC Development.Embed) + else() target_link_libraries(${target_name} PUBLIC Python::Python) endif() From 8a334e5113534d87c7486ed2bdfd2387f96b1764 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 11 Mar 2024 20:51:50 +0000 Subject: [PATCH 67/69] Try setting the so->a --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d9b0377..3d190dde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,7 @@ endif () if(EMSCRIPTEN) # ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".a") endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib") From 804975691cf7acb083beea326010bef0f3b22a5c Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 14 Mar 2024 07:19:05 +0000 Subject: [PATCH 68/69] Add back the GNUInstallDirs --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d190dde..05331842 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,6 @@ enable_language(CXX) set(CMAKE_CXX_EXTENSIONS NO) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -include(GNUInstallDirs) - # Versionning # =========== @@ -42,6 +40,8 @@ message(STATUS "Building xeus-cpp v${${PROJECT_NAME}_VERSION}") # Configuration # ============= +include(GNUInstallDirs) + if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH) set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/") set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/17) From 0e655eff89cdbb9a6b48217f830bab848762ba69 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 14 Mar 2024 07:30:49 +0000 Subject: [PATCH 69/69] Remove unused set --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05331842..09a9def0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,6 @@ endif () if(EMSCRIPTEN) # ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0) set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"") - set(CMAKE_SHARED_LIBRARY_SUFFIX ".a") endif() find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib")