Skip to content

Latest commit

 

History

History
160 lines (129 loc) · 9.92 KB

File metadata and controls

160 lines (129 loc) · 9.92 KB

python-ios-lib

Full Python 3.14 runtime for iOS/iPadOS with 30+ offline libraries. Everything runs locally on-device — no internet, no server, no JIT. App Store safe.


Languages

Language Runtime Notes
Python 3.14 BeeWare embedded CPython Native C extensions (.so → .fwork)
C Tree-walking interpreter (3,450 lines) 48 operators, structs, pointers, preprocessor
C++ Tree-walking interpreter (4,200 lines) Classes, STL, templates, inheritance
Fortran Tree-walking interpreter (4,100 lines) Modules, allocatable arrays, intrinsics

All four share the same Monaco-based code editor (WKWebView) with IntelliSense (keyword snippets, signature help, hover docs, resolve-from-Python completions for numpy / scipy / sklearn / matplotlib / sympy) and debounced auto-save (flushes to disk ~600 ms after the last keystroke, plus on run / tab-switch / view-disappear / app-backgrounding).


Python Libraries

Scientific Computing

Library Version Type Description
NumPy 2.3.5 Native iOS N-dimensional arrays, linear algebra, FFT, random
SciPy 1.15.0 Native iOS Optimization, interpolation, integration, signal, stats, spatial
SymPy 1.14.0 Pure Python Symbolic math: algebra, calculus, solving, matrices
mpmath 1.4.1 Pure Python Arbitrary-precision arithmetic, special functions

Machine Learning

Library Version Type Description
PyTorch 2.1.0 (patched) Native iOS (arm64) Full import torch — tensors, autograd, nn, optim, JIT, FFT, distributions. 95/95 correctness asserts. Apple Accelerate for linalg
transformers 4.41.2 Pure Python HuggingFace models: BERT, GPT-2, T5, BART, etc. Construct from config, train, generate, save/load — all on-device
tokenizers 0.19.1 Native iOS (Rust) First public iOS build. Real Rust BPE/WordPiece/Unigram trainers. PyO3 bindings, full speed
scikit-learn Pure NumPy (12K+ lines, 40 modules) Classification, regression, clustering, preprocessing, model selection, 38 metrics

Visualization

Library Version Type Description
matplotlib 3.9.0 Plotly shim (64 modules) Drop-in pyplot → interactive Plotly HTML
Plotly 6.6.0 Pure Python Interactive charts, 3D plots, maps
manim 0.20.1 Modified for iOS 145+ mobjects, 73 animations, 40+ rate functions, H.264 video

Media & Rendering

Library Type Description
PyAV Native iOS (17 C extensions) FFmpeg bindings: encode/decode video and audio
FFmpeg Native iOS (7 dylibs, 21 MB) H.264/HEVC hardware encoding, 50+ codecs, 30+ formats
Cairo (pycairo) Native iOS (2.8 MB) 2D vector graphics: SVG, PDF, PNG, patterns, text paths
Pillow 12.2.0, Native iOS Image processing: resize, crop, filter, draw, 15 formats
ManimPango Cairo-based fallback Text → SVG vector outlines (11 font weights)
CairoSVG Pure Python + cairocffi SVG → PNG/PDF/PS. Works in CodeBench; needs manual libcairo.dylib + find_library shim in other apps — see cairosvg.md
Local LaTeX (offlinai_latex module) SwiftMath + 33 MB texmf Math-mode LaTeX via SwiftMath (unlimited). \documentclass-level pdflatex gated off — bundled lib-tex v1.40.20 crashes; see LaTeX docs

Data & Web

Library Version Type Description
requests Pure Python HTTP client: GET, POST, sessions, auth, JSON
BeautifulSoup4 4.14.3 Pure Python HTML/XML parsing and scraping
NetworkX 3.6.1 Pure Python Graph theory: 200+ algorithms, generators
jsonschema 4.26.0 Pure Python JSON Schema validation (Draft 7)
PyYAML 6.0.3 Native YAML parsing and serialization

