Skip to content

feat(juliacall): supply libjulia path/bindir to skip the discovery subprocess#2

Merged
ncudlenco merged 1 commit into
mainfrom
feat/juliacall-skip-libjulia-discovery
May 19, 2026
Merged

feat(juliacall): supply libjulia path/bindir to skip the discovery subprocess#2
ncudlenco merged 1 commit into
mainfrom
feat/juliacall-skip-libjulia-discovery

Conversation

@ncudlenco
Copy link
Copy Markdown
Member

@ncudlenco ncudlenco commented May 18, 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 (JuliaPy#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 JuliaPy#762 ("Improve juliacall startup time?") — this removes a whole extra Julia process from every cold start. Adjacent to JuliaPy#619 (offline / BINDIR startup); note JuliaPy#619's specific complaint (juliapkg still attempting a network install) is a different concern this PR does not by itself resolve.

@ncudlenco ncudlenco closed this May 18, 2026
@ncudlenco ncudlenco reopened this May 18, 2026
@ncudlenco ncudlenco closed this May 18, 2026
@ncudlenco ncudlenco reopened this May 18, 2026
@ncudlenco ncudlenco force-pushed the feat/juliacall-skip-libjulia-discovery branch from f7c8ad4 to 6e2b9c1 Compare May 18, 2026 21:48
…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.
@ncudlenco ncudlenco force-pushed the feat/juliacall-skip-libjulia-discovery branch from 6e2b9c1 to df51ae6 Compare May 18, 2026 21:53
@ncudlenco ncudlenco merged commit 70fd306 into main May 19, 2026
17 of 18 checks passed
@ncudlenco
Copy link
Copy Markdown
Member Author

Merged into main (CHANGELOG ## Unreleased conflict with #1 resolved during the merge). Do not delete the feat/juliacall-skip-libjulia-discovery branch — it is the head of upstream JuliaPy#774 and must remain until that PR is resolved.

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