Building of sysimage fails with pyjulia in user path
When installing pyjulia in my home dir using
python3 -m pip install --user julia
as recommended in the pyjulia documentation, I'm unable to build a sysimage with
python3 -m julia.sysimage sys.so
I get a
RuntimeError: ``julia-py`` executable is not found for Python installed at /opt/anaconda3/bin/python3
I think this is because of
def julia_py(julia, pyjulia_debug, jl_args):
# ...
os.environ["_PYJULIA_JULIA_PY"] = julia_py_executable()
in "julia_py.py" and
def julia_py_executable(executable=sys.executable):
# ...
stempath = os.path.join(os.path.dirname(executable), "julia-py")
candidates = {os.path.basename(p): p for p in glob.glob(stempath + "*")}
# ...
in "tools.py".
So julia_py_executable() never looks in "$HOME/.local/bin", which is where python3 -m pip install --user julia puts julia-py. Maybe it could also look for julia-py in site.USER_BASE and/or $PATH?
So I found a workaround by creating a symlink from where julia-py is installed, to directory /usr/bin.
To check where julia-py is installed, simply do: $ type julia-py. For me, julia-py was installed in ~/.local/bin.
To create the symbolic link: $ sudo ln -s home/<user>/.local/bin/julia-py /usr/bin/.
Hope it helps!
To get around this problem I modified julia_py_executable to check the <userbase>/bin folder before checking the standard system scripts folder, since by default python -m pip install --user ... puts scripts there. It's a hack that works for me for the moment.
The best answer I think means getting to know alternate installation schemes more intimately. Maybe use sysconfig.get_scheme_names() to provide the schemes to check and use sysconfig.get_paths("scripts",scheme) for the appropriate scripts directories. According to this
the various alternate installation schemes are mutually exclusive
so checking the various schemes means you'll get at most one hit from the alternates and at most one from the standard location. Presumably checking the alternates in preference to the standard location is the way to go.
~~Diff to the v0.5.3 tools.py file: tools.py_v0.5.3_diff.txt~~
The best answer I think means getting to know alternate installation schemes more intimately. Maybe use
sysconfig.get_scheme_names()to provide the schemes to check and usesysconfig.get_paths("scripts",scheme)for the appropriate scripts directories.
Here's my attempt to do something along those lines: tools.py_v0.5.3_diff.txt
Is this reasonable?
Thanks a lot for giving a shot at this. From a quick look, it seems to be a good direction. It'd be nice if you can open a PR so that it's easier to review/discuss.
Also, having tests for this would be great. Though probably the only thing we can do is to use a mock or something.