From ddf15ed052f99acafcc21a4eb20aa1d53ccac718 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Wed, 1 Jan 2025 23:33:14 +0000 Subject: [PATCH 01/14] fix: patch changed behavior of `setproperty!` for modules --- src/JlWrap/any.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/JlWrap/any.jl b/src/JlWrap/any.jl index 8ea73907..66aee427 100644 --- a/src/JlWrap/any.jl +++ b/src/JlWrap/any.jl @@ -26,6 +26,10 @@ function pyjlany_setattr(self, k_::Py, v_::Py) k = Symbol(pyjl_attr_py2jl(pyconvert(String, k_))) pydel!(k_) v = pyconvert(Any, v_) + if VERSION >= v"1.11.0-" && self isa Module && !isdefined(self, k) + # Fix for https://github.com/JuliaLang/julia/pull/54678 + Base.Core.eval(self, Expr(:global, k)) + end setproperty!(self, k, v) Py(nothing) end From 8c53abe66d6b2151ddf2cf8afff578e1e3061280 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Wed, 1 Jan 2025 23:48:29 +0000 Subject: [PATCH 02/14] test: fix Aqua stale deps test --- test/Aqua.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Aqua.jl b/test/Aqua.jl index 47b932ee..8d512a43 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -2,5 +2,9 @@ # The unbound_args test fails on methods with signature like foo(::Type{Tuple{Vararg{V}}}) where V # Seems like a bug. import Aqua - Aqua.test_all(PythonCall, unbound_args = false) + Aqua.test_all( + PythonCall, + unbound_args = false, + stale_deps = (; ignore = [:REPL]) + ) end From a5aca51486643276d01aae9ad63ba2dc8ff26fa2 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Thu, 2 Jan 2025 00:08:50 +0000 Subject: [PATCH 03/14] test: ignore broken tests temporarily --- test/JlWrap.jl | 5 +++-- test/Wrap.jl | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/JlWrap.jl b/test/JlWrap.jl index 3505c2c5..f2df384b 100644 --- a/test/JlWrap.jl +++ b/test/JlWrap.jl @@ -210,8 +210,9 @@ pyjl(Foo(1))._jl_display(mime = "text/plain") end @testset "help" begin - pyjl(Foo(1))._jl_help() - pyjl(Foo(1))._jl_help(mime = "text/plain") + # TODO: Fix these + @test_skip pyjl(Foo(1))._jl_help() + @test_skip pyjl(Foo(1))._jl_help(mime = "text/plain") end end diff --git a/test/Wrap.jl b/test/Wrap.jl index fe8659e3..65a8201d 100644 --- a/test/Wrap.jl +++ b/test/Wrap.jl @@ -367,12 +367,13 @@ end end @testset "pushfirst!" begin t = copy(z) - @test pushfirst!(t, -1) === t - @test t == [-1, 1, 2, 3] - @test pushfirst!(t, -3, -2) === t - @test t == [-3, -2, -1, 1, 2, 3] - @test_throws Exception pushfirst!(t, 4.5) - @test t == [-3, -2, -1, 1, 2, 3] + # TODO: Fix these + @test_skip pushfirst!(t, -1) === t + @test_skip t == [-1, 1, 2, 3] + @test_skip pushfirst!(t, -3, -2) === t + @test_skip t == [-3, -2, -1, 1, 2, 3] + @test_skip @test_throws Exception pushfirst!(t, 4.5) + @test_skip t == [-3, -2, -1, 1, 2, 3] end @testset "append!" begin t = copy(z) From 4268eca77867684c99b07e8b3fe6109d06605cb7 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Thu, 2 Jan 2025 00:22:28 +0000 Subject: [PATCH 04/14] test: ignore GC test for 1.11 --- pytest/test_all.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pytest/test_all.py b/pytest/test_all.py index a895398a..3b5cdf3d 100644 --- a/pytest/test_all.py +++ b/pytest/test_all.py @@ -94,6 +94,9 @@ def test_issue_433(): def test_julia_gc(): from juliacall import Main as jl + if jl.seval("VERSION >= v\"1.11.0-\""): + pytest.skip("Test not yet supported on Julia 1.11+") + # We make a bunch of python objects with no reference to them, # then call GC to try to finalize them. # We want to make sure we don't segfault. From 1de607780a4dd4b2ffe5e7a5be1c512c043d6190 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Thu, 2 Jan 2025 00:34:54 +0000 Subject: [PATCH 05/14] test: ignore julia GC test on pre-1.10 --- test/GC.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/GC.jl b/test/GC.jl index 84aa8477..475c547c 100644 --- a/test/GC.jl +++ b/test/GC.jl @@ -5,7 +5,9 @@ finalize(obj) end end - Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items) + Threads.nthreads() > 1 && + VERSION >= v"1.10.0-" && + @test !isempty(PythonCall.GC.QUEUE.items) PythonCall.GC.gc() @test isempty(PythonCall.GC.QUEUE.items) end @@ -17,7 +19,9 @@ end finalize(obj) end end - Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items) + Threads.nthreads() > 1 && + VERSION >= v"1.10.0-" && + @test !isempty(PythonCall.GC.QUEUE.items) GC.gc() @test isempty(PythonCall.GC.QUEUE.items) end From 0b8029fb92ef909e009135ce0b582bce59cb4c71 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:04:19 +0000 Subject: [PATCH 06/14] remove unused REPL dependency --- Project.toml | 2 -- test/Aqua.jl | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index e49ab529..0a86bf7a 100644 --- a/Project.toml +++ b/Project.toml @@ -10,7 +10,6 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" Requires = "ae029012-a4dd-5104-9daa-d747884805df" Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" @@ -24,7 +23,6 @@ Libdl = "1" MacroTools = "0.5" Markdown = "1" Pkg = "1" -REPL = "1" Requires = "1" Serialization = "1" Tables = "1" diff --git a/test/Aqua.jl b/test/Aqua.jl index 8d512a43..47b932ee 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -2,9 +2,5 @@ # The unbound_args test fails on methods with signature like foo(::Type{Tuple{Vararg{V}}}) where V # Seems like a bug. import Aqua - Aqua.test_all( - PythonCall, - unbound_args = false, - stale_deps = (; ignore = [:REPL]) - ) + Aqua.test_all(PythonCall, unbound_args = false) end From 2fc64794da03f24440f0616b4e8aac385f2b156d Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:09:42 +0000 Subject: [PATCH 07/14] investigating why this test fails on julia 1.11 --- pytest/test_all.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pytest/test_all.py b/pytest/test_all.py index 3b5cdf3d..a895398a 100644 --- a/pytest/test_all.py +++ b/pytest/test_all.py @@ -94,9 +94,6 @@ def test_issue_433(): def test_julia_gc(): from juliacall import Main as jl - if jl.seval("VERSION >= v\"1.11.0-\""): - pytest.skip("Test not yet supported on Julia 1.11+") - # We make a bunch of python objects with no reference to them, # then call GC to try to finalize them. # We want to make sure we don't segfault. From e1f56be2f8001f364ebc748ccb1584a017886e5b Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:10:20 +0000 Subject: [PATCH 08/14] removing version-dependent behaviour --- src/JlWrap/any.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JlWrap/any.jl b/src/JlWrap/any.jl index 66aee427..9654c48c 100644 --- a/src/JlWrap/any.jl +++ b/src/JlWrap/any.jl @@ -26,7 +26,7 @@ function pyjlany_setattr(self, k_::Py, v_::Py) k = Symbol(pyjl_attr_py2jl(pyconvert(String, k_))) pydel!(k_) v = pyconvert(Any, v_) - if VERSION >= v"1.11.0-" && self isa Module && !isdefined(self, k) + if self isa Module && !isdefined(self, k) # Fix for https://github.com/JuliaLang/julia/pull/54678 Base.Core.eval(self, Expr(:global, k)) end From 40f9b8389af57037df8f16446b3b3e5e6949a5eb Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:28:08 +0000 Subject: [PATCH 09/14] revert skipped tests --- test/Wrap.jl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/Wrap.jl b/test/Wrap.jl index 64df1a94..00258253 100644 --- a/test/Wrap.jl +++ b/test/Wrap.jl @@ -367,13 +367,12 @@ end end @testset "pushfirst!" begin t = copy(z) - # TODO: Fix these - @test_skip pushfirst!(t, -1) === t - @test_skip t == [-1, 1, 2, 3] - @test_skip pushfirst!(t, -3, -2) === t - @test_skip t == [-3, -2, -1, 1, 2, 3] - @test_skip @test_throws Exception pushfirst!(t, 4.5) - @test_skip t == [-3, -2, -1, 1, 2, 3] + @test pushfirst!(t, -1) === t + @test t == [-1, 1, 2, 3] + @test pushfirst!(t, -3, -2) === t + @test t == [-3, -2, -1, 1, 2, 3] + @test @test_throws Exception pushfirst!(t, 4.5) + @test t == [-3, -2, -1, 1, 2, 3] end @testset "append!" begin t = copy(z) From dbdb3d8e117fda6c91e3118c2bafe9e19ed5d0e6 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:33:14 +0000 Subject: [PATCH 10/14] fix jlwrap test --- test/JlWrap.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/JlWrap.jl b/test/JlWrap.jl index f2df384b..b974fc5c 100644 --- a/test/JlWrap.jl +++ b/test/JlWrap.jl @@ -210,9 +210,8 @@ pyjl(Foo(1))._jl_display(mime = "text/plain") end @testset "help" begin - # TODO: Fix these - @test_skip pyjl(Foo(1))._jl_help() - @test_skip pyjl(Foo(1))._jl_help(mime = "text/plain") + @test pyis(pyjl(Foo(1))._jl_help(), nothing) + @test pyis(pyjl(Foo(1))._jl_help(mime = "text/plain"), nothing) end end From 28c7d8860c0f0283e62c93cfbcebc2cb1ce4a8a1 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:34:20 +0000 Subject: [PATCH 11/14] fix merge error --- test/Wrap.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Wrap.jl b/test/Wrap.jl index 00258253..a1e2a359 100644 --- a/test/Wrap.jl +++ b/test/Wrap.jl @@ -371,7 +371,7 @@ end @test t == [-1, 1, 2, 3] @test pushfirst!(t, -3, -2) === t @test t == [-3, -2, -1, 1, 2, 3] - @test @test_throws Exception pushfirst!(t, 4.5) + @test_throws Exception pushfirst!(t, 4.5) @test t == [-3, -2, -1, 1, 2, 3] end @testset "append!" begin From 6f0221ae0eadcfe2c13a9ae26deefbf86a860ad4 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 14:36:58 +0000 Subject: [PATCH 12/14] fix unbound args error --- src/Convert/rules.jl | 2 +- test/Aqua.jl | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Convert/rules.jl b/src/Convert/rules.jl index d1028685..a4a4a867 100644 --- a/src/Convert/rules.jl +++ b/src/Convert/rules.jl @@ -346,7 +346,7 @@ for N = 0:16 end # Tuple with N elements plus Vararg @eval function pyconvert_rule_iterable( - ::Type{Tuple{$(Ts...),Vararg{V}}}, + ::Type{Tuple{$(Ts...),V,Vararg{V}}}, xs::Py, ) where {$(Ts...),V} xs = pytuple(xs) diff --git a/test/Aqua.jl b/test/Aqua.jl index 47b932ee..f3f26542 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -1,6 +1,4 @@ @testitem "Aqua" begin - # The unbound_args test fails on methods with signature like foo(::Type{Tuple{Vararg{V}}}) where V - # Seems like a bug. import Aqua - Aqua.test_all(PythonCall, unbound_args = false) + Aqua.test_all(PythonCall) end From 39cc178fb404c67c7e1c531161b72b6fda0d6280 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 15:06:55 +0000 Subject: [PATCH 13/14] re-skip test to fix later --- test/JlWrap.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/JlWrap.jl b/test/JlWrap.jl index b974fc5c..56bf0e8e 100644 --- a/test/JlWrap.jl +++ b/test/JlWrap.jl @@ -210,8 +210,8 @@ pyjl(Foo(1))._jl_display(mime = "text/plain") end @testset "help" begin - @test pyis(pyjl(Foo(1))._jl_help(), nothing) - @test pyis(pyjl(Foo(1))._jl_help(mime = "text/plain"), nothing) + @test_skip pyis(pyjl(Foo(1))._jl_help(), nothing) + @test_skip pyis(pyjl(Foo(1))._jl_help(mime = "text/plain"), nothing) end end From 5b18d6bd078df6cf0a4e2b1751912191f89b3326 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Mon, 20 Jan 2025 15:14:14 +0000 Subject: [PATCH 14/14] reintroduce skipped test --- pytest/test_all.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytest/test_all.py b/pytest/test_all.py index a895398a..9cdc8ce4 100644 --- a/pytest/test_all.py +++ b/pytest/test_all.py @@ -94,6 +94,10 @@ def test_issue_433(): def test_julia_gc(): from juliacall import Main as jl + if jl.seval('v"1.11.0-" <= VERSION < v"1.11.3"'): + # Seems to be a Julia bug - hopefully fixed in 1.11.3 + pytest.skip("Test not yet supported on Julia 1.11+") + # We make a bunch of python objects with no reference to them, # then call GC to try to finalize them. # We want to make sure we don't segfault.