Skip to content

Commit 0e3f2ac

Browse files
tkfstevengj
authored andcommitted
Fix show_dlopen_error (#596)
* Fix show_dlopen_error See the first version of the comment #592 (comment) * Fix a possible bug in exec_find_libpython The previous code accidentally worked presumably because $PWD was set do deps when running deps/build.jl. Cherry-picked from #595.
1 parent ae9bbba commit 0e3f2ac

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

deps/build.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,19 @@ const dlprefix = Compat.Sys.iswindows() ? "" : "lib"
5151
const PYCALL_DEBUG_BUILD = "yes" == get(ENV, "PYCALL_DEBUG_BUILD", "no")
5252

5353
function exec_find_libpython(python::AbstractString, options)
54-
cmd = `$python $(joinpath(@__DIR__, "find_libpython.py")) $options`
54+
# Do not inline `@__DIR__` into the backticks to expand correctly.
55+
# See: https://github.com/JuliaLang/julia/issues/26323
56+
script = joinpath(@__DIR__, "find_libpython.py")
57+
cmd = `$python $script $options`
5558
if PYCALL_DEBUG_BUILD
5659
cmd = `$cmd --verbose`
5760
end
5861
return readlines(pythonenv(cmd))
5962
end
6063

61-
function show_dlopen_error(e)
64+
function show_dlopen_error(lib, e)
6265
if PYCALL_DEBUG_BUILD
63-
println(stderr, "dlopen($libpath_lib) ==> ", e)
66+
println(stderr, "dlopen($lib) ==> ", e)
6467
# Using STDERR since find_libpython.py prints debugging
6568
# messages to STDERR too.
6669
end
@@ -75,7 +78,7 @@ function find_libpython(python::AbstractString)
7578
try
7679
return (Libdl.dlopen(lib, dlopen_flags), lib)
7780
catch e
78-
show_dlopen_error(e)
81+
show_dlopen_error(lib, e)
7982
end
8083
end
8184

@@ -94,7 +97,7 @@ function find_libpython(python::AbstractString)
9497
# compare libpython.
9598
return (libpython, Libdl.dlpath(libpython))
9699
catch e
97-
show_dlopen_error(e)
100+
show_dlopen_error(lib, e)
98101
end
99102
end
100103

0 commit comments

Comments
 (0)