Skip to content

Commit c6436be

Browse files
committed
fix: improve PEP 668 detection with fallback retry logic
- Try standard pip install first - If it fails, automatically retry with --break-system-packages - More reliable than checking sys.externally_managed - Better error handling and logging
1 parent c290de6 commit c6436be

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tests/oc2ov_test/upgrade_openviking.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,16 @@ fi
128128
log "[5.6/8] Installing Python build dependencies..."
129129
log "Installing setuptools-scm and other build tools..."
130130

131-
# Check if we need --break-system-packages flag
132-
PIP_FLAGS=""
133-
if python3 -c "import sys; sys.exit(0 if hasattr(sys, 'externally_managed') else 1)" 2>/dev/null; then
134-
log "Detected externally-managed Python environment, using --break-system-packages"
135-
PIP_FLAGS="--break-system-packages"
136-
fi
137-
138-
pip3 install $PIP_FLAGS --upgrade setuptools setuptools-scm wheel cmake build 2>&1 | tee -a "$LOG_FILE"
139-
if [ $? -eq 0 ]; then
140-
log "✅ Build dependencies installed successfully"
131+
# Try to install without --break-system-packages first
132+
if ! pip3 install --upgrade setuptools setuptools-scm wheel cmake build 2>&1 | tee -a "$LOG_FILE"; then
133+
log "Standard pip install failed, trying with --break-system-packages..."
134+
if pip3 install --break-system-packages --upgrade setuptools setuptools-scm wheel cmake build 2>&1 | tee -a "$LOG_FILE"; then
135+
log "✅ Build dependencies installed successfully with --break-system-packages"
136+
else
137+
log "⚠️ Failed to install some build dependencies, continuing anyway..."
138+
fi
141139
else
142-
log "⚠️ Failed to install some build dependencies, continuing anyway..."
140+
log "✅ Build dependencies installed successfully"
143141
fi
144142

145143
log "[6/8] Cleaning previous build artifacts..."

0 commit comments

Comments
 (0)