Skip to content

Commit c26c9fe

Browse files
authored
Fix building Python bindings with Clang and add corresponding CI actions (#320)
1 parent c595e88 commit c26c9fe

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

.github/workflows/debian.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ jobs:
2525
Build:
2626
name: ${{ matrix.config.name }}
2727
runs-on: ubuntu-latest
28-
container:
29-
image: ikarusproject/ikarus-dev:latest # this does not work for the python binding tests since the dune base bindings are configured with gcc and here ikarus her executed with clang, we may use ikarus-dev-clang later here
30-
options: --memory-swap="20g" --memory="20g" --cpus="2" --user root
3128
strategy:
3229
fail-fast: false
3330
matrix:
3431
config:
3532
- {
3633
name: "Clang-16-Debug",
34+
container: "ikarusproject/ikarus-dev-clang:latest",
3735
config: Debug,
3836
compilerC: clang-16,
3937
compilerCxx: clang++-16,
@@ -42,14 +40,34 @@ jobs:
4240
}
4341
- {
4442
name: "Clang-16-Release",
43+
container: "ikarusproject/ikarus-dev-clang:latest",
4544
config: Release,
4645
compilerC: clang-16,
4746
compilerCxx: clang++-16,
4847
lib: "-stdlib=libc++",
4948
testRegex: "cpp",
5049
}
50+
- {
51+
name: "Clang-16-Python-Release",
52+
container: "ikarusproject/ikarus-dev-clang:latest",
53+
config: Release,
54+
compilerC: clang-16,
55+
compilerCxx: clang++-16,
56+
lib: "-stdlib=libc++",
57+
testRegex: "python",
58+
}
59+
- {
60+
name: "Clang-16-Python-Debug",
61+
container: "ikarusproject/ikarus-dev-clang:latest",
62+
config: Debug,
63+
compilerC: clang-16,
64+
compilerCxx: clang++-16,
65+
lib: "-stdlib=libc++",
66+
testRegex: "python",
67+
}
5168
- {
5269
name: "Gcc-12-Debug",
70+
container: "ikarusproject/ikarus-dev-gcc:latest",
5371
config: Debug,
5472
compilerC: gcc-12,
5573
compilerCxx: g++-12,
@@ -58,20 +76,36 @@ jobs:
5876
}
5977
- {
6078
name: "Gcc-12-Release",
79+
container: "ikarusproject/ikarus-dev-gcc:latest",
6180
config: Release,
6281
compilerC: gcc-12,
6382
compilerCxx: g++-12,
6483
lib: "",
6584
testRegex: "cpp",
6685
}
6786
- {
68-
name: "Gcc-12-Python",
87+
name: "Gcc-12-Python-Release",
88+
container: "ikarusproject/ikarus-dev-gcc:latest",
6989
config: Release,
7090
compilerC: gcc-12,
7191
compilerCxx: g++-12,
7292
lib: "",
7393
testRegex: "python",
7494
}
95+
- {
96+
name: "Gcc-12-Python-Debug",
97+
container: "ikarusproject/ikarus-dev-gcc:latest",
98+
config: Debug,
99+
compilerC: gcc-12,
100+
compilerCxx: g++-12,
101+
lib: "",
102+
testRegex: "python",
103+
}
104+
container:
105+
image: ${{ matrix.config.container }}
106+
options: --memory-swap="20g" --memory="20g" --cpus="2" --user root
107+
env:
108+
IKARUS_PYTHON_TEST_BUILD_TYPE_OVERRIDE: ${{ matrix.config.config }}
75109
steps:
76110
- uses: actions/checkout@v4
77111
with:

.github/workflows/testpythonpackage.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ on:
2121
- "**.md"
2222
workflow_dispatch:
2323

24+
env:
25+
IKARUS_PYTHON_TEST_BUILD_TYPE_OVERRIDE: "Debug"
26+
2427
jobs:
2528
build-n-test:
2629
runs-on: ubuntu-latest
2730
container:
28-
image: ikarusproject/ikarus-dev:latest
31+
image: ikarusproject/ikarus-dev-clang:latest
2932
options: --memory-swap="20g" --memory="20g" --cpus="2" --user root
3033

3134
steps:

ikarus/python/test/debug_info.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
# SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers [email protected]
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33
import os
4+
import dune.generator as generator
5+
from logging import info
46

57
os.environ["DUNE_LOG_LEVEL"] = "debug"
68
os.environ["DUNE_SAVE_BUILD"] = "terminal"
79

810

911
def setDebugFlags():
10-
import dune.generator as generator
12+
def apply_debug_flags():
13+
generator.setFlags("-g ", noChecks=False)
14+
15+
# Check if the environment variable is set
16+
build_type = os.environ.get("IKARUS_PYTHON_TEST_BUILD_TYPE_OVERRIDE")
1117

12-
generator.setFlags("-g ", noChecks=False)
18+
# Apply flags only if the build type is Debug, or if the variable is not set
19+
if build_type == "Debug" or build_type is None:
20+
apply_debug_flags()
21+
info("JIT Python Bindings BUILD_TYPE: Debug")
22+
else:
23+
info("JIT Python Bindings BUILD_TYPE: Release")
1324

1425

1526
def unsetDebugFlags():

python/ikarus/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ dune_add_pybind11_module(NAME _ikarus)
1212

1313
set_property(
1414
TARGET _ikarus
15-
PROPERTY LINK_LIBRARIES dunecommon ikarus _io
15+
PROPERTY LINK_LIBRARIES dunecommon ikarus
1616
APPEND
1717
)
18+
add_dependencies(_ikarus _io)
1819

1920
if(SKBUILD)
2021
install(TARGETS _ikarus LIBRARY DESTINATION python/ikarus)

0 commit comments

Comments
 (0)