build: Make sympy an optional dependency (#27200)
Move sympy from required to optional dependencies. Users doing
inference-only don't need
symbolic math library.
- Guard sympy import in symbolic_shape_infer.py with helpful error
message
- Remove sympy from requirements.txt
- Add sympy to extras_require["symbolic"] in setup.py
Users can now install with: `pip install onnxruntime[symbolic]`
Reduces default install size by ~29MB (23%).
Addresses #24872
### Description
Make sympy an optional dependency to reduce install size for
inference-only users.
Changes:
- Guard sympy import in symbolic_shape_infer.py with helpful ImportError
- Remove sympy from requirements.txt (no longer auto-installed)
- Add sympy to extras_require["symbolic"] in setup.py
### Motivation and Context
sympy is ~29MB (23% of total package size) but only used for symbolic
shape inference.
Most users doing inference-only don't need it.
After this change:
- `pip install onnxruntime` → no sympy (smaller install)
- `pip install onnxruntime[symbolic]` → includes sympy
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>