Skip to content

Commit 39912f4

Browse files
committed
fix(common): change python path for start command
1 parent 08f8b3d commit 39912f4

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

bin/release

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env bash
22
# Release script for Python buildpack with uv support
33

4-
if command -v python3 >/dev/null 2>&1; then
4+
if [ -x ".python/bin/python3" ]; then
5+
PYTHON_BIN=".python/bin/python3"
6+
elif [ -x ".python/bin/python" ]; then
7+
PYTHON_BIN=".python/bin/python"
8+
elif command -v python3 >/dev/null 2>&1; then
59
PYTHON_BIN="python3"
610
elif command -v python >/dev/null 2>&1; then
711
PYTHON_BIN="python"

test/unit/release_test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,33 @@ EOF
145145
assert_contains "$output" 'web: python3 -c "from server.main import start; start()"' "release should fall back to the start script"
146146
}
147147

148+
test_release_prefers_buildpack_managed_python_when_present() {
149+
# Arrange
150+
local app_dir="$TEST_ROOT/managed-python-app"
151+
mkdir -p "$app_dir/.python/bin"
152+
setup_fake_python_commands
153+
cat > "$app_dir/pyproject.toml" <<'EOF'
154+
[project]
155+
name = "my-app"
156+
157+
[project.scripts]
158+
start = "server.main:start"
159+
EOF
160+
cat > "$app_dir/.python/bin/python3" <<'EOF'
161+
#!/usr/bin/env bash
162+
set -euo pipefail
163+
exec "$REAL_PYTHON3" "$@"
164+
EOF
165+
chmod +x "$app_dir/.python/bin/python3"
166+
167+
# Act
168+
run_release "$app_dir"
169+
170+
# Assert
171+
assert_exit_code "$status" 0 "release should succeed when the buildpack-managed python is present"
172+
assert_contains "$output" 'web: .python/bin/python3 -c "from server.main import start; start()"' "release should prefer the buildpack-managed python shim"
173+
}
174+
148175
test_release_falls_back_to_main_py() {
149176
# Arrange
150177
local app_dir="$TEST_ROOT/main-py-app"
@@ -194,6 +221,7 @@ test_release_leaves_web_process_empty_when_no_entrypoint_exists() {
194221
test_release_exits_when_procfile_exists
195222
test_release_prefers_project_name_script_over_start
196223
test_release_falls_back_to_start_script
224+
test_release_prefers_buildpack_managed_python_when_present
197225
test_release_falls_back_to_main_py
198226
test_release_falls_back_to_app_py
199227
test_release_leaves_web_process_empty_when_no_entrypoint_exists

0 commit comments

Comments
 (0)