Skip to content

Commit 02ae09e

Browse files
committed
feat(build): enhance build script to save original directory and clean up previous builds
1 parent 4115aa2 commit 02ae09e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

scripts/build/build_linux.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
# filepath: /workspaces/pyprophet/scripts/build/build_linux.sh
23
# Build script for PyProphet Linux executable using PyInstaller
34

45
set -euo pipefail
@@ -80,18 +81,24 @@ for so in "${SITE_PACKAGES}"/pyprophet/scoring/_optimized*.so; do
8081
fi
8182
done
8283

83-
# Clean previous PyInstaller builds
84+
# Save the original directory
85+
ORIGINAL_DIR="$(pwd)"
86+
87+
# Clean previous PyInstaller builds in original directory
8488
rm -rf build dist pyprophet.spec
8589

90+
# Create dist directory in original location
91+
mkdir -p "${ORIGINAL_DIR}/dist"
92+
8693
# Change to a temporary directory to avoid picking up source files
8794
# This ensures PyInstaller only sees installed packages
8895
BUILD_DIR=$(mktemp -d)
8996
echo "Using temporary build directory: ${BUILD_DIR}"
9097
cd "${BUILD_DIR}"
9198

9299
# Copy only the necessary files
93-
cp "${OLDPWD}/packaging/pyinstaller/run_pyprophet.py" .
94-
cp -r "${OLDPWD}/packaging/pyinstaller/hooks" .
100+
cp "${ORIGINAL_DIR}/packaging/pyinstaller/run_pyprophet.py" .
101+
cp -r "${ORIGINAL_DIR}/packaging/pyinstaller/hooks" .
95102

96103
# Run PyInstaller in onefile mode (single executable)
97104
echo "Running PyInstaller (onefile mode)..."
@@ -131,10 +138,11 @@ $PYTHON -m PyInstaller \
131138
run_pyprophet.py
132139

133140
# Move the built executable back to the original directory
134-
mv dist/pyprophet "${OLDPWD}/dist/"
141+
echo "Moving executable to ${ORIGINAL_DIR}/dist/"
142+
mv dist/pyprophet "${ORIGINAL_DIR}/dist/pyprophet"
135143

136144
# Return to original directory
137-
cd "${OLDPWD}"
145+
cd "${ORIGINAL_DIR}"
138146

139147
# Clean up temporary build directory and wheel directory
140148
rm -rf "${BUILD_DIR}" /tmp/pyprophet_wheels

0 commit comments

Comments
 (0)