Commit 6aefbd1
committed
[mypyc] Fix separate=True: cached-SCC second pass returns empty Extensions
When mypycify is called twice in the same source tree (typical of pip's
wheel build, which runs setup.py for "Preparing metadata" and then
again for "Building wheel"), the second call hits the mypy metadata
cache and ends up with every state's `tree` still None. The SCC loop
in compile_modules_to_ir then sees `trees == []` for every SCC and
silently skips them, so compile_modules_to_ir returns an empty
`modules` dict.
Downstream, compile_ir_to_c sets `ctext[group_name] = []` for every
group, mypyc_build's loop produces empty cfilenames, and the resulting
Extensions ship with `sources=[]`. setuptools then runs the linker
with no input and produces a stub .so, so the installed module is
missing PyInit_<name>__mypyc and explodes on import.
Fix: when ctext is empty for a group but the .c file from the previous
mypycify pass is still on disk (which it always is for a fully-cached
build), reuse it. The path mirrors the one that
GroupGenerator.generate_c_for_modules emits.
Reproducer: `pip wheel ./sqlglotc` from sqlglot's repo with
separate=True; first build succeeds, second build (or pip's two-phase
metadata-then-wheel flow on a fresh checkout) yields a wheel with all
shared libs missing PyInit_*.1 parent 812a3c8 commit 6aefbd1
1 file changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
| 567 | + | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
576 | 593 | | |
577 | 594 | | |
578 | 595 | | |
| |||
0 commit comments