julia_import
Import the Julia environment.
This imports the
juliacall
module to obtain a Julia run-time (as
jl
), and uses it to import the
DataAxesFormats.jl
Julia package.
How Julia is run, and which Julia is run, is left to
juliacall
, and is configured by its own environment variables,
which must be set before importing anything that reaches Julia. This adds one thing to them:
@default
.
By default
juliacall
has
juliapkg
install a Julia of its own, and an environment of its own, and populates that
environment with what each installed Python package declares in its
juliapkg.json
. That is a reasonable default, and
it is not always what you want: if you use Julia yourself, it means a second copy of everything, which you cannot see
from a Julia prompt, and whose versions you do not choose.
juliacall
can be pointed at a Julia instead, through
PYTHON_JULIACALL_EXE
and
PYTHON_JULIACALL_PROJECT
, but
it has no way to say “the Julia I already have”: the first must be an executable and the second a directory which
exists. Setting either of them to
@default
here means exactly that - the
julia
in the path, and the environment
that Julia would use by itself, which it is asked for rather than being worked out from the depot and the version.
They are expanded before
juliacall
sees them, and are independent, so one may be
@default
while the other is
given explicitly.
Setting them is a deliberate act, so nothing is assumed if you do not. In particular
PYTHON_JULIACALL_THREADS
and
PYTHON_JULIACALL_HANDLE_SIGNALS
are left exactly as you set them: Julia runs on one thread unless you ask for more,
and asking for more without also setting the signal handling to
yes
is what makes it crash.
juliacall
warns
about that combination itself; this warns, once, about the single thread, which nothing else would tell you about.
Three packages provide this expansion:
dafpy
,
somegraphspy
, and
metacellspy
(transitively, through
dafpy
). Importing any of them expands
@default
, so the order does not matter. If
juliacall
is imported
before any of them, it sees
@default
itself, and rejects it as a path which does not exist, naming the variable it
could not use. That is why this is a value of a variable
juliacall
reads, rather than a variable of our own, which
it would silently ignore.
This code is based on the code from the
pysr
Python package, adapted to our needs. TODO: Much of this is replicated
in all our Python packages that invoke Julia.
- dafpy.julia_import. jl = Julia: Main
-
The interface to the Julia run-time.
- dafpy.julia_import. jl_version = (1, 12, 6)
-
The version of Julia being used.
- class dafpy.julia_import. JlEnum ( value ) [source]
-
A Python base class for a set of named values matching a Julia type.
Grouping the values in a class (as opposed to listing them in a
Literal) is what allows auto-completion to list them; aLiteraloffers no completions at all.
- class dafpy.julia_import. UndefInitializer [source]
-
A Python class to use instead of Julia’s
UndefInitializer. We need this to allow@overloadto work in the presence ofUndef.
- dafpy.julia_import. Undef = <dafpy.julia_import.UndefInitializer object>
-
A Python value to use instead of Julia’s
undef. We need this to allow@overloadto work in the presence ofundef.