Skip to content

Commit 5039c79

Browse files
author
Christopher Doris
committed
better compat with Distributed
1 parent 5f58a97 commit 5039c79

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

pysrc/juliacall/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,22 @@ def path_option(name, default=None):
129129
os.environ['JULIA_PYTHONCALL_PROJECT'] = project
130130
os.environ['JULIA_PYTHONCALL_INIT_JL'] = os.path.join(os.path.dirname(__file__), 'init.jl')
131131
script = '''
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()
132+
try
133+
import Pkg
134+
Pkg.activate(ENV["JULIA_PYTHONCALL_PROJECT"], io=devnull)
135+
import PythonCall
136+
# This uses some internals, but Base._start() gets the state more like Julia
137+
# is if you call the executable directly, in particular it creates workers when
138+
# the --procs argument is given.
139+
push!(Core.ARGS, ENV["JULIA_PYTHONCALL_INIT_JL"])
140+
Base._start()
141+
@eval Base PROGRAM_FILE=""
142+
catch err
143+
print(stderr, "ERROR: ")
144+
showerror(stderr, err, catch_backtrace())
145+
flush(stderr)
146+
rethrow()
147+
end
137148
'''
138149
res = lib.jl_eval_string(script.encode('utf8'))
139150
if res is None:

pysrc/juliacall/init.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
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
1+
# Blank script for Base._start() to run instead of starting the REPL.

0 commit comments

Comments
 (0)