Skip to content

Add initial Julia wrapper for MUSICA#736

Merged
K20shores merged 8 commits intomainfrom
copilot/create-initial-julia-wrapper
Jan 28, 2026
Merged

Add initial Julia wrapper for MUSICA#736
K20shores merged 8 commits intomainfrom
copilot/create-initial-julia-wrapper

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

Adds a julia package

  • return the version number
  • add github actions
  • add a readme

Fixes #639

  • mostly, we don't have anything setup to push a package to the julia package registry. I'll do that in a separate issue

Copilot AI changed the title [WIP] Create initial julia wrapper for musica Add initial Julia wrapper for MUSICA Jan 15, 2026
Copilot AI requested a review from K20shores January 15, 2026 23:34
Copy link
Copy Markdown
Collaborator

@K20shores K20shores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot there's a build error in the github actions file:

Run cmake -S . -B build
cmake -S . -B build
-D CMAKE_BUILD_TYPE=Release
-D MUSICA_ENABLE_JULIA=ON
-D MUSICA_ENABLE_MICM=ON
-D MUSICA_ENABLE_TUVX=OFF
-D MUSICA_ENABLE_CARMA=OFF
-D CMAKE_POLICY_VERSION_MINIMUM=3.5
cmake --build build --verbose
shell: /usr/bin/bash -e {0}
env:
CC: gcc-14
CXX: g++-14
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-14 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-14 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMake build configuration for mechanism_configuration (Release) 1.1.1
-- Found Python3: /usr/bin/python3.12 (found version "3.12.3") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- CMake build configuration for micm(Release) 3.11.0
-- CMake build configuration for musica (Release) 0.14.4
CMake Error at julia/CMakeLists.txt:4 (find_package):
By not providing "FindJulia.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Julia", but
CMake did not find one.

Could not find a package configuration file provided by "Julia" with any of
the following names:

JuliaConfig.cmake
julia-config.cmake

