Python
Building a Python App
Expected structure
daedalus detects a Python app by the presence of an entry point at the root:
app.py, main.py, server.py or __main__.py.
my_app/
app.py ← entry point, auto-detected
... ← other modules, templates, assets
Build
daedalus build ./my_app -o my_app.de
The builder:
- detects the
pythonruntime and entrypoint (/app/app.py); - embeds the build machine's
python3interpreter; - embeds the stdlib (
/usr/lib/pythonX.Y); - resolves
.sodependencies via the ELF analyzer (libc, etc.); - compresses and assembles the
.de.
Environment variables
The builder injects PYTHONUNBUFFERED=1 (real-time logs) and
PYTHONDONTWRITEBYTECODE=1 by default. Your app reads its own variables normally:
import os
PORT = int(os.environ.get("PORT", "8080"))
PORT=9000 ./my_app.de
Third-party dependencies (site-packages)
daedalus automatically embeds third-party dependencies. It looks, in order:
- a virtualenv
.venv/orvenv/at the app root → itslib/pythonX.Y/site-packages; - a vendored
site-packages/directory at the app root.
my_app/
app.py
.venv/ ← auto-detected, site-packages embedded
lib/python3.12/site-packages/
bottle.py
The builder:
- copies site-packages to
/app/site-packagesin the rootfs; - declares
PYTHONPATH=${ROOTFS}/app/site-packages(the${ROOTFS}token is resolved by the launcher at runtime — see Launcher); - runs the ELF analyzer on
.sofiles from C extensions (numpy, pillow...) to embed their system dependencies.
The example examples/bottle-web demonstrates this: it serves HTTP with
bottle, a web framework not in the stdlib.
daedalus build ./examples/bottle-web -o bottle-web.de
./bottle-web.de # → Hello from bottle, packaged by daedalus
Requirements.txt → pip install at build time
If your app has a requirements.txt with non-empty content, the builder
automatically creates a temporary venv, pip-installs the dependencies, and
embeds them:
daedalus build ./my_app -o my_app.de
# [daedalus] pip install: ./my_app/requirements.txt → /app/site-packages
Current limitations
- Cross-distro portability: see Isolation — fully guaranteed at level 2 (user namespaces + pivot_root).