File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -127,18 +127,14 @@ def path_option(name, default=None):
127127 os .environ ['JULIA_PYTHONCALL_LIBPTR' ] = str (c .pythonapi ._handle )
128128 os .environ ['JULIA_PYTHONCALL_EXE' ] = sys .executable or ''
129129 os .environ ['JULIA_PYTHONCALL_PROJECT' ] = project
130+ os .environ ['JULIA_PYTHONCALL_INIT_JL' ] = os .path .join (os .path .dirname (__file__ ), 'init.jl' )
130131 script = '''
131- try
132- import Pkg
133- Pkg.activate(ENV["JULIA_PYTHONCALL_PROJECT"], io=devnull)
134- import PythonCall
135- catch err
136- print(stderr, "ERROR: ")
137- showerror(stderr, err, catch_backtrace())
138- flush(stderr)
139- rethrow()
140- end
141- '''
132+ # This uses some internals, but Base._start() gets the state more like Julia
133+ # is if you call the executable directly, in particular it creates workers when
134+ # the --procs argument is given.
135+ push!(Core.ARGS, ENV["JULIA_PYTHONCALL_INIT_JL"])
136+ Base._start()
137+ '''
142138 res = lib .jl_eval_string (script .encode ('utf8' ))
143139 if res is None :
144140 raise Exception ('PythonCall.jl did not start properly' )
Original file line number Diff line number Diff line change 1+ try
2+ import Pkg
3+ Pkg. activate (ENV [" JULIA_PYTHONCALL_PROJECT" ], io= devnull )
4+ import PythonCall
5+ catch err
6+ print (stderr , " ERROR: " )
7+ showerror (stderr , err, catch_backtrace ())
8+ flush (stderr )
9+ rethrow ()
10+ end
You can’t perform that action at this time.
0 commit comments