Skip to content

Commit 2949099

Browse files
committed
Adapt to mpi4py build issue with Cython 3.1 and gcc<=12
1 parent a9e4893 commit 2949099

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

noxfile.py

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@nox.session
1414
def validate_code(session):
15-
session.run_always(
15+
session.run_install(
1616
"pdm", "sync", "--clean", "-G", "dev", "--no-self", external=True
1717
)
1818
session.run("pdm", "validate_code", external=True)
@@ -78,8 +78,12 @@ def _test(session, env=None, with_fft=True):
7878
@nox.session
7979
def test_without_fft_and_pythran(session):
8080
command = "pdm sync --clean -G dev -G test -G mpi --no-self"
81-
session.run_always(*command.split(), external=True)
82-
session.install(".", "-C", "setup-args=-Dtransonic-backend=python", "--no-deps")
81+
session.run_install(
82+
*command.split(), external=True, env=_get_modified_env(session)
83+
)
84+
session.install(
85+
".", "-C", "setup-args=-Dtransonic-backend=python", "--no-deps"
86+
)
8387

8488
_test(
8589
session,
@@ -95,17 +99,39 @@ def __init__(self):
9599
def __call__(self, task: str):
96100
time_now = time()
97101
if self.time_start != self.time_last:
98-
print(f"Time for {task}: {timedelta(seconds=time_now - self.time_last)}")
99-
print(f"Session started since {timedelta(seconds=time_now - self.time_start)}")
102+
print(
103+
f"Time for {task}: {timedelta(seconds=time_now - self.time_last)}"
104+
)
105+
print(
106+
f"Session started since {timedelta(seconds=time_now - self.time_start)}"
107+
)
100108
self.time_last = time_now
101109

102110

111+
def _get_modified_env(session):
112+
"""return a modified environment without -g in CFLAGS
113+
114+
see https://github.com/mpi4py/mpi4py/issues/652#issuecomment-2936030256
115+
"""
116+
out = session.run_install(
117+
"python3",
118+
"-c",
119+
"from sysconfig import get_config_var as g; print(g('CFLAGS'))",
120+
silent=True,
121+
)
122+
cflags = " ".join(flag for flag in out.split() if flag != "-g")
123+
env = os.environ.copy()
124+
env["CFLAGS"] = cflags
125+
126+
103127
@nox.session
104128
def test_with_fft_and_pythran(session):
105129
print_times = TimePrinter()
106130

107131
command = "pdm sync --clean -G dev -G test -G fft -G mpi --no-self"
108-
session.run_always(*command.split(), external=True)
132+
session.run_install(
133+
*command.split(), external=True, env=_get_modified_env(session)
134+
)
109135

110136
print_times("pdm sync")
111137

@@ -132,7 +158,9 @@ def test_examples(session):
132158
"""Execute the examples using pytest"""
133159

134160
command = "pdm sync --clean -G test -G mpi -G fft -G dev --no-self"
135-
session.run_always(*command.split(), external=True)
161+
session.run_install(
162+
*command.split(), external=True, env=_get_modified_env(session)
163+
)
136164

137165
command = "."
138166
if "GITLAB_CI" in os.environ:
@@ -150,10 +178,12 @@ def doc(session):
150178
"""Build the documentation"""
151179
print_times = TimePrinter()
152180
command = "pdm sync -G doc -G fft -G test -G dev --no-self"
153-
session.run_always(*command.split(), external=True)
181+
session.run_install(*command.split(), external=True)
154182
print_times("pdm sync")
155183

156-
session.install(".", "-C", "setup-args=-Dtransonic-backend=python", "--no-deps")
184+
session.install(
185+
".", "-C", "setup-args=-Dtransonic-backend=python", "--no-deps"
186+
)
157187
print_times("install self")
158188

159189
session.chdir("doc")
@@ -188,7 +218,9 @@ def _get_version_from_pyproject(path=Path.cwd()):
188218
def add_tag_for_release(session):
189219
session.run("hg", "pull", external=True)
190220

191-
result = session.run(*"hg log -r default -G".split(), external=True, silent=True)
221+
result = session.run(
222+
*"hg log -r default -G".split(), external=True, silent=True
223+
)
192224
if result[0] != "@":
193225
session.run("hg", "update", "default", external=True)
194226

0 commit comments

Comments
 (0)