Skip to content

Look up flatc.exe in executorch.data.bin on Windows - #23992

Open
ErenAta16 wants to merge 1 commit into
pytorch:mainfrom
ErenAta16:fix-windows-flatc-lookup
Open

ErenAta16 wants to merge 1 commit into
pytorch:mainfrom
ErenAta16:fix-windows-flatc-lookup

Conversation

@ErenAta16

@ErenAta16 ErenAta16 commented Oct 19, 2026 •

Copy link
Copy Markdown

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 @nil-is-all

The wheel installs flatc through setup.py's get_executable_name(), so on
Windows the file is executorch/data/bin/flatc.exe. _get_flatc_path() asked
for "flatc", is_file() was False, and the lookup fell through to the bare
name on PATH. That only resolves when the environment's Scripts directory is
on PATH, where the flatc console-script shim lives. Without it, anything that
serializes through flatc, such as to_executorch() after XnnpackPartitioner,
raised FileNotFoundError: [WinError 2].

Use the suffixed name on win32 and add a test for both platform spellings.
@pytorch-bot

pytorch-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23992

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 1 Awaiting Approval

As of commit 09a34c5 with merge base adc713a (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 19, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ErenAta16 / name: ErenAta16 (09a34c5)

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. community: contribution PRs coming from community (excluding hardware partners)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: _get_flatc_path() looks for data/bin/flatc but the wheel ships flatc.exe (WinError 2)

1 participant