Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update to xeus 5 #2748

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be one of: Debug, Release (current value: '${CMAKE_BUILD_TYPE}')")
endif ()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LPYTHON_CXX_NO_RTTI_FLAG "-fno-rtti")
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(LPYTHON_CXX_NO_RTTI_FLAG "-fno-rtti")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(LPYTHON_CXX_NO_RTTI_FLAG "/GR-")
endif ()
# xeus does use `dynamic_cast` and thus needs rtti (otherwise it segfaults)
if (NOT WITH_XEUS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LPYTHON_CXX_NO_RTTI_FLAG "-fno-rtti")
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(LPYTHON_CXX_NO_RTTI_FLAG "-fno-rtti")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(LPYTHON_CXX_NO_RTTI_FLAG "/GR-")
endif ()
endif(NOT WITH_XEUS)


# For CMAKE_INSTALL_BINDIR:
Expand Down Expand Up @@ -205,19 +208,20 @@ if (WITH_LLVM)
set(HAVE_LFORTRAN_LLVM yes)
endif()

# XEUS (Fortran kernel)
# XEUS (Python kernel)
set(WITH_XEUS no CACHE BOOL "Build with XEUS support")
if (WITH_XEUS)
find_package(xeus 0.24.1 REQUIRED)
set(HAVE_LFORTRAN_XEUS yes)
find_package(xeus 5.1.0 REQUIRED)
find_package(xeus-zmq 3.0.0 REQUIRED)
set(HAVE_LPYTHON_XEUS yes)

# Generate kernel.json with correct paths
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/fortran/kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels/fortran/kernel.json"
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/python/kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels/python/kernel.json"
)

# Configuration and data directories for Jupyter and LFortran
# Configuration and data directories for Jupyter and LPython
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")

# Install Jupyter kernelspecs
Expand Down
2 changes: 1 addition & 1 deletion ci/azure_install_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -ex
conda config --set always_yes yes --set changeps1 no
conda info -a
conda update -q conda
conda install -c conda-forge python=3.8 re2c bison=3.4 m4 xonsh llvmdev=11.0.1 toml cmake=3.17.0 jupyter pytest xeus=1.0.1 xtl nlohmann_json cppzmq jupyter_kernel_test
conda install -c conda-forge python=3.8 re2c bison=3.4 m4 xonsh=0.16.0 llvmdev=11.0.1 toml cmake=3.17.0 jupyter pytest xeus=5.1.0 xeus-zmq=3.0.0 nlohmann_json=3.11.3 jupyter_kernel_test
export MACOSX_DEPLOYMENT_TARGET="10.12"
export CONDA_PREFIX=/usr/local/miniconda
export LFORTRAN_CMAKE_GENERATOR="Unix Makefiles"
Expand Down
7 changes: 3 additions & 4 deletions ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ dependencies:
- toml
- pytest
- jupyter
- xeus=1.0.1
- xtl
- nlohmann_json
- cppzmq
- xeus=5.1.0
- xeus-zmq=3.0.0
- nlohmann_json=3.11.3
- jupyter_kernel_test
- xonsh
- re2c
Expand Down
32 changes: 32 additions & 0 deletions doc/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,38 @@ You can run the following examples manually in a terminal:
./src/bin/lpython --show-c examples/expr2.py
```

## Enabling the Jupyter Kernel

To install the Jupyter kernel, install the following Conda packages also:
```
conda install xeus=5.1.0 xeus-zmq=3.0.0 nlohmann_json
```
and enable the kernel by `-DWITH_XEUS=yes` and install into `$CONDA_PREFIX`. For
example:
```
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DWITH_XEUS=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" \
.
cmake --build . -j4 --target install
```
To use it, install Jupyter (`conda install jupyter`) and test that the LPython
kernel was found:
```
jupyter kernelspec list --json
```
Then launch a Jupyter notebook as follows:
```
jupyter notebook
```
Click `New->Python`. To launch a terminal jupyter LPython console:
```
jupyter console --kernel=python
```

## Found a bug?
Please report any bugs you find at our issue tracker [here](https://github.com/lcompilers/lpython/issues). Or, even better, fork the repository on GitHub and create a Pull Request (PR).

Expand Down
7 changes: 7 additions & 0 deletions environment_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ dependencies:
- make
- re2c
- toml
- pytest
- jupyter
- xeus=5.1.0
- xeus-zmq=3.0.0
- nlohmann_json=3.11.3
- jupyter_kernel_test
- xonsh=0.16.0
- zlib
- cmake
- numpy
Expand Down
8 changes: 7 additions & 1 deletion environment_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ dependencies:
- make
- re2c
- toml
- pytest
- jupyter
- xeus=5.1.0
- xeus-zmq=3.0.0
- nlohmann_json=3.11.3
- jupyter_kernel_test
- zlib
- cmake
- ninja
- numpy
- xonsh
- xonsh=0.16.0
- flake8
- setuptools
- python=3.10.2
Expand Down
Loading