|
3 | 3 |
|
4 | 4 | set -euo pipefail |
5 | 5 |
|
| 6 | +# Prefer the Python interpreter staged by `bin/compile`, but fall back to a |
| 7 | +# system interpreter so local development and unit tests can still run. |
6 | 8 | if [ -x ".python/bin/python3" ]; then |
7 | 9 | PYTHON_BIN=".python/bin/python3" |
8 | 10 | elif [ -x ".python/bin/python" ]; then |
@@ -47,19 +49,23 @@ build_python_entrypoint() { |
47 | 49 |
|
48 | 50 | DEFAULT_WEB_PROCESS="" |
49 | 51 |
|
50 | | -# If the app provides its own Procfile, let Cloud Foundry use that. |
| 52 | +# Procfile wins. When it exists, Cloud Foundry will read it directly and the |
| 53 | +# buildpack should not emit a generated default process type. |
51 | 54 | if [ -f "Procfile" ]; then |
52 | 55 | exit 0 |
53 | 56 | fi |
54 | 57 |
|
55 | | -# Prefer a script named after `project.name`, then fall back to `start`. |
| 58 | +# Without a Procfile, try to synthesize a Python command from pyproject.toml. |
| 59 | +# We prefer a console script that matches `project.name`, then fall back to |
| 60 | +# a generic `start` script if one exists. |
56 | 61 | if [ -f "pyproject.toml" ]; then |
57 | 62 | SCRIPT_TARGET="$(resolve_script_target)" |
58 | 63 | if [ -n "$SCRIPT_TARGET" ]; then |
59 | 64 | DEFAULT_WEB_PROCESS="$(build_python_entrypoint "$SCRIPT_TARGET")" |
60 | 65 | fi |
61 | 66 | fi |
62 | 67 |
|
| 68 | +# If there are no console scripts, fall back to common single-file app layouts. |
63 | 69 | if [ -z "$DEFAULT_WEB_PROCESS" ] && [ -f "main.py" ]; then |
64 | 70 | DEFAULT_WEB_PROCESS="${PYTHON_BIN} main.py" |
65 | 71 | fi |
|
0 commit comments