File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ def jlstr(x):
194194 try
195195 Base.require(Main, :CompilerSupportLibraries_jll)
196196 import Pkg
197- ENV["JULIA_PYTHONCALL_LIBPTR"] = {}
197+ global __PythonCall_libptr = Ptr{{Cvoid}}(UInt({}))
198198 ENV["JULIA_PYTHONCALL_EXE"] = {}
199199 Pkg.activate({}, io=devnull)
200200 import PythonCall
@@ -205,7 +205,7 @@ def jlstr(x):
205205 rethrow()
206206 end
207207 ''' .format (
208- jlstr ( str ( c .pythonapi ._handle ) ),
208+ hex ( c .pythonapi ._handle ),
209209 jlstr (sys .executable or '' ),
210210 jlstr (project ),
211211 )
Original file line number Diff line number Diff line change 3232
3333function init_context ()
3434
35- CTX. is_embedded = haskey ( ENV , " JULIA_PYTHONCALL_LIBPTR " )
35+ CTX. is_embedded = hasproperty (Base . Main, :__PythonCall_libptr )
3636
3737 if CTX. is_embedded
3838 # In this case, getting a handle to libpython is easy
39- CTX. lib_ptr = Ptr {Cvoid} ( parse (UInt, ENV [ " JULIA_PYTHONCALL_LIBPTR " ]))
39+ CTX. lib_ptr = Base . Main . __PythonCall_libptr :: Ptr{Cvoid}
4040 init_pointers ()
4141 # Check Python is initialized
4242 Py_IsInitialized () == 0 && error (" Python is not already initialized." )
@@ -48,10 +48,6 @@ function init_context()
4848 # this ensures PyCall uses the same Python interpreter
4949 get! (ENV , " PYTHON" , exe_path)
5050 end
51- # On success, delete JULIA_PYTHONCALL_LIBPTR so that further processes do not think
52- # they are embedded in Python (e.g. this can happen when precompiling).
53- # See https://github.com/cjdoris/PythonCall.jl/issues/235
54- delete! (ENV , " JULIA_PYTHONCALL_LIBPTR" )
5551 else
5652 # Find Python executable
5753 exe_path = get (ENV , " JULIA_PYTHONCALL_EXE" , " " )
You can’t perform that action at this time.
0 commit comments