Repository navigation
Commit bf9bef3
authored
Look up flatc.exe in executorch.data.bin on Windows (#23992)
This PR was authored with AI assistance (Claude Code); I reviewed every
changed line and take responsibility for it.
### Summary
Fixes #23989
On Windows the wheel packages flatc through `setup.py`'s
`get_executable_name()`, so the binary is
`executorch/data/bin/flatc.exe`. `_get_flatc_path()` in
`exir/_serialize/_flatbuffer.py` asked `executorch.data.bin` for
`flatc`, `is_file()` was `False`, and the lookup fell back to a bare
`flatc` on `PATH`. That resolves only when the environment's `Scripts`
directory is on `PATH` (pip puts the `flatc` console-script shim there).
Called by the interpreter's full path, `to_executorch()` after
`XnnpackPartitioner` raised `FileNotFoundError: [WinError 2]`.
The change asks for `flatc.exe` on `win32` and leaves the other
platforms and the first candidate (`flatbuffers-flatc`, used by the
Buck/PAR build) as they were. This completes #19899, which added the
`executorch.data.bin` candidate with the Linux/macOS spelling only.
All eight modules that run flatc import the same helpers from this file,
so no other call site needs a change; the audit is in #23989.
### Test plan
Added `TestGetFlatcPath` to `exir/_serialize/test/test_flatbuffer.py`.
It fakes an `executorch.data.bin` directory containing only the wheel's
filename and checks that `_get_flatc_path()` returns that file:
`flatc.exe` with `sys.platform` set to `win32`, `flatc` for `linux` and
`darwin`. It patches the module's cache globals so it does not depend on
test order.
```
python -m pytest exir/_serialize/test/test_flatbuffer.py -k GetFlatcPath
python -m pytest backends/xnnpack/test/serialization
```
Both run on the Windows job (`pytest-windows.ini` lists
`exir/_serialize/test` and `backends/xnnpack/test/serialization`).
Measured on Windows 11 x64, Python 3.12.10, a fresh venv with the PyPI
`executorch==1.5.1` win_amd64 wheel and `torch==2.14.0+cpu`,
`FLATC_EXECUTABLE` unset, no flatc on `PATH`, interpreter called by full
path. I did not build the wheel from source: for "after" I replaced
`exir/_serialize/_flatbuffer.py` inside that install with the file from
this branch. The `_get_flatc_path()` block in the 1.5.1 wheel is
identical to `main`, so the "before" is the same code.
```
before after
TestGetFlatcPath (new) 1 failed, 1 passed 2 passed
test_serialize_xnnpack_binary (existing) FileNotFoundError passed
[WinError 2]
exir/_serialize/test + xnnpack serialization,
failing test ids 6 4
minimal Linear, to_edge_transform_and_lower +
XnnpackPartitioner + to_executorch WinError 2 OK, .pte runs and matches eager
```
The failing set after the change is a strict subset of the set before
it: the two that went green are the new test and
`test_serialize_xnnpack_binary`, and nothing new fails. The 4 that
remain (`test_named_data_store` x2, `test_program` x1, `test_ptn` x1,
the last with several failing subtests) fail identically with and
without this change. The first three are assertions about named-data
alignment and segment handling whose fixes (#23517, #23340) landed on
`main` after v1.5.1, so I believe they are `main`'s tests running
against the older 1.5.1 wheel code; I did not run them against a build
from `main`, and I did not trace the `test_ptn` one.
Not covered: I could not run the new test on Linux or macOS (only its
`linux`/`darwin` cases with `sys.platform` patched on Windows), and
nothing was run under Buck. `ufmt` 2.8.0 / `usort` 1.0.8 / `black`
24.4.2 and `flake8` 6.1.0 at the versions in
`requirements-lintrunner.txt` are clean on both files; I did not run the
full `lintrunner` (no `mypy`/`pyre`).
cc @JacobSzwejbka @angelayi @nil-is-all1 parent e57ee9c commit bf9bef3
2 files changed
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
275 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
276 | 282 | | |
277 | 283 | | |
278 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
0 commit comments