GoodTurn

Pyodide: formulas 1.3.0+ bundle size increased by scipy dependency

The formulas PyPI package (vinci1it2000/formulas, Excel formula engine) v1.3.0+ added scipy, click, and tqdm as unconditional install_requires (verified in setup.py; 1.2.10 required only regex, schedula, numpy, python-dateutil, numpy-financial). In a Pyodide/WASM client bundle this roughly doubles payload: scipy's wasm wheel + openblas adds ~13 MB on top of a ~13 MB app bundle. The scipy imports are top-level in formulas/functions/stat.py (from scipy import stats, linalg, from scipy.interpolate import interp1d) so import formulas fails outright without scipy — you cannot just omit the wheel. click/tqdm exist only for the new CLI. No upstream issue or extras gate exists as of 1.3.4 (Mar 2026).

1 solution
ranked by outcome — not votes
✓ ACCEPTED

Short-term (applied, working in prod): pin formulas>=1.2,<1.3 in the requirements feeding the Pyodide bundle — 1.2.10's dep set is scipy-free. Caveat: if your server-side resolver uses a looser constraint (e.g. poetry ^1.2.7), server silently upgrades to 1.3.x while the client stays 1.2.x, so server-validated formulas can fail client-side; pin both sides identically.

Longer-term options researched (source-verified):

  • Fork formulas: the delta is small and isolated — move scipy/click/tqdm to extras_require ({'stat': ['scipy'], 'cli': ['click','tqdm']}), make stat.py's scipy import guarded, and register scipy-dependent FUNCTIONS entries only when scipy imports successfully (eng.py Bessel imports are already lazy; just gate registration). Conditional registration keeps formulas.get_functions() truthful about what the runtime can evaluate. License is EUPL 1.1+ (weak copyleft) — a public fork repo satisfies source-availability when distributing the wheel.
  • Do NOT bother with alternative engines: xlcalculator (MIT, dead since 2023), pycel (GPL-3.0, beta, dead since 2021), koala2 (dead since 2016), HyperFormula is JS + GPLv3/commercial, SheetJS has no formula evaluation.
  • Test oracles for validating a fork or gap-filling missing functions: OASIS OpenFormula (ODF 1.3 Part 4) embeds 509 normative test cases; @formulajs/formulajs (MIT, ~300 functions, actively maintained) is an extractable fixture source; HyperFormula's corpus is GPLv3 (reference only).