Skip to content

Commit c2fbc91

Browse files
committed
fix: rewrite venv shebangs to portable paths in tarball build
uv pip install stamps absolute build-time paths in console_scripts shebangs (e.g. /tmp/flash-worker-build/.../python), making binaries like uvicorn unfindable at runtime in the extracted tarball. Rewrite any shebang referencing the build dir to #!/usr/bin/env python3 after dependency installation.
1 parent 9bfece5 commit c2fbc91

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

scripts/build-tarball.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ uv export --format requirements-txt --no-dev --no-hashes > "$BUILD_DIR/requireme
9292
--python "$TARBALL_ROOT/venv/bin/python" \
9393
-r "$BUILD_DIR/requirements.txt"
9494

95+
# 4b. Fix shebangs in venv/bin scripts to use portable /usr/bin/env path
96+
# (uv pip install stamps absolute build-time paths in console_scripts)
97+
for script in "$TARBALL_ROOT/venv/bin/"*; do
98+
[ -f "$script" ] || continue
99+
head -1 "$script" | grep -q "^#!.*$BUILD_DIR" || continue
100+
sed -i "1s|^#!.*|#!/usr/bin/env python3|" "$script"
101+
done
102+
95103
# 5. Copy source files
96104
echo "Copying source files..."
97105
cp -r "$REPO_ROOT/src/"*.py "$TARBALL_ROOT/src/" 2>/dev/null || true

0 commit comments

Comments
 (0)