Skip to content

juliacall: optionally supply libjulia path/bindir to skip the discovery subprocess#774

Open
ncudlenco wants to merge 1 commit into
JuliaPy:mainfrom
buchi-labortechnik-ag:feat/juliacall-skip-libjulia-discovery
Open

juliacall: optionally supply libjulia path/bindir to skip the discovery subprocess#774
ncudlenco wants to merge 1 commit into
JuliaPy:mainfrom
buchi-labortechnik-ag:feat/juliacall-skip-libjulia-discovery

Conversation

@ncudlenco
Copy link
Copy Markdown

@ncudlenco ncudlenco commented May 19, 2026

Summary

Adds opt-in libpath / default_bindir juliacall options so the path to libjulia and Sys.BINDIR can be supplied directly, skipping the short-lived Julia process init() otherwise spawns at startup just to discover them. No behaviour change unless both are set.

Motivation

In short-lived Python processes that embed Julia via juliacall (serverless / autoscaled containers), every fresh process pays import juliacall startup with no long-lived server to amortise it. During that startup init() launches a whole separate Julia process — julia -O0 --compile=min -e 'print(Libdl.dlpath("libjulia"), Sys.BINDIR)' — solely to discover two strings. That is an entire extra Julia interpreter boot on the critical path of every cold start. In a pre-built container or system image those paths are static and known at build time, so the subprocess is pure repeated waste.

Change

Two new juliacall options (same -X / PYTHON_JULIACALL_* mechanism as the rest):

  • libpathPYTHON_JULIACALL_LIBPATH
  • default_bindirPYTHON_JULIACALL_DEFAULT_BINDIR

When both are set the discovery subprocess is skipped and the supplied values used; otherwise behaviour is exactly as before. docs/src/juliacall.md config table and CHANGELOG.md updated.

Backward compatibility

No behaviour change unless both options are set. Values are validated with the existing path_option(..., check_exists=True) helper, so a bad path fails fast with the standard error message.

Testing

The new options only take effect when explicitly set, so default behaviour is unchanged and the existing test suites are unaffected.

Independent of, and complementary to, the system-image PR (#773): together they remove the two biggest fixed costs from a cold juliacall start — loading PythonCall, and this extra Julia process.

Related issues

Relates to #762 ("Improve juliacall startup time?") — this removes a whole extra Julia process from every cold start. Adjacent to #619 (offline / BINDIR startup); note #619's specific complaint (juliapkg still attempting a network install) is a different concern this PR does not by itself resolve.

…very subprocess

init() starts a short-lived Julia process solely to print libjulia's
path and Sys.BINDIR. In pre-built containers / system images these are
static and known ahead of time; allow supplying them via the libpath /
default_bindir options (PYTHON_JULIACALL_LIBPATH /
PYTHON_JULIACALL_DEFAULT_BINDIR) to skip the extra process. Behaviour is
unchanged unless both are set. Docs and CHANGELOG updated.
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.

1 participant