@@ -6,7 +6,33 @@ function init_stdlib()
66 pywordsize = @py (jlbool (pysysmodule. maxsize > 2 ^ 32 )) ? 64 : 32
77 pywordsize == Sys. WORD_SIZE || error (" Julia is $(Sys. WORD_SIZE) -bit but Python is $(pywordsize) -bit" )
88
9- if ! C. CTX. is_embedded
9+ if C. CTX. is_embedded
10+
11+ # This uses some internals, but Base._start() gets the state more like Julia
12+ # is if you call the executable directly, in particular it creates workers when
13+ # the --procs argument is given.
14+ push! (Core. ARGS , joinpath (ROOT_DIR, " pysrc" , " juliacall" , " init.jl" ))
15+ Base. _start ()
16+ Base. eval (:(PROGRAM_FILE = " " ))
17+
18+ # if Python is interactive, ensure Julia is too
19+ if pyhasattr (pysysmodule, " ps1" )
20+ Base. eval (:(is_interactive = true ))
21+ REPL = Base. require (Base. PkgId (Base. UUID (" 3fa0cd96-eef1-5676-8a61-b3b8758bbffb" ), " REPL" ))
22+ # adapted from run_main_repl() in julia/base/client.jl
23+ Base. load_InteractiveUtils ()
24+ term_env = get (ENV , " TERM" , Sys. iswindows () ? " " : " dumb" )
25+ term = REPL. Terminals. TTYTerminal (term_env, stdin , stdout , stderr )
26+ if term. term_type == " dumb"
27+ repl = REPL. BasicREPL (term)
28+ else
29+ repl = REPL. LineEditREPL (term, get (stdout , :color , false ), true )
30+ repl. history_file = false
31+ end
32+ pushdisplay (REPL. REPLDisplay (repl))
33+ end
34+
35+ else
1036
1137 # set sys.argv
1238 pysysmodule. argv = pylist ([" " ; ARGS ])
0 commit comments