Skip to content

Commit 9780c69

Browse files
committed
don't require MacroTools in default package environment
1 parent cb55370 commit 9780c69

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/julia/pyjulia_helper.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ module _PyJuliaHelper
22

33
using PyCall
44
using PyCall: pyeval_, Py_eval_input, Py_file_input
5-
using MacroTools
6-
using MacroTools: isexpr
5+
using PyCall.MacroTools: isexpr, walk
76

87
if VERSION < v"0.7-"
98
nameof(m::Module) = ccall(:jl_module_name, Ref{Symbol}, (Any,), m)
@@ -52,11 +51,11 @@ end
5251

5352
macro prepare_for_pyjulia_call(ex)
5453

55-
# f(x) returns transformed expression x and whether to recurse
54+
# f(x) should return a transformed expression x and whether to recurse
5655
# into the new expression
57-
function walk(f, x)
56+
function stoppable_walk(f, x)
5857
(fx, recurse) = f(x)
59-
MacroTools.walk(fx, (recurse ? (x -> walk(f,x)) : identity), identity)
58+
walk(fx, (recurse ? (x -> stoppable_walk(f,x)) : identity), identity)
6059
end
6160

6261
locals = gensym("locals")
@@ -69,7 +68,7 @@ macro prepare_for_pyjulia_call(ex)
6968
:($convert($T, $pyeval_($code, $(Expr(:$,globals)), $(Expr(:$,locals)), $input_type)))
7069
end
7170

72-
ex = walk(ex) do x
71+
ex = stoppable_walk(ex) do x
7372
if isexpr(x, :$)
7473
if isexpr(x.args[1], :$)
7574
x.args[1], false

0 commit comments

Comments
 (0)