Parent Issue
#19 - Multi-language runtime support via base images
Depends On
#20 - Multi-layer OCI manifest support for base images
Overview
Enable Python code to run in Fabricks by integrating componentize-py and publishing official Python base images.
Target User Experience
[from]
image = "fabricks.dev/runtimes/python:3.12"
[source]
path = "."
entrypoint = "server.py"
[capabilities.network]
listen = [8080]
User runs fabricks build and gets a working WASM component.
Implementation
1. Python build toolchain integration
When [from].image references a Python runtime:
- Detect Python project (presence of
*.py, requirements.txt, pyproject.toml)
- Install dependencies into a virtual environment
- Use componentize-py to create user code layer
- Compose with base runtime layer
2. Build official Python base images
Create and publish to fabricks.dev registry:
fabricks.dev/runtimes/python:3.11
fabricks.dev/runtimes/python:3.12
fabricks.dev/runtimes/python:3.13
Base image contains:
- CPython interpreter compiled to WASM
- Standard library
- Common dependencies (optional slim variants)
3. WIT interface generation
For Python HTTP services, generate appropriate WIT bindings:
wasi:http/proxy for HTTP services
wasi:cli/command for CLI tools
4. Dependency handling
Support for requirements.txt or pyproject.toml:
[source]
path = "."
entrypoint = "server.py"
requirements = "requirements.txt" # optional, auto-detected
Example Python MCP Server
# server.py
from mcp import Server
app = Server("my-mcp-server")
@app.tool()
def hello(name: str) -> str:
return f"Hello, {name}!"
if __name__ == "__main__":
app.run()
# Fabrickfile
[from]
image = "fabricks.dev/runtimes/python:3.12"
[info]
name = "my-mcp-server"
type = "http"
[source]
entrypoint = "server.py"
[capabilities.network]
listen = [8080]
Files to Create/Modify
fabricks/src/commands/build.rs - Python detection and build flow
fabricks/src/build/python.rs - Python-specific build logic (new)
- New repo or directory for base image builds
New Dependencies
componentize-py (CLI tool, invoked during build)
Acceptance Criteria
Parent Issue
#19 - Multi-language runtime support via base images
Depends On
#20 - Multi-layer OCI manifest support for base images
Overview
Enable Python code to run in Fabricks by integrating componentize-py and publishing official Python base images.
Target User Experience
User runs
fabricks buildand gets a working WASM component.Implementation
1. Python build toolchain integration
When
[from].imagereferences a Python runtime:*.py,requirements.txt,pyproject.toml)2. Build official Python base images
Create and publish to fabricks.dev registry:
fabricks.dev/runtimes/python:3.11fabricks.dev/runtimes/python:3.12fabricks.dev/runtimes/python:3.13Base image contains:
3. WIT interface generation
For Python HTTP services, generate appropriate WIT bindings:
wasi:http/proxyfor HTTP serviceswasi:cli/commandfor CLI tools4. Dependency handling
Support for
requirements.txtorpyproject.toml:Example Python MCP Server
Files to Create/Modify
fabricks/src/commands/build.rs- Python detection and build flowfabricks/src/build/python.rs- Python-specific build logic (new)New Dependencies
componentize-py(CLI tool, invoked during build)Acceptance Criteria
fabricks buildworks for Python projects with[from].imagerequirements.txtdependencies are bundledwasi:http/proxyexamples/directory