Skip to content

Commit

Permalink
Use libpy_handle instead of libpython
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf authored and tkf committed Nov 10, 2018
1 parent a7c976a commit 5669d62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/pyinit.jl
Expand Up @@ -86,6 +86,8 @@ function __init__()
error("Using Conda.jl python, but location of $python seems to have moved to $(Conda.PYTHONDIR). Re-run Pkg.build(\"PyCall\") and restart Julia.")
end

global libpy_handle

# issue #189
libpy_handle = libpython === nothing ? C_NULL :
Libdl.dlopen(libpython, Libdl.RTLD_LAZY|Libdl.RTLD_GLOBAL)
Expand Down
8 changes: 4 additions & 4 deletions src/startup.jl
Expand Up @@ -125,15 +125,15 @@ if libpython == nothing
end
else
macro pysym(func)
:(($(esc(func)), libpython))
:(Libdl.dlsym(libpy_handle, $(esc(func))))
end
macro pyglobal(name)
:(cglobal(($(esc(name)), libpython)))
:(convert(Ptr{Cvoid}, Libdl.dlsym(libpy_handle, $(esc(name)))))
end
macro pyglobalobj(name)
:(cglobal(($(esc(name)), libpython), PyObject_struct))
:(convert(Ptr{PyObject_struct}, Libdl.dlsym(libpy_handle, $(esc(name)))))
end
macro pyglobalobjptr(name)
:(unsafe_load(cglobal(($(esc(name)), libpython), Ptr{PyObject_struct})))
:(unsafe_load(convert(Ptr{Ptr{PyObject_struct}}, Libdl.dlsym(libpy_handle, $(esc(name))))))
end
end

0 comments on commit 5669d62

Please sign in to comment.