Seamlessly integrate the unmatched computational power of Python's elite ecosystem—like PyTorch, SciPy, pandas, and NumPy—directly within your TypeScript applications, fully protected by a robust type system.
Copy this into your coding agent to get started in one shot:
View full documentation →TypeScript definitions generated directly from Python source analysis via AST — no manual type writing.
One API across Node.js, Bun, Deno (subprocess), and browsers (Pyodide WebAssembly).
First-class support for numpy, pandas, scipy, torch, and sklearn with Apache Arrow binary transport.
Run npx tywrap generate and get production-ready TypeScript wrappers with a single command.
npm install tywrap
pip install tywrap-ir # Python component for code generation
npx tywrap init
npx tywrap generatetywrap and tywrap-ir are versioned independently. Install the latest published release of each package unless you need to pin them explicitly.
import { NodeBridge } from 'tywrap/node';
import { setRuntimeBridge } from 'tywrap/runtime';
import * as math from './generated/math.generated.js';
setRuntimeBridge(new NodeBridge({ pythonPath: 'python3' }));
const result = await math.sqrt(16); // 4 — fully typedimport { startNodeWatchSession } from 'tywrap/dev';
import { NodeBridge } from 'tywrap/node';
const session = await startNodeWatchSession({
configFile: './tywrap.config.ts',
createBridge: async config =>
new NodeBridge({
pythonPath: config.runtime.node?.pythonPath ?? 'python3',
timeoutMs: config.runtime.node?.timeout ?? 30000,
}),
});Use reloadNow() for an explicit rebuild or close() to stop watching. Node gets full hot reload, Pyodide gets manual bridge replacement through createBridgeReloader(...), and HTTP reload remains external to tywrap.
⚠️ Experimental — APIs may change before v1.0.0. See Releases for breaking changes.
If tywrap saves you time, a ⭐ on GitHub helps others find it.