From 1c8039d3adb0b5daa460fbaa9b086c60627844d6 Mon Sep 17 00:00:00 2001 From: Petr Vana Date: Mon, 8 Nov 2021 23:35:44 +0100 Subject: [PATCH 1/2] Add a warning against having multiple copies of a shared library loaded --- src/PyCall.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PyCall.jl b/src/PyCall.jl index 42713b9f..c11347b2 100644 --- a/src/PyCall.jl +++ b/src/PyCall.jl @@ -31,6 +31,7 @@ end import Conda import MacroTools # because of issue #270 import Base.Iterators: filter +import Libdl ######################################################################### @@ -472,7 +473,11 @@ end function _pyimport(name::AbstractString) cookie = ActivatePyActCtx() try - return PyObject(ccall((@pysym :PyImport_ImportModule), PyPtr, (Cstring,), name)) + pyobject = PyObject(ccall((@pysym :PyImport_ImportModule), PyPtr, (Cstring,), name)) + # From version 1.8 it is possible to detect when two versions + # of the same shared library is loaded + VERSION > v"1.7.999" && Libdl.check_dllist() + return pyobject finally DeactivatePyActCtx(cookie) end From c9d31fb0a64c786550c3ad7af326c2e0e0a7aef4 Mon Sep 17 00:00:00 2001 From: Petr Vana Date: Thu, 11 Nov 2021 20:08:10 +0100 Subject: [PATCH 2/2] Use Libdl.dlopen("") instead of check_dllist() --- src/PyCall.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PyCall.jl b/src/PyCall.jl index c11347b2..43cbe0dd 100644 --- a/src/PyCall.jl +++ b/src/PyCall.jl @@ -475,8 +475,8 @@ function _pyimport(name::AbstractString) try pyobject = PyObject(ccall((@pysym :PyImport_ImportModule), PyPtr, (Cstring,), name)) # From version 1.8 it is possible to detect when two versions - # of the same shared library is loaded - VERSION > v"1.7.999" && Libdl.check_dllist() + # of the same shared library is loaded\ + VERSION > v"1.7.999" && Libdl.dlopen("") return pyobject finally DeactivatePyActCtx(cookie)