FerryDocs

Python

Ferry builds a Python app from requirements.txt, pyproject.toml or Pipfile.

Edit on GitHub

Detect. Ferry finds requirements.txt, pyproject.toml or Pipfile.

1 / 5

A minimal example

app.py
requirements.txt
Procfile
requirements.txt
flask==3.1.*
gunicorn==23.*
app.py
from flask import Flask

app = Flask(__name__)


@app.get("/")
def hello():
    return "Hello from Python on Ferry\n"
Procfile
web: gunicorn app:app --bind 0.0.0.0:$PORT
Terminal
ferry up hello-python --follow

The line runs with sh -c. Thus the replaces $PORT with the value. For FastAPI, use web: uvicorn main:app --host 0.0.0.0 --port $PORT.

What Ferry generates

StepWhat Ferry generates
python:<version>-slim. The default is 3.12. Ferry uses the major.minor of .python-version or runtime.txt (python-3.11.9), if there is one. Ferry sets PYTHONUNBUFFERED=1. Thus the logs show immediately.
BuildYour build command, if you set one. Example: python manage.py collectstatic --noinput.
Startpython main.py or python app.py, when the file exists. All other servers (Gunicorn, Uvicorn, Django) need a Procfile entry or --start-cmd.

The install command

Ferry findsInstall
requirements.txtpip install -r requirements.txt
uv.lockthe locked dependencies, with uv
poetry.lock or [tool.poetry]poetry install --only main
a packaged pyproject.tomlpip install .
a plain PEP 621 pyproject.tomlits [project] dependencies
Pipfilepipenv install --system --deploy (--skip-lock with no Pipfile.lock)

System packages

Ferry adds system packages when your need them. The -binary variants need nothing.

DependencyPackages
psycopg2 or psycopg[c]build-essential libpq-dev
psycopglibpq5
mysqlclientbuild-essential default-libmysqlclient-dev pkg-config

On this page