Skip to content

Load CondaPkg lazily, and drop Pkg as a dependency#752

Closed
JamesWrigley wants to merge 3 commits intoJuliaPy:mainfrom
JamesWrigley:condapkg
Closed

Load CondaPkg lazily, and drop Pkg as a dependency#752
JamesWrigley wants to merge 3 commits intoJuliaPy:mainfrom
JamesWrigley:condapkg

Conversation

@JamesWrigley
Copy link
Contributor

Combined, these reduce the load time with JULIA_PYTHONCALL_EXE set from ~1.3s to ~0.3s on my machine.

Note that removing Pkg as a dependency could be breaking if packages are depending on accessing Pkg in the juliacall module. But, only Main is documented as being available so it is technically ok to remove it in a nonbreaking release: https://juliapy.github.io/PythonCall.jl/stable/juliacall-reference/#Constants

This shaves ~0.5s off the load time if `JULIA_PYTHONCALL_EXE` is set.
This removes ~0.4s from the load time.
@JamesWrigley
Copy link
Contributor Author

(bump)

@cjdoris
Copy link
Member

cjdoris commented Mar 23, 2026

Thanks, it's a nice idea, however doing runtime imports like this is not allowed in Julia as it breaks precompilation. I don't totally understand how but there are issues/PRs about it somewhere...

What we CAN do though is, once the PR for using Preferences.jl is merged, avoid loading CondaPkg if the exe pref is set to something other than @CondaPkg. This is because preferences can be used at precompile-time. We do something similar in CondaPkg itself to avoid loading MicroMamba_jll if we don't need it.

Closing as the approach is unsound but happy to take a PR for the preferences way.

@cjdoris cjdoris closed this Mar 23, 2026
@JamesWrigley
Copy link
Contributor Author

@eval using CondaPkg is indeed not allowed and you get an error about it, but AFAIK Base.require() is safe.

What we CAN do though is, once the PR for using Preferences.jl is merged, avoid loading CondaPkg if the exe pref is set to something other than @CondaPkg. This is because preferences can be used at precompile-time. We do something similar in CondaPkg itself to avoid loading MicroMamba_jll if we don't need it.

Ok, that works for me too 👍

@JamesWrigley JamesWrigley deleted the condapkg branch March 23, 2026 13:21
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.

2 participants