Skip to content

Commit 9dfa3c2

Browse files
committed
use pyPreferences
1 parent 5467c72 commit 9dfa3c2

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ 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

1516
[compat]
1617
Conda = "1.0"
1718
MacroTools = "0.4, 0.5"
1819
VersionParsing = "1.0"
19-
julia = "0.7, 1.0"
20+
julia = "1.6"
2021

2122
[extras]
2223
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

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/pyinit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function __init__()
201201

202202
if new_pyversion.major != pyversion.major
203203
error("PyCall precompiled with Python $pyversion, but now using Python $new_pyversion; ",
204-
"you need to relaunch Julia and re-run Pkg.build(\"PyCall\")")
204+
"you need to relaunch Julia and run `using PyPrefernces; PyPreferences.recompile()")
205205
end
206206

207207
copy!(inspect, pyimport("inspect"))

src/startup.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,22 @@ 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
46+
PyPreferences.assert_configured()
47+
using PyPreferences: PYTHONHOME, conda, libpython, pyprogramname, python, pyversion_build
4248
# Python not present. Use deps.jl
4349
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")
50+
4651
# Only to be used at top-level - pointer will be invalid after reload
4752
libpy_handle = try
4853
Libdl.dlopen(libpython, Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)
4954
catch err
5055
if err isa ErrorException
51-
error(err.msg, ". Please run `Pkg.build(\"PyCall\")` if your Python build has changed")
56+
error(err.msg, "\n", PyPreferences.instruction_message())
5257
else
5358
rethrow(err)
5459
end

0 commit comments

Comments
 (0)