Skip to content

Commit 23479e6

Browse files
authored
Expand buildpack detection known file list (#1729)
This adds more Python project related file and directory names to the list recognised by buildpack detection. Such apps will still fail to build successfully (since they are missing a package manager file), but will now be shown a more helpful error message during compile, rather than the generic: "No default language could be detected for this app" The list is based on builds logs analysis of builds that filed to pass detection, plus builds that passed detection but didn't have a valid package manager file. (Possible since the build logs error message includes a file listing of the root directory of the app.) GUS-W-17530056.
1 parent f686af6 commit 23479e6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44

5+
- Added more Python project related file and directory names to the list recognised by buildpack detection. ([#1729](https://github.com/heroku/heroku-buildpack-python/pull/1729))
56
- Improved the file listing in the error messages shown when buildpack detection fails or when no Python package manager files are found. ([#1728](https://github.com/heroku/heroku-buildpack-python/pull/1728))
67

78
## [v272] - 2024-12-13

bin/detect

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ source "${BUILDPACK_DIR}/lib/output.sh"
2020
# allowing us to show a helpful error message during the build phase.
2121
KNOWN_PYTHON_PROJECT_FILES=(
2222
.python-version
23+
__init__.py
2324
app.py
2425
main.py
2526
manage.py
@@ -30,13 +31,27 @@ KNOWN_PYTHON_PROJECT_FILES=(
3031
pyproject.toml
3132
requirements.txt
3233
runtime.txt
34+
server.py
3335
setup.cfg
3436
setup.py
3537
uv.lock
38+
# Commonly seen misspellings of requirements.txt. (Which occur since pip doesn't
39+
# create/manage requirements files itself, so the filenames are manually typed.)
40+
requirement.txt
41+
Requirements.txt
42+
requirements.text
43+
requirements.txt.txt
44+
requirments.txt
45+
# Whilst virtual environments shouldn't be committed to Git (and so shouldn't
46+
# normally be present during the build), they are often present for beginner
47+
# Python apps that are missing all of the other Python related files above.
48+
.venv/
49+
venv/
3650
)
3751

38-
for filename in "${KNOWN_PYTHON_PROJECT_FILES[@]}"; do
39-
if [[ -f "${BUILD_DIR}/${filename}" ]]; then
52+
for filepath in "${KNOWN_PYTHON_PROJECT_FILES[@]}"; do
53+
# Using -e since we need to check for both files and directories.
54+
if [[ -e "${BUILD_DIR}/${filepath}" ]]; then
4055
echo "Python"
4156
exit 0
4257
fi

0 commit comments

Comments
 (0)