Skip to content

Commit 0f2dd37

Browse files
authored
Print a note after julia.install with non-default julia (#419)
1 parent 7002cac commit 0f2dd37

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/julia/tests/test_tools.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from julia.tools import julia_py_executable
8+
from julia.tools import _non_default_julia_warning_message, julia_py_executable
99

1010
fake_user = "fa9a5150-8e17-11ea-3f8d-ff1e5ae4a251"
1111
posix_user_sample_path = os.path.join(os.sep, "home", fake_user, ".local", "bin")
@@ -81,3 +81,8 @@ def test_find_julia_py_executable_not_found(monkeypatch):
8181
julia_py_executable()
8282

8383
assert "``julia-py`` executable is not found" in str(excinfo.value)
84+
85+
86+
def test_non_default_julia_warning_message():
87+
msg = _non_default_julia_warning_message("julia1.5")
88+
assert "Julia(runtime='julia1.5')" in msg

src/julia/tools.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ def _julia_version(julia):
4141
return (0, 0, 0)
4242

4343

44+
def _non_default_julia_warning_message(julia):
45+
# Avoid confusion like
46+
# https://github.com/JuliaPy/pyjulia/issues/416
47+
return (
48+
"PyCall is setup for non-default Julia runtime (executable) `{julia}`.\n"
49+
"To use this Julia runtime, PyJulia has to be initialized first by\n"
50+
" from julia import Julia\n"
51+
" Julia(runtime={julia!r})"
52+
).format(julia=julia)
53+
54+
4455
def build_pycall(julia="julia", python=sys.executable, **kwargs):
4556
# Passing `python` to force build (OP="build")
4657
install(julia=julia, python=python, **kwargs)
@@ -117,6 +128,9 @@ def install(julia="julia", color="auto", python=None, quiet=False):
117128
if not quiet:
118129
print("Precompiling PyCall... DONE", file=sys.stderr)
119130
print("PyCall is installed and built successfully.", file=sys.stderr)
131+
if julia != "julia":
132+
print(file=sys.stderr)
133+
print(_non_default_julia_warning_message(julia), file=sys.stderr)
120134
sys.stderr.flush()
121135

122136

0 commit comments

Comments
 (0)