Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased
* JuliaCall: added `libpath` / `default_bindir` options
(`PYTHON_JULIACALL_LIBPATH` / `PYTHON_JULIACALL_DEFAULT_BINDIR`) to supply
libjulia's path and `Sys.BINDIR` directly, skipping the discovery subprocess
at startup. Behaviour is unchanged unless both are set.

## 0.9.34 (2026-05-18)
* Bug fixes.

Expand Down
2 changes: 2 additions & 0 deletions docs/src/juliacall.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ be configured in two ways:
| `-X juliacall-heap-size-hint=<N>` | `PYTHON_JULIACALL_HEAP_SIZE_HINT=<N>` | Hint for initial heap size in bytes. |
| `-X juliacall-exe=<file>` | `PYTHON_JULIACALL_EXE=<file>` | Path to Julia binary to use (overrides JuliaPkg). |
| `-X juliacall-project=<dir>` | `PYTHON_JULIACALL_PROJECT=<dir>` | Path to the Julia project to use (overrides JuliaPkg). |
| `-X juliacall-libpath=<file>` | `PYTHON_JULIACALL_LIBPATH=<file>` | Path to libjulia. If set together with `default-bindir`, skips the subprocess that discovers it. |
| `-X juliacall-default-bindir=<dir>` | `PYTHON_JULIACALL_DEFAULT_BINDIR=<dir>` | Julia's `Sys.BINDIR`. If set together with `libpath`, skips the subprocess that discovers it. |
| `-X juliacall-trace-compile=<stderr\|name>` | `PYTHON_JULIACALL_TRACE_COMPILE=<stderr\|name>` | Print precompile statements. |
| `-X juliacall-trace-compile-timing` | `PYTHON_JULIACALL_TRACE_COMPILE_TIMING=<yes\|no>` | Include timings with precompile statements. |

Expand Down
17 changes: 13 additions & 4 deletions pysrc/juliacall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,19 @@ def args_from_config(config):
exepath = CONFIG['exepath']
project = CONFIG['project']

# Find the Julia library
cmd = [exepath, '--project='+project, '--startup-file=no', '-O0', '--compile=min',
'-e', 'import Libdl; print(abspath(Libdl.dlpath("libjulia")), "\\0", Sys.BINDIR)']
libpath, default_bindir = subprocess.run(cmd, check=True, capture_output=True, encoding='utf8').stdout.split('\0')
# Find the Julia library.
#
# This normally starts a short-lived Julia process just to print libjulia's
# path and Sys.BINDIR. In deployment scenarios (e.g. a pre-built container
# or system image) these are static and known ahead of time, so they may be
# supplied directly via the `libpath` / `default_bindir` options to skip the
# extra process. Behaviour is unchanged unless both are set.
libpath = path_option('libpath', check_exists=True)[0]
default_bindir = path_option('default_bindir', check_exists=True)[0]
if libpath is None or default_bindir is None:
cmd = [exepath, '--project='+project, '--startup-file=no', '-O0', '--compile=min',
'-e', 'import Libdl; print(abspath(Libdl.dlpath("libjulia")), "\\0", Sys.BINDIR)']
libpath, default_bindir = subprocess.run(cmd, check=True, capture_output=True, encoding='utf8').stdout.split('\0')
assert os.path.exists(libpath)
assert os.path.exists(default_bindir)
CONFIG['libpath'] = libpath
Expand Down
Loading