Skip to content

Commit 4c53fdb

Browse files
saurabh500Copilot
andcommitted
Fix musl detection on Alpine for mssql_py_core install
ldd --version exits with code 1 on musl/Alpine. Combined with set -euo pipefail, the piped grep check always took the else branch, misidentifying Alpine as glibc (manylinux). pip then rejected the manylinux wheel since it cannot run on musl. Fix: capture ldd output into a variable with || true before grepping. Add fallback detection via /etc/alpine-release and /lib/ld-musl-*. Skip gracefully (exit 0) when no musllinux wheel is available yet. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cbef84a commit 4c53fdb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

eng/scripts/install-mssql-py-core.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,20 @@ echo "Python: $PY_VERSION | Platform: $PLATFORM | Arch: $ARCH"
4949
# Detect musl (Alpine) vs glibc for Linux
5050
case "$PLATFORM" in
5151
linux)
52-
if ldd --version 2>&1 | grep -qi musl; then
52+
# Detect musl libc (Alpine) vs glibc — multiple methods for robustness
53+
# Note: ldd --version exits with code 1 on musl, which combined with
54+
# pipefail causes the grep pipeline to fail. Use a variable instead.
55+
IS_MUSL=false
56+
LDD_OUTPUT=$(ldd --version 2>&1 || true)
57+
if echo "$LDD_OUTPUT" | grep -qi musl; then
58+
IS_MUSL=true
59+
elif [ -f /etc/alpine-release ]; then
60+
IS_MUSL=true
61+
elif ls /lib/ld-musl-* >/dev/null 2>&1; then
62+
IS_MUSL=true
63+
fi
64+
65+
if $IS_MUSL; then
5366
LIBC="musllinux_1_2"
5467
else
5568
LIBC="manylinux_2_28"
@@ -132,6 +145,13 @@ MATCHING_WHEEL=$(find "$WHEELS_DIR" -name "$WHEEL_PATTERN" | head -1)
132145
if [ -z "$MATCHING_WHEEL" ]; then
133146
echo "Available wheels:"
134147
ls "$WHEELS_DIR"/*.whl 2>/dev/null || echo " (none)"
148+
# On musllinux (Alpine), no wheels may be available yet — skip gracefully
149+
if echo "$WHEEL_PLATFORM" | grep -q "musllinux"; then
150+
echo "WARNING: No musllinux wheel found matching pattern: $WHEEL_PATTERN"
151+
echo "mssql_py_core is not yet available for musllinux — skipping installation."
152+
rm -rf "$OUTPUT_DIR"
153+
exit 0
154+
fi
135155
echo "ERROR: No wheel found matching pattern: $WHEEL_PATTERN"
136156
exit 1
137157
fi

0 commit comments

Comments
 (0)