whatisgithub

What is terrarium?

haplollc/terrarium — explained in plain English

Analysis updated 2026-05-18

3PythonAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A Swift package that runs a real embedded Python 3.13 interpreter in iOS and macOS apps, with on-device pip install and a WebAssembly fallback for scientific packages.

Mindmap

mindmap
  root((repo))
    What it does
      Embeds CPython 3.13
      Runs Python on device
      pip install magic
    Tech stack
      Swift
      SwiftUI
      Pyodide WASM
    Use cases
      Run Python scripts in app
      Chart data with matplotlib
      Call web APIs from Python
    Audience
      iOS developers
      macOS developers
    Setup
      SwiftPM package
      No manual Xcode setup
    Notes
      Persistent packages
      Native and WASM runtimes

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add an in-app Python console to an iOS or macOS app.

USE CASE 2

Run scientific Python code like matplotlib and pandas on device.

USE CASE 3

Let an app fetch live data from an API and chart it with Python.

USE CASE 4

Build a teaching or scripting tool that runs user-written Python.

What is it built with?

SwiftSwiftUIPythonPyodideSwiftPM

How does it compare?

haplollc/terrarium0marildo/imagoagentlexi/agent-lexi
Stars333
LanguagePythonPythonPython
Setup difficultymoderateeasymoderate
Complexity3/52/54/5
Audiencedevelopergeneralvibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Scientific packages route through a WASM runtime that is roughly twice as slow as native.

The README does not state license terms.

So what is it?

Terrarium is a Swift package that embeds a real Python 3.13 interpreter inside iOS and macOS apps, so developers can run Python code directly on device without a server or a subprocess. It bundles CPython through a Python.xcframework, which means pure Python scripts run natively and fast, with no transpiling step involved. The standout feature is inline package installation. A script can start with a line like percent pip install requests, and Terrarium resolves that package from PyPI, downloads a wheel, and stores it in a writable folder so it survives the next app launch. For packages with C extensions that Apple platforms cannot easily support, such as matplotlib, numpy, pandas, scipy, and scikit-learn, Terrarium automatically switches to a hidden WKWebView running Pyodide, a version of CPython compiled to WebAssembly with roughly 250 prebuilt scientific packages available. The package includes a SwiftUI runner sheet with run, stop, and clear controls, plus proper cancellation support. It shows live byte level progress bars while packages download, supports colored terminal output through libraries like rich and colorama, and automatically displays matplotlib charts in a view tab without needing plt.show(). Network requests work out of the box through the requests library, using Python's built in SSL support for HTTPS. There is also a package manager interface where a user can search installed packages, see their storage size, and delete them individually. A developer can force which runtime handles a script with a magic comment, choosing either the native CPython path or the Pyodide WASM path, and can list installed packages with a pip style command showing whether each one is bundled, user installed, or running through Pyodide. Installing from a requirements.txt file is also supported using the standard pip flag. The whole thing ships as a self contained SwiftPM package, with all its resources bundled so there is no manual Xcode folder setup required. In short, it gives an iOS or macOS app the ability to run and extend real Python code, including much of the scientific Python stack, entirely on the user's device.

Copy-paste prompts

Prompt 1
Help me add Terrarium to my iOS app and run a hello world Python script.
Prompt 2
Show me how to use %pip install in Terrarium to install requests and call an API.
Prompt 3
Explain how Terrarium decides whether to run a package on CPython or Pyodide.
Prompt 4
Write a Terrarium script that fetches live data and renders a matplotlib chart.

Frequently asked questions

What is terrarium?

A Swift package that runs a real embedded Python 3.13 interpreter in iOS and macOS apps, with on-device pip install and a WebAssembly fallback for scientific packages.

What language is terrarium written in?

Mainly Python. The stack also includes Swift, SwiftUI, Python.

What license does terrarium use?

The README does not state license terms.

How hard is terrarium to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is terrarium for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.