You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A short term fix for editable mode install failed to import root level module such as exir (#9818)
Summary:
Fixes#9558.
The `src/executorch/exir` file exists primarily due to the limitations
of `pip install` in editable mode. Specifically, `pip install -e .` does
not recognize `<executorch root>/exir` (or any root level directory with
a `__init__.py`) as a valid package module because of the presence of
`<executorch root>/exir/__init__.py`. See the following GitHub issue for
details: [Issue
#9558](#9558).
To work around this limitation, a symlink is used. With this symlink and
this package entry in `pyproject.toml`:
```toml
[tool.setuptools.package-dir]
# ...
"executorch" = "src/executorch"
```
We are telling `pip install -e .` to treat `src/executorch` as the root
of the `executorch` package and hence mapping `executorch.exir` to
`src/executorch/exir`. This effectively gets `exir` out from the root
level package.
This allows us to perform `pip install -e .` successfully and enables
the execution of the following command:
```bash
python -c "from executorch.exir import CaptureConfig"
```
Test Plan:
```bash
./install_executorch.sh --pybind --editable
python -c "from executorch.exir import CaptureConfig"
```
Reviewers:
Subscribers:
Tasks:
Tags:
The `src/executorch/*` files exist primarily due to the limitations of `pip install` in editable mode. Specifically, `pip install -e .` does not recognize `<executorch root>/exir` (or any root level directory with a `__init__.py`) as a valid package module because of the presence of `<executorch root>/exir/__init__.py`. See the following GitHub issue for details: [Issue #9558](https://github.com/pytorch/executorch/issues/9558).
4
+
5
+
## The Symlink Solution
6
+
7
+
To work around this limitation, a symlink is used. With this symlink and this package entry in `pyproject.toml`:
8
+
9
+
```toml
10
+
[tool.setuptools.package-dir]
11
+
# ...
12
+
"executorch" = "src/executorch"
13
+
```
14
+
We are telling `pip install -e .` to treat `src/executorch` as the root of the `executorch` package and hence mapping `executorch.*.*` to `src/executorch/*/*`. This effectively gets modules like `exir` out from the root level package.
15
+
16
+
This allows us to perform `pip install -e .` successfully and enables the execution of the following command:
We should start to move directories from <executorchroot>/ to <executorchroot>/src/ and remove the symlinks. Issue [#8699](https://github.com/pytorch/executorch/issues/8699) to track this effort. This will require a lot of work internally.
25
+
26
+
TODO(mnachin T180504136): Do not put examples/models into core pip packages. Refactor out the necessary utils or core models files into a separate package.
0 commit comments