[RFC] Canonicalize python file structure
Open
@larryliu0820 is already working on this.
Since Feb 25, 2025.
enhancement
triaged
- Dominant language
- Python
- Stars
- 5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 581
Description
π The feature, motivation and pitch
Blocking #2871
Context
Currently the file structure looks like this:
executorch
βββ backends
...
βββ exir
βββ extension
...
βββ runtime
βββ setup.py
...
βββ version.txt
Problem
- Since we don't have an
executorch/directory, we can't add code intoexecutorchroot module, we will have to do things likeimport executorch.exiretc. In the future we want to dofrom executorch import <top level API> - We want to have a clean separation between python code and C++ code, for easier build system management.
- E.g., we don't want to build python code in GH, so it will be easier to configure the internal repo to not map TARGETS files to GH.
- Editable mode install couldn't find the top level module correctly and thus failed to install.
- This is because when
setuptoolstries to map the module namespace to actual files, it will do the following mapping:'executorch/backens.apple': ['<path to local executorch repo>/executorch/backends/apple'].setuptoolscouldn't define a root levelexecutorchmodule as well because it only lookup folders underexecutorch/. SeeNAMESPACEsection in this generated code, instead we want this code.
- This is because when
Proposal
Move all python code into executorch/ and use that as our root level module. Keep all native source files intact.
executorch
βββ backends
β βββ apple // no python code
β βββ arm
βββ executorch // only python code
β βββ backends
β βββ exir
β βββ extension
...
βββ version.txt
This way we can build a self-contained executorch module which works for editable mode.
Migrations
If we go down this route, we will have to migrate python targets to executorch/ and change internal usage. I don't expect this to affect pip users since they will just do the same from executorch.exir import X.
Alternatives
No response
Additional context
No response
RFC (Optional)
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up β it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.