diff --git a/Project.toml b/Project.toml index 02209fdc..064df3be 100644 --- a/Project.toml +++ b/Project.toml @@ -23,6 +23,7 @@ Libdl = "1" MacroTools = "0.5" Markdown = "1" Pkg = "1" +PyCall = "1" Requires = "1" Serialization = "1" Tables = "1" @@ -33,8 +34,9 @@ julia = "1.9" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" [targets] -test = ["Aqua", "Test", "TestItemRunner"] +test = ["Aqua", "PyCall", "Test", "TestItemRunner"] diff --git a/src/Compat/Compat.jl b/src/Compat/Compat.jl index 7e3c9584..db8bd566 100644 --- a/src/Compat/Compat.jl +++ b/src/Compat/Compat.jl @@ -15,11 +15,7 @@ using Serialization: Serialization, AbstractSerializer, serialize, deserialize using Tables: Tables using Requires: @require -import ..PythonCall: - event_loop_on, - event_loop_off, - fix_qt_plugin_path, - pytable +import ..PythonCall: event_loop_on, event_loop_off, fix_qt_plugin_path, pytable include("gui.jl") include("ipython.jl") diff --git a/src/Compat/pycall.jl b/src/Compat/pycall.jl index 2dbfc3d1..7cc54a47 100644 --- a/src/Compat/pycall.jl +++ b/src/Compat/pycall.jl @@ -10,7 +10,7 @@ function init_pycall(PyCall::Module) - Set the environment variable `PYTHON` to `PythonCall.C.CTX.exe_path` and rebuild PyCall. This forces PyCall to use the same interpreter as PythonCall, but needs to be repeated whenever you switch Julia environment. """ - @eval function Core.Py(x::$PyCall.PyObject) + @eval function PythonCall.Py(x::$PyCall.PyObject) C.CTX.matches_pycall::Bool || error($errmsg) return pynew(C.PyPtr($PyCall.pyreturn(x))) end diff --git a/test/Compat.jl b/test/Compat.jl index 4db316d5..3753dd40 100644 --- a/test/Compat.jl +++ b/test/Compat.jl @@ -38,8 +38,13 @@ end # TODO end -@testitem "PyCall.jl" begin - # TODO +@testitem "PyCall.jl" setup = [PyCall] begin + x1 = pylist() + x2 = PyCall.PyObject(x1) + x3 = Py(x2) + @test PythonCall.C.CTX.matches_pycall + @test pyisinstance(x3, pybuiltins.list) + @test pyis(x3, x1) end @testitem "Serialization.jl" begin diff --git a/test/runtests.jl b/test/runtests.jl index b9e874db..a4e2b920 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,3 +1,12 @@ using TestItemRunner @run_package_tests + +@testmodule PyCall begin + using PythonCall: PythonCall + using Pkg: Pkg + ENV["PYTHON"] = PythonCall.python_executable_path() + @info "Building PyCall..." ENV["PYTHON"] + Pkg.build("PyCall") + using PyCall +end