Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user site bin for julia-py #312

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/julia/juliainfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using Libdl
using Pkg

println(Base.Sys.BINDIR)
println(Libdl.dlpath(string("lib", splitext(Base.julia_exename())[1])))
println(Libdl.dlpath("libjulia"))
println(unsafe_string(Base.JLOptions().image_file))

pkg = Base.PkgId(Base.UUID(0x438e738f_606a_5dbb_bf0a_cddfbfd45ab0), "PyCall")
Expand Down
60 changes: 40 additions & 20 deletions src/julia/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import glob
import os
import platform
import re
import site
import subprocess
import sysconfig
import sys

from .core import JuliaNotFound, which
Expand Down Expand Up @@ -139,27 +142,44 @@ def julia_py_executable(executable=sys.executable):
"""
Path to ``julia-py`` executable installed for this Python executable.
"""
stempath = os.path.join(os.path.dirname(executable), "julia-py")
candidates = {os.path.basename(p): p for p in glob.glob(stempath + "*")}
if not candidates:
raise RuntimeError(
"``julia-py`` executable is not found for Python installed at {}".format(
executable
)
)
basenames = []
basedirs = []
platform_sys = platform.system()

if platform_sys in {"Linux", "Darwin"}:
basenames = ["julia-py"]
basedirs = [
basedirs.append(os.path.join(site.USER_BASE, "bin")),
os.path.join(site.PREFIXES[0], "bin"),
os.path.dirname(executable)
]
elif platform_sys == "win32":
basenames = ["julia-py.exe", "julia-py.cmd"]
basedirs = [
os.path.join(site.USER_BASE,
"Python" + sysconfig.get_config_vars("VERSION"),
"Scripts"),
os.path.join(site.PREFIXES[0], "Scripts"),
os.path.dirname(executable)
]
else:
raise RuntimeError("Unsupported platform: {}".format(platform_sys))

for basename in ["julia-py", "julia-py.exe", "julia-py.cmd"]:
try:
return candidates[basename]
except KeyError:
for basedir in basedirs:
stempath = os.path.join(basedir, "julia-py")
candidates = {os.path.basename(p): p for p in glob.glob(stempath + "*")}
if not candidates:
continue
for basename in basenames:
try:
return candidates[basename]
except KeyError:
continue

raise RuntimeError(
"""\
``julia-py`` with following unrecognized extension(s) are found.
Please report it at https://github.com/JuliaPy/pyjulia/issues
with the full traceback.
Files found:
"""
+ " \n".join(sorted(candidates))
)
"""\``julia-py`` executable not found in {} looking for
{}. If the file exists with another extension, please report it
at https://github.com/JuliaPy/pyjulia/issues
with the full traceback.
""".format(basedirs, basenames)
)