Skip to content

Commit f407963

Browse files
author
Christopher Doris
committed
don't build PyCall in tests
instead, add a case to CI where we use system python for both, ensuring we test the same case. we also add tests for the non-same case.
1 parent b861036 commit f407963

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ on:
1212

1313
jobs:
1414
julia:
15-
name: Test Julia (${{ matrix.jlversion }}, ${{ matrix.os }})
15+
name: Test Julia (${{ matrix.jlversion }}, ${{ matrix.os }}, ${{ matrix.pythonexe }})
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
arch: [x64] # x86 unsupported by MicroMamba
2121
os: [ubuntu-latest, windows-latest, macos-latest]
2222
jlversion: ['1','1.9']
23+
python: ['@CondaPkg']
24+
include:
25+
- arch: x64
26+
os: ubuntu-latest
27+
jlversion: '1'
28+
pythonexe: python
2329

2430
steps:
2531
- uses: actions/checkout@v5
@@ -34,12 +40,16 @@ jobs:
3440

3541
- name: Build package
3642
uses: julia-actions/julia-buildpkg@v1
43+
env:
44+
PYTHON: python
3745

3846
- name: Run tests
3947
uses: julia-actions/julia-runtest@v1
4048
env:
4149
JULIA_DEBUG: PythonCall
4250
JULIA_NUM_THREADS: '2'
51+
PYTHON: python
52+
JULIA_PYTHONCALL_EXE: ${{ matrix.pythonexe }}
4353

4454
- name: Process coverage
4555
uses: julia-actions/julia-processcoverage@v1

test/Compat.jl

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,25 @@ end
3838
# TODO
3939
end
4040

41-
@testitem "PyCall.jl" setup = [PyCall] begin
42-
@test Base.get_extension(PythonCall, :PyCallExt).SAME[]
43-
x1 = pylist()
44-
x2 = PyCall.PyObject(x1)
45-
x3 = Py(x2)
46-
@test pyis(x3, x1)
41+
@testitem "PyCall.jl" begin
42+
using PyCall
43+
same = Base.get_extension(PythonCall, :PyCallExt).SAME[]::Bool
44+
@info "testing PyCall" same
45+
if get(ENV, "CI", "") != ""
46+
# ensure we test both `same` and `!same` in CI
47+
@test same == (ENV["JULIA_PYTHONCALL_EXE"] == "python")
48+
end
49+
if same
50+
x1 = pylist()::Py
51+
x2 = PyCall.PyObject(x1)::PyCall.PyObject
52+
x3 = Py(x2)::Py
53+
@test pyis(x3, x1)
54+
else
55+
x1 = pylist()::Py
56+
@test_throws "only possible when using the same Python" PyCall.PyObject(x1)
57+
x2 = PyCall.pybuiltin("list")()::PyCall.PyObject
58+
@test_throws "only possible when using the same Python" Py(x2)
59+
end
4760
end
4861

4962
@testitem "Serialization.jl" begin

test/runtests.jl

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

33
@run_package_tests
4-
5-
@testmodule PyCall begin
6-
using PythonCall: PythonCall
7-
using Pkg: Pkg
8-
ENV["PYTHON"] = PythonCall.python_executable_path()
9-
@info "Building PyCall..." ENV["PYTHON"]
10-
Pkg.build("PyCall")
11-
using PyCall
12-
end

0 commit comments

Comments
 (0)