Skip to content

Commit 395c4d9

Browse files
committed
Ship juliapkg.json with the documented solver stack (fixes #175)
`load_julia_packages` was running `Pkg.activate("diffeqpy", shared=true)` before adding the solver packages, which moved Julia off juliacall's managed project (`$CONDA_PREFIX/julia_env`, where PythonCall is pinned to the ABI-matched version) and into a separate shared environment. The shared environment then resolved an unconstrained PythonCall, breaking the juliacall <-> PythonCall ABI and segfaulting on import. Declare the solver stack in `diffeqpy/juliapkg.json` so juliacall installs DifferentialEquations, OrdinaryDiffEq, StochasticDiffEq, DelayDiffEq, Sundials, DiffEqCallbacks, and ModelingToolkit into its managed project alongside PythonCall, with proper version resolution. Compat ranges span the doc-tested major and the current major (e.g. DifferentialEquations "7, 8") so the docs keep working under the recent v8 metapackage where some sub-solvers are no longer transitive. Drop the `Pkg.activate` line from `load_julia_packages` so the lazy install path used by the GPU sub-modules (cuda/amdgpu/metal/oneapi) also targets juliacall's managed project. https://claude.ai/code/session_01G6GjTpy5ZKWq78zfdCzV4y
1 parent f0ce5ad commit 395c4d9

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include README.md
22
include LICENSE.md
33
include docs/*.txt
44
include diffeqpy/*.jl
5+
include diffeqpy/*.json

diffeqpy/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,19 @@ def load_julia_packages(*names):
2929
"""
3030
Load Julia packages and return references to them, automatically installing julia and
3131
the packages as necessary.
32+
33+
Packages declared in ``diffeqpy/juliapkg.json`` (the documented solver stack:
34+
DifferentialEquations, OrdinaryDiffEq, StochasticDiffEq, DelayDiffEq, Sundials,
35+
DiffEqCallbacks, ModelingToolkit) are installed by juliacall at import time into
36+
its managed project alongside the ABI-matched PythonCall, so they should already
37+
be importable here. Anything not listed there (e.g. the optional GPU backends
38+
pulled in by ``diffeqpy.cuda`` / ``amdgpu`` / ``metal`` / ``oneapi``) is added
39+
lazily on first use into the same managed project.
3240
"""
3341
# This is terrifying to many people. However, it seems SciML takes pragmatic approach.
3442
_ensure_julia_installed()
3543

3644
script = """import Pkg
37-
Pkg.activate(\"diffeqpy\", shared=true)
3845
try
3946
import {0}
4047
catch e

diffeqpy/juliapkg.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"julia": "1.10",
3+
"packages": {
4+
"DifferentialEquations": {
5+
"uuid": "0c46a032-eb83-5123-abaf-570d42b7fbaa",
6+
"version": "7, 8"
7+
},
8+
"OrdinaryDiffEq": {
9+
"uuid": "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed",
10+
"version": "6, 7"
11+
},
12+
"StochasticDiffEq": {
13+
"uuid": "789caeaf-c7a9-5a7d-9973-96adeb23e2a0",
14+
"version": "6, 7"
15+
},
16+
"DelayDiffEq": {
17+
"uuid": "bcd4f6db-9728-5f36-b5f7-82caef46ccdb",
18+
"version": "5, 6"
19+
},
20+
"Sundials": {
21+
"uuid": "c3572dad-4567-51f8-b174-8c6c989267f4",
22+
"version": "4, 5, 6"
23+
},
24+
"DiffEqCallbacks": {
25+
"uuid": "459566f4-90b8-5000-8ac3-15dfb0a30def",
26+
"version": "3, 4"
27+
},
28+
"ModelingToolkit": {
29+
"uuid": "961ee093-0014-501f-94e3-6117800e7a78",
30+
"version": "9, 10, 11"
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)