Skip to content

Commit bd3e990

Browse files
leofangclaude
andcommitted
Fix numpy pyproject.toml patch to preserve [tool.meson-python]
The previous regex stripped everything from [tool.cibuildwheel] to EOF, which also removed [tool.meson-python] with its vendored meson path. Use a line-by-line approach to only remove cibuildwheel sections. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent b808899 commit bd3e990

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎.github/workflows/build-wheel.yml‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,23 @@ jobs:
264264
cd numpy-sdist && tar xf numpy-*.tar.gz && rm numpy-*.tar.gz
265265
# WAR: numpy 2.4.x ships [tool.cibuildwheel] config that is
266266
# incompatible with cibuildwheel v4.0 (cpython-freethreading enable
267-
# group, OpenBLAS before-build scripts, etc.). Strip the entire
268-
# section — we only need a basic numpy wheel for testing.
267+
# group, OpenBLAS before-build scripts, etc.). Strip the cibuildwheel
268+
# sections but preserve [tool.meson-python] (vendored meson path).
269269
python -c "
270-
import glob, re
270+
import glob
271271
for f in glob.glob('numpy-*/pyproject.toml'):
272-
txt = open(f).read()
273-
txt = re.sub(r'\n\[tool\.cibuildwheel\].*', '', txt, flags=re.DOTALL)
274-
open(f, 'w').write(txt)
272+
lines, skip = open(f).readlines(), False
273+
out = []
274+
for line in lines:
275+
hdr = line.strip()
276+
if hdr.startswith('[tool.cibuildwheel') or hdr.startswith('[[tool.cibuildwheel'):
277+
skip = True
278+
continue
279+
if skip and hdr.startswith('[') and 'cibuildwheel' not in hdr:
280+
skip = False
281+
if not skip:
282+
out.append(line)
283+
open(f, 'w').writelines(out)
275284
"
276285
echo "NUMPY_SRC_DIR=$(pwd)/$(ls -d numpy-*/)" >> $GITHUB_ENV
277286

0 commit comments

Comments
 (0)