Repository navigation
Commit ff09af0
authored
Stop installing test-only packages with the executorch package (pytorch#24143)
### Summary
`pip install executorch` installs four packages that are only there for
ExecuTorch's own tests: `expecttest`, `hypothesis`, `kgb` and
`parameterized`. `hypothesis` also brings `sortedcontainers`. So every
user installs five packages they never need.
This moves the four from the package's runtime dependencies
(`_base_dependencies()` in `setup.py`) to `requirements-dev.txt`. The
developer setup and every CI job that runs tests already install that
file, so tests still get them.
Nothing a user imports needs them. Three shipped files do, but only
tests or a code generator use them:
`backends/cadence/aot/typing_stubs.py`,
`examples/models/llama/source_transformation/test_attention_sink.py`,
and `exir/dialects/edge/spec/gen.py`.
Effect, resolving the declared dependencies for Python 3.12 (without
`torch`): 55 packages before, 50 after on macOS arm64 and Linux x86_64.
The same five go away on Linux aarch64 and Windows.
Kept on purpose: `coremltools` and `scikit-learn` (the Core ML backend
needs both), and `hydra-core`, `omegaconf`, `pandas`, `tabulate` and
`pytorch-tokenizers`, which shipped modules import.
The first commit fixes the wheel's clean-install check. It hid
undeclared packages so that `importlib.util.find_spec` raised instead of
returning `None`. `torch._dynamo` probes for `hypothesis` with
`find_spec` when it loads, so the check failed once `hypothesis` was no
longer declared, although a real install works.
### Test plan
On macOS arm64, in a fresh environment with only the trimmed
dependencies, `torch` 2.14.0 and a nightly `executorch` installed with
`--no-deps`:
- Tried to import all ~3,000 modules in the package. Only the three
files above failed for lack of a removed package. The rest imported, or
stopped on unrelated optional packages such as vendor SDKs.
- Exported a small model with XNNPACK and with Core ML, ran both, and
matched eager PyTorch.
- The clean-install check fails before the first commit and passes after
it, and still fails when a checked module imports an undeclared package.
Tests that use the moved packages pass with `requirements-dev.txt`
installed.1 parent 9944b02 commit ff09af0
3 files changed
Lines changed: 25 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | | - | |
| 218 | + | |
| 219 | + | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
245 | 249 | | |
246 | 250 | | |
247 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1154 | 1154 | | |
1155 | 1155 | | |
1156 | 1156 | | |
1157 | | - | |
1158 | 1157 | | |
1159 | | - | |
1160 | | - | |
1161 | 1158 | | |
1162 | 1159 | | |
1163 | 1160 | | |
1164 | 1161 | | |
1165 | | - | |
1166 | 1162 | | |
1167 | 1163 | | |
1168 | 1164 | | |
| |||
0 commit comments