Python Language Recognition Strategy
By default, the platform will recognize it as a Python project based on whether there is a
requirements.txt file in the source root directory.
Platform Compilation and Operation Mechanism
- The pre-compilation process will detect whether the startup command configuration file Procfile is defined, and if not defined, the default Flask/Django startup configuration file will be generated;
- After the pre-compilation process is completed, the Python buildpack will be selected according to the language type to compile the project. The defined Python version and related Python dependencies will be installed during the compilation process;
- After the compilation is completed, it will be checked whether the Procfile parameter is set on the platform, and if it is configured, the startup command configuration file Procfile will be overwritten.
Python Project Source Code Specification
In this step, you need to provide a usable Python source code program for deployment on the Kato platform. This application must at least meet the following conditions:
- The deployed Python program can be run normally locally
- The project can be hosted in a git repository
requirements.txtmust exist in the project root directory, which is used to manage the dependencies of the Python project and is also a necessary condition for Kato to recognize the Python language
Procfileneeds to be defined in the root directory of the project to define the way to start the program
- There is
runtime.txtin the project root directory, which is used to define the Python version of the current project
If the program has no dependencies, make
requirements.txt an empty file.
If there is no
requirements.txt, the following command can be used to generate
pip freeze > requirements.txt
If the project does not define a Procfile file, the platform will generate a default Procfile to run the War package by default.
web: gunicorn app:app --log-file - --access-logfile - --error-logfile -
The above is the default Procfile, if you need to expand more startup parameters, you can customize the Procfile.
- There is a space between
- The end of the file cannot contain special characters
Compile and Run Environment Settings
Configure Python Version
It is recommended to use runtime.txt to define the Python version. If not defined, Kato will use the
python-3.6.6 version by default.
$ cat runtime.txt python-3.6.6
Recommended python version
The python version is supported by default
# python 2.7.x python-2.7.9 python-2.7.10 python-2.7.13 python-2.7.14 python-2.7.15 # python 3.x python-3.4.3 python-3.5.3 python-3.6.0 python-3.6.1 python-3.6.2 python-3.6.3 python-3.6.4 python-3.6.5 python-3.6.6 python-3.7.0
Advanced Build Options
Enable advanced build features in build advanced settings or build sources
|Environment Variables||Default Value||Description|
Django Static File Support
Since the static file support (CSS, images, etc.) of Django is not easy to configure and difficult to debug, here is an example:
By default, the system will automatically execute the following command when building a Django application to try to check (–dry-run) whether the static file configuration is correct:
$ python manage.py collectstatic --dry-run --noinput
If there is no error in this command, the real command will be executed to copy the static files to the STATIC_ROOT directory:
$ python manage.py collectstatic --noinput
Users can manually disable the above features, only need to configure the value of
BUILD_DISABLE_COLLECTSTATIC to 1 in the application environment variables.