Skip to content

Commit 939f4ad

Browse files
author
Christopher Doris
committed
respect JULIA_DEPOT_PATH
1 parent 94e751f commit 939f4ad

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ deps/deps.jl
44
deps/build.log
55
.ipynb_checkpoints
66
__pycache__
7-
.conda_env
7+
conda_env
8+
julia_env
89
*.egg-info

juliacall/init.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
break
1414
CONFIG['dev'] = isdev
1515

16+
# Determine where to look for julia
17+
jldepot = os.environ.get("JULIA_DEPOT_PATH", "").split(";" if os.name == "nt" else ":")[0] or os.path.join(os.path.expanduser("~"), ".julia")
18+
jlprefix = os.path.join(jldepot, "pythoncall")
19+
jlbin = os.path.join(jlprefix, "bin")
20+
jlinstall = os.path.join(jlprefix, "install")
21+
jldownload = os.path.join(jlprefix, "download")
22+
jlexe = os.path.join(jlbin, "julia.cmd" if os.name == "nt" else "julia")
23+
1624
# Determine where to put the julia environment
1725
venvprefix = os.environ.get("VIRTUAL_ENV")
1826
condaprefix = os.environ.get("CONDA_PREFIX")
@@ -25,18 +33,11 @@
2533
else:
2634
prefix = None
2735
if prefix is None:
28-
jlenv = "PythonCall"
36+
jlenv = os.path.join(jldepot, "environments", "PythonCall")
2937
else:
3038
jlenv = os.path.join(prefix, "julia_env")
3139
CONFIG['meta'] = os.path.join(jlenv, "PythonCallMeta.json")
3240

33-
# Determine where to look for julia
34-
jlprefix = os.path.join(os.path.expanduser("~"), ".julia", "pythoncall")
35-
jlbin = os.path.join(jlprefix, "bin")
36-
jlinstall = os.path.join(jlprefix, "install")
37-
jldownload = os.path.join(jlprefix, "download")
38-
jlexe = os.path.join(jlbin, "julia.cmd" if os.name == "nt" else "julia")
39-
4041
# Find the Julia library
4142
libpath = os.environ.get('PYTHON_JULIACALL_LIB')
4243
if libpath is None:
@@ -111,20 +112,15 @@
111112
script = '''
112113
try
113114
import Pkg
114-
Pkg.activate("{}", shared={}, io=devnull)
115+
Pkg.activate(raw"{}", io=devnull)
115116
{}
116117
ENV["JULIA_PYTHONCALL_LIBPTR"] = "{}"
117118
import PythonCall
118119
catch err
119120
@error "Error loading PythonCall.jl" err=err
120121
rethrow()
121122
end
122-
'''.format(
123-
jlenv.replace('\\', '\\\\'),
124-
'true' if prefix is None else 'false',
125-
install,
126-
c.pythonapi._handle,
127-
)
123+
'''.format(jlenv, install, c.pythonapi._handle)
128124
res = lib.jl_eval_string(script.encode('utf8'))
129125
if res is None:
130126
raise Exception('PythonCall.jl did not start properly')

src/cpython/context.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function init_context()
6464
# Regarding the LOAD_PATH as getting "less specific" as we go through, this
6565
# choice of location is the "most specific" place which actually depends on
6666
# PythonCall.
67-
Deps._conda_env[] = joinpath(CTX.jlenv, ".conda_env")
67+
Deps._conda_env[] = joinpath(CTX.jlenv, "conda_env")
6868
Deps.resolve()
6969
exe_path = Deps.python_exe()
7070
isfile(exe_path) || error("cannot find python executable")

0 commit comments

Comments
 (0)