Python Buildpack on App Platform

App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.


How App Platform Builds Images

App Platform supports two ways to build an image for your app: Cloud Native Buildpacks and Dockerfiles.

When you give App Platform access to your code, it defaults to using a Dockerfile if one is present in the root of the directory or specified in the app spec. Otherwise, App Platform checks your code to determine what language or framework it uses. If it supports the language or framework, it chooses an appropriate resource type and uses the proper buildpack to build the app and deploy a container.

heroku-buildpack-python is utilized as the buildpack for detecting and building your Python applications.

Python Applications using Buildpacks

App Platform looks for any of the following to detect a Python application:

  • requirements.txt
  • Pipfile
  • setup.py

Current Buildpack Version and Supported Runtimes

App Platform uses version 242 of the Heroku Python Buildpack. If no version is specified in your app, App Platform defaults to using version 3.12.1.

The Python buildpack versions that are available are v4, v3, v2, v1, and v0. It should be noted that Python v4 and v3 do not support Ubuntu-18. If you’d like to start using Python v4 or v3, we recommend upgrading your buildpack to Ubuntu-22 before upgrading to newer Python buildpack versions. To see specific runtimes that are available for these versions, please look at our release notes.

The buildpack supports the following Python runtime versions:

  • Ubuntu-22
    • 3.9.12 - 3.9.18
    • 3.10.4 - 3.10.13
    • 3.11.0 - 3.11.7
    • 3.12.0 - 3.12.1
  • Ubuntu-18
    • 2.7.15 - 2.7.18
    • 3.4.9 - 3.4.10
    • 3.5.6 - 3.5.7
    • 3.5.9 - 3.5.10
    • 3.6.0 - 3.6.15
    • 3.7.0 - 3.7.16
    • 3.8.0 - 3.8.16
    • 3.9.0 - 3.9.16
    • 3.10.0 - 3.10.12
    • 3.11.0 - 3.11.5

Specify a Python Version

You can configure the python version used at runtime by specifying a runtime.txt file at the root of your source code:

    
        
            
python-3.10.4

        
    

Limits

  • At least one of requirements.txt, Pipfile, and setup.py must be located in the root directory of the repo.
  • A run command is required. If one is not auto-detected, you must set one before deploying your app.
  • Due to an issue with Gunicorn running in Docker, App Platform fails to run when the temporary directory is not specified in the run command. To resolve, run Gunicorn to use a different location for its temp files. Modify the run command by passing this option: gunicorn --worker-tmp-dir /dev/shm project.wsgi, where project is the name of your project.