I’ve just made a package JuliaPythonAdaptor.jl that helps automatically setting up environment variables required by PythonCall.jl.
Things works pretty fine if I use these two packages in REPL:
# 'JuliaPythonAdaptor.__init__' modifies 'ENV'. julia> import JuliaPythonAdaptor # find the python I specified in $PATH julia> using PythonCall
However, it turns out to be difficult when working with precompilation.
Here is an MWE, and you could just create a small package referencing the two packages:
#= install deps: =# import Pkg Pkg.add(url=raw"https://github.com/thautwarm/JuliaPythonAdaptor.jl/") Pkg.add("PythonCall") #= my package's main module =# module MyMWE import JuliaPythonAdaptor import PythonCall end # module
The first time I imported
MyMWE, things worked and the package got precompiled. Then, I won’t be able to import
MyMWE any more , as
JuliaPythonAdaptor.__init__ is not called before loading
Although it is possible to use bash scripts to set environment variables before starting julia, I’d like to use a Julia package to implement the logic. I’m not stick to my current method, but my final goal is to
allow using a Julia package to configure the environment before loading PythonCall. (EDIT) dynamically call some Julia code for setup, before loading PythonCall.
I wonder if this is possible without modifying the source code of PythonCall?