Skip to content

Commit ef06509

Browse files
committed
feat(build): enhance installation script to uninstall existing pyprophet and optimize wheel build process
1 parent 4e431a4 commit ef06509

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

scripts/build/build_linux.sh

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,57 @@ for dep in deps:
7171
continue
7272
PYEOF
7373

74+
# Uninstall any existing pyprophet installation
75+
echo "Uninstalling any existing pyprophet..."
76+
$PYTHON -m pip uninstall -y pyprophet 2>/dev/null || true
77+
78+
# Move pyprophet source directory OUT of the way completely
79+
echo "Temporarily hiding pyprophet source directory..."
80+
TEMP_BACKUP_DIR=$(mktemp -d)
81+
if [ -d "pyprophet" ]; then
82+
mv pyprophet "${TEMP_BACKUP_DIR}/pyprophet_src"
83+
fi
84+
if [ -d "packaging" ]; then
85+
mv packaging "${TEMP_BACKUP_DIR}/packaging_src"
86+
fi
87+
7488
# Build pyprophet wheel in a completely isolated temp directory
7589
echo "Building pyprophet wheel in isolated directory..."
7690
WHEEL_BUILD_DIR=$(mktemp -d)
77-
cp -r "${ORIGINAL_DIR}"/* "${WHEEL_BUILD_DIR}/" 2>/dev/null || true
91+
92+
# Copy ONLY the files needed for building (not the entire tree)
93+
cp "${ORIGINAL_DIR}/pyproject.toml" "${WHEEL_BUILD_DIR}/"
94+
cp "${ORIGINAL_DIR}/setup.py" "${WHEEL_BUILD_DIR}/"
95+
cp "${ORIGINAL_DIR}/README.md" "${WHEEL_BUILD_DIR}/" 2>/dev/null || true
96+
cp "${ORIGINAL_DIR}/LICENSE" "${WHEEL_BUILD_DIR}/" 2>/dev/null || true
97+
98+
# Copy source files
99+
cp -r "${TEMP_BACKUP_DIR}/pyprophet_src" "${WHEEL_BUILD_DIR}/pyprophet"
100+
78101
cd "${WHEEL_BUILD_DIR}"
79102

103+
# Build wheel
80104
$PYTHON -m pip wheel --no-deps --wheel-dir /tmp/pyprophet_wheels .
81105

82-
# Return to original directory and clean up wheel build directory
106+
# Return to original directory
83107
cd "${ORIGINAL_DIR}"
84-
rm -rf "${WHEEL_BUILD_DIR}"
85108

86-
# CRITICAL: Remove pyprophet source directory to prevent pip from finding it
87-
# and installing in editable mode
88-
echo "Temporarily moving pyprophet source directory..."
89-
if [ -d "pyprophet" ]; then
90-
mv pyprophet pyprophet.bak
91-
fi
109+
# Clean up wheel build directory
110+
rm -rf "${WHEEL_BUILD_DIR}"
92111

93-
# Install pyprophet from wheel (this will now go to site-packages)
112+
# Install pyprophet from wheel (now pyprophet source is hidden, so it MUST go to site-packages)
94113
echo "Installing pyprophet from wheel to site-packages..."
95-
$PYTHON -m pip install --force-reinstall --no-deps /tmp/pyprophet_wheels/pyprophet-*.whl
114+
$PYTHON -m pip install --no-deps --no-cache-dir /tmp/pyprophet_wheels/pyprophet-*.whl
96115

97-
# Restore the source directory (we'll need hooks and run_pyprophet.py later)
98-
if [ -d "pyprophet.bak" ]; then
99-
mv pyprophet.bak pyprophet
116+
# Restore the source directories
117+
echo "Restoring source directories..."
118+
if [ -d "${TEMP_BACKUP_DIR}/pyprophet_src" ]; then
119+
mv "${TEMP_BACKUP_DIR}/pyprophet_src" pyprophet
120+
fi
121+
if [ -d "${TEMP_BACKUP_DIR}/packaging_src" ]; then
122+
mv "${TEMP_BACKUP_DIR}/packaging_src" packaging
100123
fi
124+
rm -rf "${TEMP_BACKUP_DIR}"
101125

102126
# Verify installation is in site-packages, NOT source directory
103127
echo "Verifying pyprophet installation..."
@@ -127,7 +151,7 @@ else
127151
echo "✗ WARNING: NumPy may not be in site-packages!"
128152
fi
129153

130-
$PYTHON -c "import pandas; print('Pandas imports successfully')"
154+
$PYTHON -c "import pandas; print('Pandas imports successfully')"
131155

132156
# Collect compiled extension binaries from the installed package
133157
ADD_BINARY_ARGS=()

0 commit comments

Comments
 (0)