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
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/julia/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import glob
import os
import re
import site
import subprocess
import sys

Expand Down Expand Up @@ -139,8 +140,11 @@ 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 + "*")}
basedirs = {os.path.dirname(executable),
os.path.join(site.USER_BASE, "bin")}
Copy link
Member

@tkf tkf Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use set? I think we should use a list here in the order of increasing preference (so that the values of candidates are the one in the most preferred location). Does basedirs = [os.path.dirname(executable), os.path.join(site.USER_BASE, "bin")] + site.PREFIXES make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, os.path.join(site.USER_BASE, "bin") may not work in Windows? Is there a pre-defined path we can use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint! I've changed the logics according to your remarks. On Windows there seem to be more difficulties anyway (starting with "libjulia" library extension), but this part looks like it should work if the rest does too.

stempaths = {os.path.join(basedir, "julia-py") for basedir in basedirs}
candidates = {os.path.basename(p): p for stempath in stempaths
for p in glob.glob(stempath + "*")}
if not candidates:
raise RuntimeError(
"``julia-py`` executable is not found for Python installed at {}".format(
Expand Down