Skip to content

Python runtime support via componentize-py #21

@richardkiene

Description

@richardkiene

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:

  1. Detect Python project (presence of *.py, requirements.txt, pyproject.toml)
  2. Install dependencies into a virtual environment
  3. Use componentize-py to create user code layer
  4. 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

  • fabricks build works for Python projects with [from].image
  • Python base images published to fabricks.dev
  • requirements.txt dependencies are bundled
  • HTTP services work with wasi:http/proxy
  • Example Python service in examples/ directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions