diff --git a/.github/workflows/deploy-github-page.yml b/.github/workflows/deploy-github-page.yml index 905d33c..18c70d5 100644 --- a/.github/workflows/deploy-github-page.yml +++ b/.github/workflows/deploy-github-page.yml @@ -23,7 +23,7 @@ jobs: - name: Github-page steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: fetch-depth: 0 @@ -66,7 +66,7 @@ jobs: --XeusAddon.prefix=${{ env.PREFIX }} \ --XeusAddon.mounts=$PREFIX/share/octave:/share/octave \ --XeusAddon.mounts=$PREFIX/share/xeus-octave:/share/xeus-octave \ - --XeusAddon.default_channels=https://repo.prefix.dev/emscripten-forge-dev \ + --XeusAddon.default_channels=https://repo.prefix.dev/emscripten-forge-4x \ --XeusAddon.default_channels=https://repo.prefix.dev/conda-forge \ --contents notebooks/xeus-octave-wasm.ipynb \ --output-dir dist diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2a23cd7..bced529 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Install micromamba uses: mamba-org/setup-micromamba@v2 with: @@ -45,7 +45,7 @@ jobs: static-analysis: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Install micromamba uses: mamba-org/setup-micromamba@v2 with: @@ -54,7 +54,7 @@ jobs: cache-downloads: true - name: Set PYTHON_HASH run: echo "PYTHON_HASH=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - - uses: actions/cache@v4 + - uses: actions/cache@v5 with: path: ~/.cache/pre-commit key: precommit-v1-${{ env.PYTHON_HASH }}-${{ hashFiles('.pre-commit-config.yaml') }} @@ -64,7 +64,7 @@ jobs: test-doc: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Install micromamba uses: mamba-org/setup-micromamba@v2 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index da4bd07..126bae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,27 +33,6 @@ set( ) message(STATUS "Building xeus-octave v${${PROJECT_NAME}_VERSION}") -# Configuration -# ============= - -include(GNUInstallDirs) - -if(NOT DEFINED XEUS_OCTAVE_KERNELSPEC_PATH) - set(XEUS_OCTAVE_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/") -endif() - -if(EMSCRIPTEN) - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel_wasm.json.in" - "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel.json" - ) -else() - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel.json.in" - "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel.json" - ) -endif() - # Build options # ============= @@ -104,6 +83,32 @@ endif() find_package(PkgConfig REQUIRED) pkg_check_modules(octinterp REQUIRED IMPORTED_TARGET GLOBAL octinterp>=10.0) +# Configuration +# ============= + +include(GNUInstallDirs) + +if(NOT DEFINED XEUS_OCTAVE_KERNELSPEC_PATH) + set(XEUS_OCTAVE_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/") +endif() + +if(EMSCRIPTEN) + # Requires version variable, octinterp_VERSION, set by Octave dependency + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel_wasm.json.in" + "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel.json" + ) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/wasm/env_vars.js.in" + "${CMAKE_CURRENT_SOURCE_DIR}/wasm/env_vars.js" + ) +else() + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel.json.in" + "${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xoctave/kernel.json" + ) +endif() + # Compiler flags # ============== @@ -267,9 +272,12 @@ macro(xeus_octave_create_target target_name linkage output_name) if(EMSCRIPTEN) include(WasmBuildOptions) - target_compile_options(${target_name} PRIVATE ${octinterp_CFLAGS}) xeus_wasm_compile_options(${target_name}) - target_link_libraries(${target_name} PUBLIC xeus ${octinterp_STATIC_LIBRARIES}) + target_link_libraries( + ${target_name} + PUBLIC xeus PkgConfig::octinterp + PRIVATE FortranRuntime + ) else() target_link_libraries( ${target_name} diff --git a/environment-wasm-build.yml b/environment-wasm-build.yml index d82ddd2..399bbc0 100644 --- a/environment-wasm-build.yml +++ b/environment-wasm-build.yml @@ -1,13 +1,13 @@ name: xeus-octave-wasm-build channels: - - https://repo.prefix.dev/emscripten-forge-dev + - https://repo.prefix.dev/emscripten-forge-4x - conda-forge dependencies: # Xeus-Octave - cmake - make - pkg-config - - emscripten_emscripten-wasm32==3.1.73 + - emscripten_emscripten-wasm32 # JupyterLite - jupyterlite-core - jupyter_server diff --git a/environment-wasm-host.yml b/environment-wasm-host.yml index 74087fc..eea5d9e 100644 --- a/environment-wasm-host.yml +++ b/environment-wasm-host.yml @@ -1,6 +1,6 @@ name: xeus-octave-wasm-host channels: - - https://repo.prefix.dev/emscripten-forge-dev + - https://repo.prefix.dev/emscripten-forge-4x - conda-forge dependencies: - xeus @@ -8,7 +8,6 @@ dependencies: - nlohmann_json - nlohmann_json-abi - octave - - octave-fuzzy-logic-toolkit - libpng - zlib - libflang @@ -17,3 +16,6 @@ dependencies: - liblapack - freetype - plotly +# Optional + - octave-fuzzy-logic-toolkit + - octave-splines diff --git a/share/jupyter/kernels/xoctave/kernel_wasm.json.in b/share/jupyter/kernels/xoctave/kernel_wasm.json.in index d1f5555..4908e84 100644 --- a/share/jupyter/kernels/xoctave/kernel_wasm.json.in +++ b/share/jupyter/kernels/xoctave/kernel_wasm.json.in @@ -7,10 +7,12 @@ ], "language": "Octave", "metadata": { - "debugger": false, - "shared": { - "libxeus.so": "lib/libxeus.so", - "libz.so": "lib/libz.so" - } + "debugger": false, + "shared": { + "libxeus.so": "lib/libxeus.so", + "liboctinterp.so": "lib/octave/@octinterp_VERSION@/liboctinterp.so", + "liboctave.so": "lib/octave/@octinterp_VERSION@/liboctave.so", + "libz.so": "lib/libz.so" + } } } diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 375c638..d5170cc 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -437,13 +437,6 @@ void xoctave_interpreter::configure_impl() // Initialize interpreter m_octave_interpreter.execute(); -#ifdef XEUS_OCTAVE_PKG_REBUILD - // Run pkg rebuild upon starting the kernel - std::string pkg_rebuild("pkg rebuild"); - int status = 0; - m_octave_interpreter.eval_string(pkg_rebuild, true, status); -#endif - // Fix disp function and clear display function m_octave_interpreter.get_symbol_table().install_built_in_function("display", octave_value()); @@ -493,6 +486,11 @@ void xoctave_interpreter::configure_impl() m_octave_interpreter.get_symbol_table().install_built_in_function( "XOCTAVE", new octave_builtin([](octave_value_list const&, int) { return ovl(XEUS_OCTAVE_VERSION); }, "XOCTAVE") ); + +#ifdef XEUS_OCTAVE_PKG_REBUILD + // Rebuild package database + octave::feval("pkg", ovl("rebuild")); +#endif } namespace diff --git a/wasm/env_vars.js b/wasm/env_vars.js deleted file mode 100644 index 875ae00..0000000 --- a/wasm/env_vars.js +++ /dev/null @@ -1,10 +0,0 @@ -Module["onRuntimeInitialized"] = () => { - console.log("Octave is ready!"); -} - -Module["preRun"] = () => { - ENV["OCTAVE_HOME"] = "/"; - ENV["OCTAVE_PATH"] = "/share/xeus-octave::/share/octave/site/m:/share/octave/site/m/startup:/share/octave/10.2.0/m:/share/octave/10.2.0/m/audio:/share/octave/10.2.0/m/deprecated:/share/octave/10.2.0/m/elfun:/share/octave/10.2.0/m/general:/share/octave/10.2.0/m/geometry:/share/octave/10.2.0/m/gui:/share/octave/10.2.0/m/help:/share/octave/10.2.0/m/image:/share/octave/10.2.0/m/io:/share/octave/10.2.0/m/legacy:/share/octave/10.2.0/m/linear-algebra:/share/octave/10.2.0/m/miscellaneous:/share/octave/10.2.0/m/ode:/share/octave/10.2.0/m/optimization:/share/octave/10.2.0/m/path:/share/octave/10.2.0/m/pkg:/share/octave/10.2.0/m/plot:/share/octave/10.2.0/m/plot/appearance:/share/octave/10.2.0/m/plot/draw:/share/octave/10.2.0/m/plot/util:/share/octave/10.2.0/m/polynomial:/share/octave/10.2.0/m/prefs:/share/octave/10.2.0/m/profiler:/share/octave/10.2.0/m/set:/share/octave/10.2.0/m/signal:/share/octave/10.2.0/m/sparse:/share/octave/10.2.0/m/specfun:/share/octave/10.2.0/m/special-matrix:/share/octave/10.2.0/m/startup:/share/octave/10.2.0/m/statistics:/share/octave/10.2.0/m/strings:/share/octave/10.2.0/m/testfun:/share/octave/10.2.0/m/time:/share/octave/10.2.0/m/web:/share/octave/10.2.0/data"; - ENV["OCTAVE_BUILT_IN_DOCSTRINGS_FILE"] = "/share/octave/10.2.0/etc/built-in-docstrings"; - ENV["OCTAVE_TEXI_MACROS_FILE"] = "/share/octave/10.2.0/etc/macros.texi"; -}; diff --git a/wasm/env_vars.js.in b/wasm/env_vars.js.in new file mode 100644 index 0000000..33beaa4 --- /dev/null +++ b/wasm/env_vars.js.in @@ -0,0 +1,10 @@ +Module["onRuntimeInitialized"] = () => { + console.log("Octave is ready!"); +} + +Module["preRun"] = () => { + ENV["OCTAVE_HOME"] = "/"; + ENV["OCTAVE_PATH"] = "/share/xeus-octave::/share/octave/site/m:/share/octave/site/m/startup:/share/octave/@octinterp_VERSION@/m:/share/octave/@octinterp_VERSION@/m/audio:/share/octave/@octinterp_VERSION@/m/deprecated:/share/octave/@octinterp_VERSION@/m/elfun:/share/octave/@octinterp_VERSION@/m/general:/share/octave/@octinterp_VERSION@/m/geometry:/share/octave/@octinterp_VERSION@/m/gui:/share/octave/@octinterp_VERSION@/m/help:/share/octave/@octinterp_VERSION@/m/image:/share/octave/@octinterp_VERSION@/m/io:/share/octave/@octinterp_VERSION@/m/legacy:/share/octave/@octinterp_VERSION@/m/linear-algebra:/share/octave/@octinterp_VERSION@/m/miscellaneous:/share/octave/@octinterp_VERSION@/m/ode:/share/octave/@octinterp_VERSION@/m/optimization:/share/octave/@octinterp_VERSION@/m/path:/share/octave/@octinterp_VERSION@/m/pkg:/share/octave/@octinterp_VERSION@/m/plot:/share/octave/@octinterp_VERSION@/m/plot/appearance:/share/octave/@octinterp_VERSION@/m/plot/draw:/share/octave/@octinterp_VERSION@/m/plot/util:/share/octave/@octinterp_VERSION@/m/polynomial:/share/octave/@octinterp_VERSION@/m/prefs:/share/octave/@octinterp_VERSION@/m/profiler:/share/octave/@octinterp_VERSION@/m/set:/share/octave/@octinterp_VERSION@/m/signal:/share/octave/@octinterp_VERSION@/m/sparse:/share/octave/@octinterp_VERSION@/m/specfun:/share/octave/@octinterp_VERSION@/m/special-matrix:/share/octave/@octinterp_VERSION@/m/startup:/share/octave/@octinterp_VERSION@/m/statistics:/share/octave/@octinterp_VERSION@/m/strings:/share/octave/@octinterp_VERSION@/m/testfun:/share/octave/@octinterp_VERSION@/m/time:/share/octave/@octinterp_VERSION@/m/web:/share/octave/@octinterp_VERSION@/data"; + ENV["OCTAVE_BUILT_IN_DOCSTRINGS_FILE"] = "/share/octave/@octinterp_VERSION@/etc/built-in-docstrings"; + ENV["OCTAVE_TEXI_MACROS_FILE"] = "/share/octave/@octinterp_VERSION@/etc/macros.texi"; +};