@@ -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,21 +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 ['project' ] = path_option ('project' , check_exists = True )[0 ]
151+ CONFIG ['exe' ] = path_option ('exe' , check_exists = True )[0 ]
150152
151153 # Stop if we already initialised
152154 if CONFIG ['inited' ]:
153155 return
154156
155- # we don't import this at the top level because it is not required when juliacall is
156- # loaded by PythonCall and won't be available
157- import juliapkg
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 :
160+ # we don't import this at the top level because it is not required when
161+ # juliacall is loaded by PythonCall and won't be available, or if both
162+ # `exe` and `project` are set by the user.
163+ import juliapkg
158164
159- # Find the Julia executable and project
160- CONFIG ['exepath' ] = exepath = juliapkg .executable ()
161- CONFIG ['project' ] = project = juliapkg .project ()
165+ # Find the Julia executable and 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." )
170+
171+ exe = CONFIG ['exe' ]
172+ project = CONFIG ['project' ]
162173
163174 # Find the Julia library
164- cmd = [exepath , '--project=' + project , '--startup-file=no' , '-O0' , '--compile=min' ,
175+ cmd = [exe , '--project=' + project , '--startup-file=no' , '-O0' , '--compile=min' ,
165176 '-e' , 'import Libdl; print(abspath(Libdl.dlpath("libjulia")), "\\ 0", Sys.BINDIR)' ]
166177 libpath , default_bindir = subprocess .run (cmd , check = True , capture_output = True , encoding = 'utf8' ).stdout .split ('\0 ' )
167178 assert os .path .exists (libpath )
0 commit comments