pyjulia icon indicating copy to clipboard operation
pyjulia copied to clipboard

Building of sysimage fails with pyjulia in user path

Open oschulz opened this issue 5 years ago • 5 comments

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?

oschulz avatar Feb 10 '20 18:02 oschulz

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!

Kchour avatar Mar 19 '20 21:03 Kchour

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~~

grahamgill avatar Apr 30 '20 17:04 grahamgill

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.

Here's my attempt to do something along those lines: tools.py_v0.5.3_diff.txt

Is this reasonable?

grahamgill avatar Apr 30 '20 20:04 grahamgill

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.

tkf avatar Apr 30 '20 20:04 tkf

Also, having tests for this would be great. Though probably the only thing we can do is to use a mock or something.

tkf avatar Apr 30 '20 20:04 tkf