Skip to content

Commit 5f8f8f7

Browse files
authored
fix #676 and test GUI compat better along the way (#683)
* fix #676 and test GUI compat better along the way * remove debug printing * require newer juliapkg * skip some tests in CI if using system python * fix ci attempt 2 * fix world age issue on Julia 1.12 * install julia 1.11 in python test workflow --------- Co-authored-by: Christopher Doris <github.com/cjdoris>
1 parent 71666ca commit 5f8f8f7

File tree

9 files changed

+47
-14
lines changed

9 files changed

+47
-14
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ jobs:
8484
uses: actions/setup-python@v6
8585
with:
8686
python-version: ${{ matrix.pyversion }}
87+
88+
- name: Check Python OpenSSL version (see setup_julia)
89+
shell: python
90+
run: |
91+
import ssl
92+
assert ssl.OPENSSL_VERSION_INFO < (3, 5)
8793
8894
- name: Set up uv
8995
uses: astral-sh/setup-uv@v6
@@ -94,7 +100,9 @@ jobs:
94100
id: setup_julia
95101
uses: julia-actions/setup-julia@v2
96102
with:
97-
version: '1'
103+
# Python in the GitHub runners ships with OpenSSL 3.0. Julia 1.12 requires
104+
# OpenSSL 3.5. Therefore juliapkg requires Julia 1.11 or lower.
105+
version: '1.11'
98106

99107
- name: Set up test Julia project
100108
if: ${{ matrix.juliaexe == 'julia' }}

CondaPkg.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
[deps.libstdcxx]
1+
2+
[deps.openssl]
23
version = "<=julia"
34

4-
[deps.libstdcxx-ng]
5+
[deps.libstdcxx]
56
version = "<=julia"
67

7-
[deps.openssl]
8+
[deps.libstdcxx-ng]
89
version = "<=julia"
910

1011
[deps.python]
1112
build = "**cpython**"
1213
version = ">=3.9,<4"
14+
15+
[dev.deps]
16+
matplotlib = ""
17+
pyside6 = ""

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ UnsafePointers = "e17b2a0c-0bdf-430a-bd0c-3a23cae4ff39"
1717
[compat]
1818
Aqua = "0 - 999"
1919
CategoricalArrays = "0.10, 1"
20-
CondaPkg = "0.2.30"
20+
CondaPkg = "0.2.33"
2121
Dates = "1"
2222
Libdl = "1"
2323
MacroTools = "0.5"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ classifiers = [
1313
"Operating System :: OS Independent",
1414
]
1515
requires-python = ">=3.9, <4"
16-
dependencies = ["juliapkg >=0.1.17, <0.2"]
16+
dependencies = ["juliapkg >=0.1.21, <0.2"]
1717

1818
[dependency-groups]
1919
dev = [

src/Compat/gui.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function init_gui()
159159

160160
# add a hook to automatically call fix_qt_plugin_path()
161161
fixqthook =
162-
Py(() -> (Core.CONFIG.auto_fix_qt_plugin_path && fix_qt_plugin_path(); nothing))
162+
Py(() -> (PythonCall.CONFIG.auto_fix_qt_plugin_path && fix_qt_plugin_path(); nothing))
163163
pymodulehooks.add_hook("PyQt4", fixqthook)
164164
pymodulehooks.add_hook("PyQt5", fixqthook)
165165
pymodulehooks.add_hook("PySide", fixqthook)

src/Core/stdlib.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function init_stdlib()
4040
class JuliaCompatHooks:
4141
def __init__(self):
4242
self.hooks = {}
43-
def find_module(self, name, path=None):
43+
def find_spec(self, name, path=None, target=None):
4444
hs = self.hooks.get(name)
4545
if hs is not None:
4646
for h in hs:

src/JlWrap/any.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ function pyjlany_setattr(self, k_::Py, v_::Py)
2828
v = pyconvert(Any, v_)
2929
if self isa Module && !isdefined(self, k)
3030
# Fix for https://github.com/JuliaLang/julia/pull/54678
31-
Base.Core.eval(self, Expr(:global, k))
31+
@eval self (global $k = $v)
32+
else
33+
setproperty!(self, k, v)
3234
end
33-
setproperty!(self, k, v)
3435
Py(nothing)
3536
end
3637
pyjl_handle_error_type(::typeof(pyjlany_setattr), self, exc) = pybuiltins.AttributeError

test/Compat.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
@testitem "gui" begin
1+
@testitem "gui" setup=[Setup] begin
22
@testset "fix_qt_plugin_path" begin
33
@test PythonCall.fix_qt_plugin_path() isa Bool
44
# second time is a no-op
55
@test PythonCall.fix_qt_plugin_path() === false
66
end
77
@testset "event_loop_on/off" begin
8-
for g in [:pyqt4, :pyqt5, :pyside, :pyside2, :pyside6, :gtk, :gtk3, :wx]
8+
@testset "$g" for g in [:pyqt4, :pyqt5, :pyside, :pyside2, :pyside6, :gtk, :gtk3, :wx]
99
# TODO: actually test the various GUIs somehow?
10-
@show g
11-
@test_throws PyException PythonCall.event_loop_on(g)
10+
if Setup.devdeps && g == :pyside6
11+
# pyside6 is installed as a dev dependency
12+
# AND it's a dependency of matplotlib, which is also a dev dependency
13+
@test PythonCall.event_loop_on(g) isa Timer
14+
else
15+
@test_throws PyException PythonCall.event_loop_on(g)
16+
end
1217
@test PythonCall.event_loop_off(g) === nothing
1318
end
1419
end
20+
@testset "matplotlib issue 676" begin
21+
if Setup.devdeps
22+
plt = pyimport("matplotlib.pyplot")
23+
@test plt.get_backend() isa Py
24+
end
25+
end
1526
end
1627

1728
@testitem "ipython" begin

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
using TestItemRunner
22

3+
@testmodule Setup begin
4+
using PythonCall
5+
# test if we are in CI
6+
ci = get(ENV, "CI", "") == "true"
7+
# test if we have all dev conda deps
8+
devdeps = PythonCall.C.CTX.which == :CondaPkg
9+
end
10+
311
@run_package_tests

0 commit comments

Comments
 (0)