Python

The Python language is officially supported on the platform.

Detection

To ensure our deployment system considers your application as a Python application, a file Pipfile, requirements.txt or setup.py should be present at the root of your project, defining the dependencies of your app.

Python Versions

Availability

The following versions of Python are available:

Python Version scalingo-20 scalingo-22
3.13 up to 3.13.1 up to 3.13.1
3.12 up to 3.12.8 up to 3.12.8
3.11 up to 3.11.11 up to 3.11.11
3.10 up to 3.10.16 up to 3.10.16

Selecting a Version

The default Python version on both scalingo-20 and scalingo-22 is the latest 3.13 version. You can, however, instruct the platform to use another version.

The buildpack looks for a Python version in the following places (in descending order of precedence):

  • The runtime.txt file (deprecated)
  • The .python-version file (recommended)
  • The python_full_version field in the Pipfile.lock file (Pipenv users only)
  • The python_version field in the Pipfile.lock file (Pipenv users only)

To instruct the platform to use a specific Python runtime, add a .python-version file to your app’s root directory and declare the Python version number to use in it.

This version can be either:

  • The major Python version such as 3.12 (recommended)
  • The full Python version such as 3.12.7

Dependencies

When the project is using pipenv and contains a Pipfile and a Pipfile.lock files, the following command is used to install dependencies:

pipenv install

Legacy: requirements.txt

If a requirements.txt file is present in your application, the dependencies will be installed respecting this file with:

pip install -r requirements.txt

Frameworks

We handle most of the common frameworks. Obviously, Django is among them. You need to configure your application to bind the port defined by the environment variable $PORT.

Specific Python Buildpack Hooks

You may want to trigger custom actions after a successful deployment. The postdeploy hook is exactly what you need. But your application may require some actions to be executed during the deployment.

The Python buildpack can execute two hooks: before and after the installation of Python and its dependencies. They must be located in the bin root folder of your application and be named pre_compile and post_compile.

Buildpack

More information at https://github.com/Scalingo/python-buildpack.


Suggest edits

Python

©2024 Scalingo