Skip to content

Commit 82a6a40

Browse files
committed
fix(common): change runtime path
1 parent 8c19354 commit 82a6a40

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

bin/compile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ if [ -f "pyproject.toml" ] && [ -f "uv.lock" ]; then
133133
# project itself is not installed by the exported third-party requirements.
134134
if [ -d "$SRC_DIR" ]; then
135135
cat > "$PROFILE_DIR/python.sh" <<EOF
136-
export PATH="$PYTHON_SHIM_DIR:$PACKAGE_BIN_DIR:\${PATH}"
137-
export PYTHONPATH="$SRC_DIR:$SITE_PACKAGES_DIR:\${PYTHONPATH}"
136+
export APP_DIR="\${HOME}/app"
137+
export PATH="\$APP_DIR/.python/bin:\$APP_DIR/.python_packages/bin:\${PATH}"
138+
export PYTHONPATH="\$APP_DIR/src:\$APP_DIR/.python_packages/lib/python${PYTHON_VERSION}/site-packages:\${PYTHONPATH}"
138139
EOF
139140
else
140141
cat > "$PROFILE_DIR/python.sh" <<EOF
141-
export PATH="$PYTHON_SHIM_DIR:$PACKAGE_BIN_DIR:\${PATH}"
142-
export PYTHONPATH="$SITE_PACKAGES_DIR:\${PYTHONPATH}"
142+
export APP_DIR="\${HOME}/app"
143+
export PATH="\$APP_DIR/.python/bin:\$APP_DIR/.python_packages/bin:\${PATH}"
144+
export PYTHONPATH="\$APP_DIR/.python_packages/lib/python${PYTHON_VERSION}/site-packages:\${PYTHONPATH}"
143145
EOF
144146
fi
145147
else

test/unit/compile_test.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ test_compile_succeeds_for_locked_uv_project() {
216216
assert_path_exists "$export_file" "compile should write the exported requirements file"
217217
assert_path_exists "$shim_dir/python3" "compile should create a python3 shim for runtime commands"
218218
assert_path_exists "$shim_dir/python" "compile should create a python shim for runtime commands"
219-
assert_file_contains "$profile_file" "$site_packages_dir" "profile script should add staged dependencies to PYTHONPATH"
220-
assert_file_contains "$profile_file" "$shim_dir" "profile script should add the managed Python shims to PATH"
221-
assert_file_contains "$profile_file" "$package_bin_dir" "profile script should add staged console scripts to PATH"
219+
assert_file_contains "$profile_file" 'export APP_DIR="${HOME}/app"' "profile script should resolve paths from the droplet app directory at runtime"
220+
assert_file_contains "$profile_file" '$APP_DIR/.python/bin:$APP_DIR/.python_packages/bin:${PATH}' "profile script should add the managed Python shims and staged console scripts to PATH"
221+
assert_file_contains "$profile_file" '$APP_DIR/.python_packages/lib/python3.13/site-packages:${PYTHONPATH}' "profile script should add staged dependencies to PYTHONPATH"
222222
assert_file_contains "$TEST_ROOT/uv.log" "python install 3.13" "compile should install the Python version pinned by .python-version"
223223
assert_file_contains "$TEST_ROOT/uv.log" "python find --managed-python 3.13" "compile should resolve the managed interpreter path after installation"
224224
assert_file_contains "$TEST_ROOT/uv.log" "export --locked --format requirements-txt --no-emit-local -o $export_file" "compile should export locked third-party dependencies"
@@ -242,7 +242,7 @@ test_compile_adds_src_directory_to_pythonpath_when_present() {
242242

243243
# Assert
244244
assert_exit_code "$status" 0 "compile should succeed for src-layout projects"
245-
assert_file_contains "$profile_file" "$build_dir/src" "profile script should add src layout projects to PYTHONPATH"
245+
assert_file_contains "$profile_file" '$APP_DIR/src:$APP_DIR/.python_packages/lib/python3.13/site-packages:${PYTHONPATH}' "profile script should add src layout projects to PYTHONPATH using runtime paths"
246246
}
247247

248248
test_compile_accepts_two_argument_cf_invocation() {

0 commit comments

Comments
 (0)