Skip to content

Commit 87ca784

Browse files
committed
Fail with a helpful message if separate cache is not supported
1 parent a954914 commit 87ca784

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

julia/core.py

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,34 @@ def is_compatible_exe(jlinfo, _debug=lambda *_: None):
344344
return py_libpython == jl_libpython
345345

346346

347+
def raise_separate_cache_error(runtime, pyprogramname):
348+
message = """\
349+
It seems your Julia and PyJulia setup are not supported.
350+
351+
Julia interpreter:
352+
{runtime}
353+
Python interpreter used by PyCall.jl:
354+
{pyprogramname}
355+
Python interpreter used to import PyJulia.
356+
{sys.executable}
357+
358+
In Julia >= 0.7, above two paths to the Python interpreters have to match
359+
exactly in order for PyJulia to work. To configure PyCall.jl to use Python
360+
interpreter "{sys.executable}",
361+
run the following commands in the Julia interpreter:
362+
363+
ENV["PYTHON"] = "{sys.executable}"
364+
using Pkg
365+
Pkg.build("PyCall")
366+
367+
For more information, see:
368+
https://github.com/JuliaPy/pyjulia
369+
https://github.com/JuliaPy/PyCall.jl
370+
""".format(runtime=runtime, pyprogramname=pyprogramname,
371+
sys=sys)
372+
raise RuntimeError(message)
373+
374+
347375
_julia_runtime = [False]
348376

349377

@@ -498,14 +526,20 @@ def __init__(self, init_julia=True, jl_runtime_path=None, jl_init_path=None,
498526
if init_julia:
499527
if use_separate_cache:
500528
# First check that this is supported
501-
self._call("""
502-
if VERSION < v"0.5-"
503-
error(\"""Using pyjulia with a statically-compiled version
504-
of python or with a version of python that
505-
differs from that used by PyCall.jl is not
506-
supported on julia 0.4""\")
507-
end
508-
""")
529+
version_range = self._unbox_as(self._call("""
530+
Int64(if VERSION < v"0.6-"
531+
2
532+
elseif VERSION >= v"0.7-"
533+
1
534+
else
535+
0
536+
end)
537+
"""), "int64")
538+
if version_range == 2:
539+
raise RuntimeError(
540+
"PyJulia does not support Julia < 0.6 anymore")
541+
elif version_range == 1:
542+
raise_separate_cache_error(runtime, depsjlexe)
509543
# Intercept precompilation
510544
os.environ["PYCALL_PYTHON_EXE"] = sys.executable
511545
os.environ["PYCALL_JULIA_HOME"] = PYCALL_JULIA_HOME

0 commit comments

Comments
 (0)