File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 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"
610elif command -v python > /dev/null 2>&1 ; then
711 PYTHON_BIN=" python"
Original file line number Diff line number Diff line change 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+
148175test_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() {
194221test_release_exits_when_procfile_exists
195222test_release_prefers_project_name_script_over_start
196223test_release_falls_back_to_start_script
224+ test_release_prefers_buildpack_managed_python_when_present
197225test_release_falls_back_to_main_py
198226test_release_falls_back_to_app_py
199227test_release_leaves_web_process_empty_when_no_entrypoint_exists
You can’t perform that action at this time.
0 commit comments