Skip to content

Commit a955681

Browse files
committed
Use PyPreferences
1 parent fbd0bba commit a955681

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
99
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1010
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
12+
PyPreferences = "cc9521c6-0242-4dda-8d66-c47a9d9eec02"
1213
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1314
VersionParsing = "81def892-9a0e-5fdd-b105-ffc91e053289"
1415

src/PyCall.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optle
44
@eval Base.Experimental.@optlevel 1
55
end
66

7+
using PyPreferences
78
using VersionParsing
89

910
export pycall, pycall!, pyimport, pyimport_e, pybuiltin, PyObject, PyReverseDims,

src/startup.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,19 @@ else
3838
global symbols_present = hassym(proc_handle, :Py_GetVersion)
3939
end
4040

41+
if PyPreferences.inprocess
42+
@assert symbols_present # TODO: better error
43+
end
44+
4145
if !symbols_present
42-
# Python not present. Use deps.jl
43-
const depfile = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
44-
isfile(depfile) || error("PyCall not properly installed. Please run Pkg.build(\"PyCall\")")
45-
include(depfile) # generated by Pkg.build("PyCall")
46+
PyPreferences.assert_configured()
47+
using PyPreferences: PYTHONHOME, conda, libpython, pyprogramname, python, pyversion_build
4648
# Only to be used at top-level - pointer will be invalid after reload
4749
libpy_handle = try
4850
Libdl.dlopen(libpython, Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)
4951
catch err
5052
if err isa ErrorException
51-
error(err.msg, ". Please run `Pkg.build(\"PyCall\")` if your Python build has changed")
53+
error(err.msg, "\n", PyPreferences.instruction_message())
5254
else
5355
rethrow(err)
5456
end

0 commit comments

Comments
 (0)