Skip to content

Commit 69b90ca

Browse files
committed
fixup! Add options for the Julia binary and project path
1 parent 4b8e644 commit 69b90ca

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

docs/src/juliacall.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ See [JuliaPkg](https://github.com/JuliaPy/PyJuliaPkg) for more details.
104104
### Using existing environments
105105

106106
It's possible to override the defaults and disable JuliaPkg entirely by setting
107-
the `PYTHON_JULIACALL_EXEPATH` and `PYTHON_JULIACALL_PROJECT` options. This is
108-
particularly useful when using shared environments on HPC systems that may be
109-
readonly. If `PYTHON_JULIACALL_PROJECT` is specified the project *must* already
110-
have PythonCall.jl already installed. If only one of these options is specified
111-
then JuliaPkg will still be loaded to get a default value for the other one.
107+
the `PYTHON_JULIACALL_EXE` and `PYTHON_JULIACALL_PROJECT` options (both must be
108+
set together). This is particularly useful when using shared environments on HPC
109+
systems that may be readonly. Note that the project set in
110+
`PYTHON_JULIACALL_PROJECT` *must* already have PythonCall.jl installed and it
111+
*must* match the JuliaCall version, otherwise loading Julia will fail.
112112

113113
## [Configuration](@id julia-config)
114114

pysrc/juliacall/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def int_option(name, *, accept_auto=False, **kw):
110110
raise ValueError(f'{s}: expecting an int'+(' or auto' if accept_auto else ""))
111111

112112
def args_from_config(config):
113-
argv = [config['exepath']]
113+
argv = [config['exe']]
114114
for opt, val in config.items():
115115
if opt.startswith('opt_'):
116116
if val is None:
@@ -147,32 +147,32 @@ def args_from_config(config):
147147
CONFIG['opt_handle_signals'] = choice('handle_signals', ['yes', 'no'])[0]
148148
CONFIG['opt_startup_file'] = choice('startup_file', ['yes', 'no'])[0]
149149
CONFIG['opt_heap_size_hint'] = option('heap_size_hint')[0]
150-
CONFIG['opt_project'] = path_option('project', check_exists=True)[0]
151-
CONFIG['exepath'] = path_option('exepath', check_exists=True)[0]
150+
CONFIG['project'] = path_option('project', check_exists=True)[0]
151+
CONFIG['exe'] = path_option('exe', check_exists=True)[0]
152152

153153
# Stop if we already initialised
154154
if CONFIG['inited']:
155155
return
156156

157-
no_exepath = CONFIG['exepath'] is None
158-
no_project = CONFIG['opt_project'] is None
159-
if no_exepath or no_project:
157+
have_exe = CONFIG['exe'] is not None
158+
have_project = CONFIG['project'] is not None
159+
if not have_exe and not have_project:
160160
# we don't import this at the top level because it is not required when
161161
# juliacall is loaded by PythonCall and won't be available, or if both
162-
# `exepath` and `project` are set by the user.
162+
# `exe` and `project` are set by the user.
163163
import juliapkg
164164

165165
# Find the Julia executable and project
166-
if no_exepath:
167-
CONFIG['exepath'] = juliapkg.executable()
168-
if no_project:
169-
CONFIG['opt_project'] = juliapkg.project()
166+
CONFIG['exe'] = juliapkg.executable()
167+
CONFIG['project'] = juliapkg.project()
168+
elif (not have_exe and have_project) or (have_exe and not have_project):
169+
raise Exception("Both PYTHON_JULIACALL_PROJECT and PYTHON_JULIACALL_EXE must be set together, not only one of them.")
170170

171-
exepath = CONFIG['exepath']
172-
project = CONFIG['opt_project']
171+
exe = CONFIG['exe']
172+
project = CONFIG['project']
173173

174174
# Find the Julia library
175-
cmd = [exepath, '--project='+project, '--startup-file=no', '-O0', '--compile=min',
175+
cmd = [exe, '--project='+project, '--startup-file=no', '-O0', '--compile=min',
176176
'-e', 'import Libdl; print(abspath(Libdl.dlpath("libjulia")), "\\0", Sys.BINDIR)']
177177
libpath, default_bindir = subprocess.run(cmd, check=True, capture_output=True, encoding='utf8').stdout.split('\0')
178178
assert os.path.exists(libpath)

0 commit comments

Comments
 (0)