Web frameworks (run dashboards on-device)

All five are bundled with iOS-specific patches so Ctrl+C / Stop works, debug mode doesn't crash on missing _multiprocessing, and the preview panel auto-loads the running server URL. Click any library name for its detailed module list. See web-stack.md for the cross-library iOS patches and feature tests.

Library Version Modules Description
Werkzeug 3.1.x 52 WSGI utilities + dev server. Patched: multiprocessing.Value fallback, reloader auto-disable, preview hook, clean shutdown
Flask 3.x 24 Web framework on Werkzeug — routes, sessions, templates, blueprints, signals, CLI
Dash 3.x 211 Plotly-based dashboards — reactive callbacks, dcc/html/dash_table, pattern-matching callbacks
Streamlit 1.50.x 213 Script-style dashboards — declarative widgets, @st.cache_data, sessions, fragments
Tornado 6.5.x 73 Async HTTP/WebSocket framework — Streamlit's transport, usable standalone

Utilities

Library Description
rich Rich text, tables, progress bars, syntax highlighting
tqdm Progress bars for loops and iterables
Pygments Source code syntax highlighting (500+ languages)
click CLI framework with decorators
pydub Audio manipulation (slice, concatenate, effects)
packaging Version parsing and comparison (PEP 440)
srt Subtitle file parsing and generation
watchdog Filesystem event monitoring
svgelements SVG parsing and manipulation
cffi C Foreign Function Interface

Detailed Documentation

Machine Learning

  • PyTorch — Full import torch on iPad. 95/95 numerical + training asserts
  • transformers — HuggingFace models: BERT, GPT-2, train + generate on-device
  • tokenizers — First public iOS build of HuggingFace's Rust tokenizers
  • scikit-learn — 40 modules, 85%+ of common ML workflows

Scientific

  • NumPy — Arrays, linear algebra, FFT, random
  • SciPy — 18+ submodules: optimize, integrate, signal, stats, ...
  • SymPy — Computer algebra system

Visualization & Media

Interpreters


Architecture

┌─────────────────────────────────────────────────┐
│                   iPad App                       │
├──────────┬──────────┬──────────┬────────────────┤
│  Editor  │  Files   │   Docs   │   AI Chat      │
│  (code)  │ (browse) │  (ref)   │  (LLM assist)  │
├──────────┴──────────┴──────────┴────────────────┤
│              Python 3.14 Runtime                 │
│  ┌─────────┬───────────┬─────────────┐          │
│  │ PyTorch │transformers│ tokenizers  │  ← ML    │
│  │ 2.1 iOS │   4.41     │ 0.19 (Rust) │          │
│  └─────────┴───────────┴─────────────┘          │
│  ┌────────┬────────┬────────┬────────┐          │
│  │ NumPy  │ SciPy  │ manim  │sklearn │   ...    │
│  └────────┴────────┴────────┴────────┘          │
├─────────────────────────────────────────────────┤
│  Native Frameworks (arm64)                       │
│  ┌──────────┬────────┬────────┬────────┐        │
│  │ libtorch │ FFmpeg │ Cairo  │pdftex  │        │
│  │ (185 MB) │(7 libs)│        │        │        │
│  └──────────┴────────┴────────┴────────┘        │
│  ┌─────────────────────┬──────────────┐         │
│  │ Apple Accelerate    │ Pillow       │         │
│  │ (BLAS/LAPACK/FFT)   │              │         │
│  └─────────────────────┴──────────────┘         │
├──────────┬──────────┬───────────────────────────┤
│ C interp │ C++ int  │ Fortran interpreter       │
│ (Swift)  │ (Swift)  │ (Swift)                   │
├──────────┴──────────┴───────────────────────────┤
│           llama.cpp (local LLM inference)        │
│           Qwen3.5 / Gemma 4 (GGUF)             │
└─────────────────────────────────────────────────┘