Add the installation prefix of "Julia" to CMAKE_PREFIX_PATH or set
"Julia_DIR" to a directory containing one of the above files. If "Julia"
provides a separate development package or SDK, be sure it has been
installed.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.58%. Comparing base (04f45a5) to head (18b8cd2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #736   +/-   ##
=======================================
  Coverage   74.58%   74.58%           
=======================================
  Files         109      109           
  Lines        8090     8090           
=======================================
  Hits         6034     6034           
  Misses       2056     2056           
Flag Coverage Δ
cpp_fortran 68.49% <ø> (ø)
javascript 92.56% <ø> (ø)
python 78.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 15, 2026

@copilot there's a build error in the github actions file:

Run cmake -S . -B build ...

Fixed in commit 7348f7c. The issue was that CMake couldn't find Julia and JlCxx packages. The solution:

  1. CMakeLists.txt changes: Now uses find_program to locate Julia, then queries Julia itself to get its include directory and CxxWrap's prefix path for JlCxx
  2. Workflow changes: Moved Julia dependency installation (CxxWrap) to run before the CMake configuration step

This ensures CxxWrap.jl is installed when CMake tries to find the JlCxx package.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pkg.julialang.org
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.instantiate() (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown
Collaborator

@K20shores K20shores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot everything built, but the tests don't pass

[ 99%] Building CXX object julia/CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o
cd /home/runner/work/musica/musica/build/julia && /usr/bin/g++-14 -DJULIA_ENABLE_THREADING -DMICM_DEFAULT_VECTOR_SIZE=4 -DMUSICA_USE_MICM -DYAML_CPP_STATIC_DEFINE -Dmusica_julia_EXPORTS -I/opt/hostedtoolcache/julia/1.10.10/x64/bin/../share/julia -I/home/runner/work/musica/musica/include -I/home/runner/work/musica/musica/build/_deps/mechanism_configuration-src/include -I/home/runner/work/musica/musica/build/_deps/yaml-cpp-src/include -I/home/runner/work/musica/musica/build/_deps/micm-src/include -isystem /home/runner/.julia/artifacts/c129d84767ca7fe64514b3789c623e1203355949/include -isystem /opt/hostedtoolcache/julia/1.10.10/x64/include/julia -O3 -DNDEBUG -std=gnu++20 -fPIC -MD -MT julia/CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o -MF CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o.d -o CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o -c /home/runner/work/musica/musica/julia/bindings/musica_julia.cpp
[100%] Linking CXX shared library lib/musica_julia.so
cd /home/runner/work/musica/musica/build/julia && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/musica_julia.dir/link.txt --verbose=1
/usr/bin/g++-14 -fPIC -O3 -DNDEBUG -Wl,--dependency-file=CMakeFiles/musica_julia.dir/link.d -shared -Wl,-soname,musica_julia.so -o lib/musica_julia.so CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o -Wl,-rpath,"$ORIGIN" ../lib/libmusica.a /home/runner/.julia/artifacts/c129d84767ca7fe64514b3789c623e1203355949/lib/libcxxwrap_julia.so.0.12.3 ../lib/libmechanism_configuration.a ../_deps/yaml-cpp-build/libyaml-cpp.a /opt/hostedtoolcache/julia/1.10.10/x64/lib/libjulia.so.1.10
Copying musica_julia library to source tree for development
cd /home/runner/work/musica/musica/build/julia && /usr/local/bin/cmake -E make_directory /home/runner/work/musica/musica/julia/deps/lib
cd /home/runner/work/musica/musica/build/julia && /usr/local/bin/cmake -E copy /home/runner/work/musica/musica/build/julia/lib/musica_julia.so /home/runner/work/musica/musica/julia/deps/lib/
gmake[2]: Leaving directory '/home/runner/work/musica/musica/build'
[100%] Built target musica_julia
gmake[1]: Leaving directory '/home/runner/work/musica/musica/build'
/usr/local/bin/cmake -E cmake_progress_start /home/runner/work/musica/musica/build/CMakeFiles 0

3s
Run julia --project=. test/runtests.jl
julia --project=. test/runtests.jl
shell: /usr/bin/bash -e {0}
env:
CC: gcc-14
CXX: g++-14
ERROR: LoadError: MUSICA Julia library not found at: /home/runner/work/musica/musica/julia/src/../deps/lib/libmusica_julia.so

Please build the library first with:
cmake -S . -B build -D MUSICA_ENABLE_JULIA=ON
cmake --build build

See the README.md for more information.

Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] __check_library()
@ Musica ~/work/musica/musica/julia/src/Musica.jl:12
[3] top-level scope
@ ~/work/musica/musica/julia/src/Musica.jl:24
[4] include
@ ./Base.jl:495 [inlined]
[5] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
@ Base ./loading.jl:2292
[6] top-level scope
@ stdin:4
in expression starting at /home/runner/work/musica/musica/julia/src/Musica.jl:1
in expression starting at stdin:4
ERROR: LoadError: Failed to precompile Musica [66742b49-3186-4ea4-9bc8-7132dfe8b3ac] to "/home/runner/.julia/compiled/v1.10/Musica/jl_ZPf0cN".
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
@ Base ./loading.jl:2539
[3] compilecache
@ ./loading.jl:2411 [inlined]
[4] (::Base.var"#971#972"{Base.PkgId})()
@ Base ./loading.jl:2044
[5] mkpidlock(f::Base.var"#971#972"{Base.PkgId}, at::String, pid::Int32; kwopts::@kwargs{stale_age::Int64, wait::Bool})
@ FileWatching.Pidfile /opt/hostedtoolcache/julia/1.10.10/x64/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
[6] #mkpidlock#6
@ /opt/hostedtoolcache/julia/1.10.10/x64/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
[7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@kwargs{stale_age::Int64})
@ FileWatching.Pidfile /opt/hostedtoolcache/julia/1.10.10/x64/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
[8] #invokelatest#2
@ ./essentials.jl:894 [inlined]
[9] invokelatest
@ ./essentials.jl:889 [inlined]
[10] maybe_cachefile_lock(f::Base.var"#971#972"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
@ Base ./loading.jl:3054
[11] maybe_cachefile_lock
@ ./loading.jl:3051 [inlined]
[12] _require(pkg::Base.PkgId, env::String)
@ Base ./loading.jl:2040
[13] __require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:1882
[14] #invoke_in_world#3
@ ./essentials.jl:926 [inlined]
[15] invoke_in_world
@ ./essentials.jl:923 [inlined]
[16] _require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base ./loading.jl:1873
[17] macro expansion
@ ./loading.jl:1860 [inlined]
[18] macro expansion
@ ./lock.jl:267 [inlined]
[19] __require(into::Module, mod::Symbol)
@ Base ./loading.jl:1823
[20] #invoke_in_world#3
@ ./essentials.jl:926 [inlined]
[21] invoke_in_world
@ ./essentials.jl:923 [inlined]
[22] require(into::Module, mod::Symbol)
@ Base ./loading.jl:1816
in expression starting at /home/runner/work/musica/musica/julia/test/runtests.jl:2
Error: Process completed with exit code 1.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 16, 2026

@copilot everything built, but the tests don't pass

[ 99%] Building CXX object julia/CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o...

Fixed in commit 2313dca. The issue was that the library existence check was running during module precompilation, before the library was built.

The fix moves the library check into the __init__() function, which only runs when the module is actually loaded at runtime (after the build completes), not during precompilation when Julia installs dependencies.

Copy link
Copy Markdown
Collaborator

@K20shores K20shores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the library still cannot be found

[ 99%] Building CXX object julia/CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o
cd /home/runner/work/musica/musica/build/julia && /usr/bin/g++-14 -DJULIA_ENABLE_THREADING -DMICM_DEFAULT_VECTOR_SIZE=4 -DMUSICA_USE_MICM -DYAML_CPP_STATIC_DEFINE -Dmusica_julia_EXPORTS -I/opt/hostedtoolcache/julia/1.6.7/x64/bin/../share/julia -I/home/runner/work/musica/musica/include -I/home/runner/work/musica/musica/build/_deps/mechanism_configuration-src/include -I/home/runner/work/musica/musica/build/_deps/yaml-cpp-src/include -I/home/runner/work/musica/musica/build/_deps/micm-src/include -isystem /home/runner/.julia/artifacts/86e0b5f90e059a447ab73d9c103456c80886e74c/include -isystem /opt/hostedtoolcache/julia/1.6.7/x64/include/julia -O3 -DNDEBUG -std=gnu++20 -fPIC -MD -MT julia/CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o -MF CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o.d -o CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o -c /home/runner/work/musica/musica/julia/bindings/musica_julia.cpp
[100%] Linking CXX shared library lib/musica_julia.so
cd /home/runner/work/musica/musica/build/julia && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/musica_julia.dir/link.txt --verbose=1
/usr/bin/g++-14 -fPIC -O3 -DNDEBUG -Wl,--dependency-file=CMakeFiles/musica_julia.dir/link.d -shared -Wl,-soname,musica_julia.so -o lib/musica_julia.so CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o -Wl,-rpath,"$ORIGIN" ../lib/libmusica.a /home/runner/.julia/artifacts/86e0b5f90e059a447ab73d9c103456c80886e74c/lib/libcxxwrap_julia.so.0.12.3 ../lib/libmechanism_configuration.a ../_deps/yaml-cpp-build/libyaml-cpp.a /opt/hostedtoolcache/julia/1.6.7/x64/lib/libjulia.so.1
Copying musica_julia library to source tree for development
cd /home/runner/work/musica/musica/build/julia && /usr/local/bin/cmake -E make_directory /home/runner/work/musica/musica/julia/deps/lib
cd /home/runner/work/musica/musica/build/julia && /usr/local/bin/cmake -E copy /home/runner/work/musica/musica/build/julia/lib/musica_julia.so /home/runner/work/musica/musica/julia/deps/lib/
gmake[2]: Leaving directory '/home/runner/work/musica/musica/build'
[100%] Built target musica_julia
gmake[1]: Leaving directory '/home/runner/work/musica/musica/build'
/usr/local/bin/cmake -E cmake_progress_start /home/runner/work/musica/musica/build/CMakeFiles 0

4s
Run julia --project=. test/runtests.jl
ERROR: LoadError: could not load library "/home/runner/work/musica/musica/julia/src/../deps/lib/libmusica_julia.so"
/home/runner/work/musica/musica/julia/src/../deps/lib/libmusica_julia.so: cannot open shared object file: No such file or directory
Stacktrace:
[1] dlopen(s::String, flags::UInt32; throw_error::Bool)
@ Base.Libc.Libdl ./libdl.jl:114
[2] dlopen
@ ./libdl.jl:114 [inlined]
[3] readmodule(so_path_cb::Musica.var"#1#2", funcname::Symbol, m::Module, flags::Nothing)
@ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/J8Cop/src/CxxWrap.jl:814
[4] wrapmodule(so_path_cb::Function, funcname::Symbol, m::Module, flags::Nothing)
@ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/J8Cop/src/CxxWrap.jl:825
[5] top-level scope
@ ~/work/musica/musica/julia/src/Musica.jl:10
[6] include
@ ./Base.jl:384 [inlined]
[7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base ./loading.jl:1235
[8] top-level scope
@ none:1
[9] eval
@ ./boot.jl:360 [inlined]
[10] eval(x::Expr)
@ Base.MainInclude ./client.jl:446
[11] top-level scope
@ none:1
in expression starting at /home/runner/work/musica/musica/julia/src/Musica.jl:1
ERROR: LoadError: Failed to precompile Musica [66742b49-3186-4ea4-9bc8-7132dfe8b3ac] to /home/runner/.julia/compiled/v1.6/Musica/jl_VEfZxS.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::Base.PipeEndpoint, internal_stdout::Base.PipeEndpoint, ignore_loaded_modules::Bool)
@ Base ./loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base ./loading.jl:923
in expression starting at /home/runner/work/musica/musica/julia/test/runtests.jl:2

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 16, 2026

@copilot the library still cannot be found

[ 99%] Building CXX object julia/CMakeFiles/musica_julia.dir/bindings/musica_julia.cpp.o...

Fixed in commit 6ef06ac. The issue was a precompilation cache timing problem:

  1. During Pkg.instantiate(), Julia precompiled the Musica module, but the library didn't exist yet
  2. The build then created the library
  3. When tests ran, Julia used the cached (failed) precompilation from step 1

The fix adds a step to clear the precompilation cache and rebuild it after the library is built, ensuring the module is compiled with the library available.

Copilot AI requested a review from K20shores January 16, 2026 14:35
@K20shores K20shores force-pushed the copilot/create-initial-julia-wrapper branch 2 times, most recently from 6ef06ac to 27adbf8 Compare January 21, 2026 17:57
- can read musica version
- adds github actions file
- adds readmes
@K20shores K20shores force-pushed the copilot/create-initial-julia-wrapper branch from de6fcdb to f1e2db0 Compare January 22, 2026 22:47
@K20shores K20shores marked this pull request as ready for review January 22, 2026 22:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces an initial Julia wrapper package (Musica.jl) for MUSICA using CxxWrap, along with CI and documentation updates.

Changes:

  • Adds a minimal Julia package and CxxWrap C++ bindings exposing get_version().
  • Integrates Julia into the build system (CMake) and adds a GitHub Actions workflow to build/test the Julia wrapper.
  • Adds Julia documentation pages and a Julia-specific README.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
julia/src/Musica.jl Defines the Julia module and loads the compiled CxxWrap library at runtime.
julia/bindings/musica_julia.cpp Implements the CxxWrap module and binds get_version() to MUSICA’s C++ version API.
julia/CMakeLists.txt Builds the musica_julia shared library for the Julia wrapper.
julia/Project.toml Declares the Julia package metadata and dependency/compat constraints.
julia/test/runtests.jl Adds a basic Julia test validating version retrieval.
julia/README.md Provides Julia-specific build and usage instructions.
julia/.gitignore Ignores Julia build artifacts in the julia/ subtree.
docs/source/api/julia.rst Adds a Julia API documentation page.
docs/source/api/index.rst Links the Julia API page from the docs index.
cmake/dependencies.cmake Adds Julia/CxxWrap discovery and setup during CMake configuration.
CMakeLists.txt Adds MUSICA_ENABLE_JULIA option and includes the julia/ subdirectory when enabled.
README.md Adds a badge for the new Julia CI workflow.
.gitignore Ignores Julia build output directories/artifacts at repo root level.
.github/workflows/julia.yml Adds CI to configure/build MUSICA with Julia enabled and run Julia tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@K20shores K20shores merged commit 2c13cdb into main Jan 28, 2026
49 of 50 checks passed
@K20shores K20shores deleted the copilot/create-initial-julia-wrapper branch January 28, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create initial julia wrapper

5 participants