Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8cee2e8
Add standalone mssql-python-odbc package for ODBC driver binaries
jahnvi480 Jul 7, 2026
69ca1b7
FIX: Robust ODBC driver fallback and address review feedback for pack…
jahnvi480 Jul 7, 2026
362b1df
FIX: Require complete odbc libs (driver + mssql-auth.dll) before usin…
jahnvi480 Jul 7, 2026
25ff315
Include vcredist (msvcp140.dll) in odbc package for full parity with …
jahnvi480 Jul 7, 2026
c3c3001
Address review: acquire GIL in GetOdbcLibsBaseDir, document driver-ve…
jahnvi480 Jul 7, 2026
d69ce14
Document deliberate vcredist/msvcp140.dll inclusion in odbc wheel
jahnvi480 Jul 7, 2026
40961b7
DOCS: Add CHANGELOG entry for the mssql-python-odbc package split
jahnvi480 Jul 8, 2026
74b6d62
Fix inaccurate setup_odbc.py docstring on libs packaging
jahnvi480 Jul 8, 2026
eb100db
Merge branch 'main' into jahnvi/odbc-package-split
jahnvi480 Jul 10, 2026
0884620
odbc: bump mssql-python-odbc package version 18.6.0 -> 18.6.2
jahnvi480 Jul 10, 2026
ab91887
Centralize ODBC driver version via single source of truth
jahnvi480 Jul 17, 2026
33a6084
Merge remote-tracking branch 'origin/main' into jahnvi/odbc-package-s…
jahnvi480 Jul 17, 2026
73733d4
Fix Linux pipeline uninstall parsing and ARM64 setup checks
jahnvi480 Jul 17, 2026
087b39b
Fix Linux pipeline version parsing quoting
jahnvi480 Jul 17, 2026
63a2117
Fix Linux pipeline host-side version parsing
jahnvi480 Jul 17, 2026
d9749ad
Fix Ubuntu Linux pipeline version parsing
jahnvi480 Jul 17, 2026
07888e9
Fix DRIVER_MAJOR_MINOR setup in all Linux uninstall steps
jahnvi480 Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ build/
**/build/
mssql_python.egg-info/

# ODBC package (mssql-python-odbc): transition-period build artifacts.
# During Phase 2, setup_odbc.py copies the current platform's driver binaries
# from mssql_python/libs into this tree so a wheel can be built locally. The
# release pipeline populates these per-platform; do not commit the copies.
mssql_python_odbc/libs/
mssql_python_odbc.egg-info/

# Python bytecode
__pycache__/
*.py[cod]
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
connection. The callback is invoked by mssql-tds mid-handshake (FedAuth
workflow 0x02) so the tenant id can be resolved from the server-supplied
STS URL. Requires `mssql-py-core` 0.1.5+. Partial fix for #534.
- **Standalone `mssql-python-odbc` package (PRs #663, #664):** the Microsoft
ODBC Driver 18 for SQL Server binaries are now also published as a separate,
platform-specific `mssql-python-odbc` package. When it is installed, the
native driver loader resolves the driver from it; when it is absent or
incomplete, mssql-python transparently falls back to its own bundled `libs/`.
This is a non-breaking step toward decoupling driver-binary updates from
mssql-python releases; a future major version will make the dependency
explicit and drop the bundled binaries.

### Changed
- Improved error handling in the connection module.
Expand Down
70 changes: 62 additions & 8 deletions eng/pipelines/pr-validation-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ jobs:

- script: |
# Install ODBC driver in the container
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-$(distroName) bash -c "
export DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -833,6 +836,9 @@ jobs:

- script: |
# Uninstall ODBC Driver before running tests
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-$(distroName) bash -c "
export DEBIAN_FRONTEND=noninteractive
apt-get remove --purge -y msodbcsql18 mssql-tools18 unixodbc-dev
Expand All @@ -843,7 +849,7 @@ jobs:
odbcinst -u -d -n 'ODBC Driver 18 for SQL Server' || true
echo 'Uninstalled ODBC Driver and cleaned up libraries'
echo 'Verifying x86_64 debian_ubuntu driver library signatures:'
ldd mssql_python/libs/linux/debian_ubuntu/x86_64/lib/libmsodbcsql-18.6.so.2.1
ldd mssql_python/libs/linux/debian_ubuntu/x86_64/lib/libmsodbcsql-${DRIVER_MAJOR_MINOR}.so.2.1
"
displayName: 'Uninstall ODBC Driver before running tests in $(distroName) container'

Expand Down Expand Up @@ -1070,32 +1076,41 @@ jobs:
# Install dependencies in the ARM64 container
if [ "$(distroName)" = "Ubuntu" ]; then
docker exec test-container-$(distroName)-$(archName) bash -c "
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
export TZ=UTC
ln -snf /usr/share/zoneinfo/\$TZ /etc/localtime && echo \$TZ > /etc/timezone
apt-get update &&
apt-get update
apt-get install -y python3 python3-pip python3-venv python3-full cmake curl wget gnupg software-properties-common build-essential python3-dev pybind11-dev
# Verify architecture
uname -m
dpkg --print-architecture
python3 --version
cmake --version
"
else
# Debian ARM64
docker exec test-container-$(distroName)-$(archName) bash -c "
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
export TZ=UTC
ln -snf /usr/share/zoneinfo/\$TZ /etc/localtime && echo \$TZ > /etc/timezone
apt-get update &&
apt-get update
apt-get install -y python3 python3-pip python3-venv python3-full cmake curl wget gnupg software-properties-common build-essential python3-dev pybind11-dev
# Verify architecture
uname -m
dpkg --print-architecture
python3 --version
cmake --version
"
fi
displayName: 'Install basic dependencies in $(distroName) ARM64 container'

- script: |
# Install ODBC driver in the ARM64 container
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-$(distroName)-$(archName) bash -c "
export DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -1126,9 +1141,14 @@ jobs:
- script: |
# Install Python dependencies in the ARM64 container using virtual environment
docker exec test-container-$(distroName)-$(archName) bash -c "
set -euo pipefail
# Create a virtual environment
python3 -m venv /opt/venv
source /opt/venv/bin/activate

# Ensure the expected runtime tools are available before build/test steps
command -v python >/dev/null 2>&1
command -v cmake >/dev/null 2>&1

# Install dependencies in the virtual environment
python -m pip install --upgrade pip
Expand All @@ -1142,7 +1162,14 @@ jobs:
- script: |
# Build pybind bindings in the ARM64 container
docker exec test-container-$(distroName)-$(archName) bash -c "
set -euo pipefail
if [ ! -f /opt/venv/bin/activate ]; then
echo '/opt/venv/bin/activate is missing. Python dependency setup did not complete.'
exit 1
fi
source /opt/venv/bin/activate
command -v python >/dev/null 2>&1
command -v cmake >/dev/null 2>&1
cd mssql_python/pybind
chmod +x build.sh
./build.sh
Expand All @@ -1158,6 +1185,9 @@ jobs:

- script: |
# Uninstall ODBC Driver before running tests
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-$(distroName)-$(archName) bash -c "
export DEBIAN_FRONTEND=noninteractive
apt-get remove --purge -y msodbcsql18 mssql-tools18 unixodbc-dev
Expand All @@ -1168,7 +1198,7 @@ jobs:
odbcinst -u -d -n 'ODBC Driver 11 for SQL Server' || true
echo 'Uninstalled ODBC Driver and cleaned up libraries'
echo 'Verifying arm64 debian_ubuntu driver library signatures:'
ldd mssql_python/libs/linux/debian_ubuntu/arm64/lib/libmsodbcsql-18.6.so.2.1
ldd mssql_python/libs/linux/debian_ubuntu/arm64/lib/libmsodbcsql-${DRIVER_MAJOR_MINOR}.so.2.1
"
displayName: 'Uninstall ODBC Driver before running tests in $(distroName) ARM64 container'

Expand Down Expand Up @@ -1268,6 +1298,9 @@ jobs:

- script: |
# Install dependencies in the RHEL 9 container
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-rhel9 bash -c "
# Enable CodeReady Builder repository for additional packages
dnf update -y
Expand Down Expand Up @@ -1372,6 +1405,9 @@ jobs:

- script: |
# Uninstall ODBC Driver before running tests
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-rhel9 bash -c "
dnf remove -y msodbcsql18 mssql-tools18 unixODBC-devel
rm -f /usr/bin/sqlcmd
Expand All @@ -1381,7 +1417,7 @@ jobs:
odbcinst -u -d -n 'ODBC Driver 11 for SQL Server' || true
echo 'Uninstalled ODBC Driver and cleaned up libraries'
echo 'Verifying x86_64 rhel driver library signatures:'
ldd mssql_python/libs/linux/rhel/x86_64/lib/libmsodbcsql-18.6.so.2.1
ldd mssql_python/libs/linux/rhel/x86_64/lib/libmsodbcsql-${DRIVER_MAJOR_MINOR}.so.2.1
"
displayName: 'Uninstall ODBC Driver before running tests in RHEL 9 container'

Expand Down Expand Up @@ -1489,6 +1525,9 @@ jobs:

- script: |
# Install dependencies in the RHEL 9 ARM64 container
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-rhel9-arm64 bash -c "
# Enable CodeReady Builder repository for additional packages
dnf update -y
Expand Down Expand Up @@ -1597,6 +1636,9 @@ jobs:

- script: |
# Uninstall ODBC Driver before running tests
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-rhel9-arm64 bash -c "
dnf remove -y msodbcsql18 mssql-tools18 unixODBC-devel
rm -f /usr/bin/sqlcmd
Expand All @@ -1606,7 +1648,7 @@ jobs:
odbcinst -u -d -n 'ODBC Driver 18 for SQL Server' || true
echo 'Uninstalled ODBC Driver and cleaned up libraries'
echo 'Verifying arm64 rhel driver library signatures:'
ldd mssql_python/libs/linux/rhel/arm64/lib/libmsodbcsql-18.6.so.2.1
ldd mssql_python/libs/linux/rhel/arm64/lib/libmsodbcsql-${DRIVER_MAJOR_MINOR}.so.2.1
"
displayName: 'Uninstall ODBC Driver before running tests in RHEL 9 ARM64 container'

Expand Down Expand Up @@ -1750,6 +1792,9 @@ jobs:

- script: |
# Install ODBC driver in the Alpine x86_64 container
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-alpine bash -c "
# Detect architecture for ODBC driver download
case \$(uname -m) in
Expand Down Expand Up @@ -1830,6 +1875,9 @@ jobs:

- script: |
# Uninstall ODBC Driver before running tests to use bundled libraries
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-alpine bash -c "
# Remove system ODBC installation
apk del msodbcsql18 mssql-tools18 unixodbc-dev || echo 'ODBC packages not installed via apk'
Expand All @@ -1840,7 +1888,7 @@ jobs:
odbcinst -u -d -n 'ODBC Driver 18 for SQL Server' || true
echo 'Uninstalled system ODBC Driver and cleaned up libraries'
echo 'Verifying x86_64 alpine driver library signatures:'
ldd mssql_python/libs/linux/alpine/x86_64/lib/libmsodbcsql-18.6.so.2.1 || echo 'Driver library not found'
ldd mssql_python/libs/linux/alpine/x86_64/lib/libmsodbcsql-${DRIVER_MAJOR_MINOR}.so.2.1 || echo 'Driver library not found'
"
displayName: 'Uninstall system ODBC Driver before running tests in Alpine x86_64 container'

Expand Down Expand Up @@ -2000,6 +2048,9 @@ jobs:

- script: |
# Install ODBC driver in the Alpine ARM64 container
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-alpine-arm64 bash -c "
# Detect architecture for ODBC driver download
case \$(uname -m) in
Expand Down Expand Up @@ -2081,6 +2132,9 @@ jobs:

- script: |
# Uninstall ODBC Driver before running tests to use bundled libraries
DRIVER_VERSION=$(awk -F= '/^__version__/ {gsub(/[[:space:]"]/, "", $2); print $2; exit}' mssql_python_odbc/__init__.py)
DRIVER_MAJOR_MINOR=$(echo "$DRIVER_VERSION" | cut -d. -f1,2)
if [ -z "$DRIVER_MAJOR_MINOR" ]; then echo 'Error: failed to parse mssql_python_odbc.__version__'; exit 1; fi
docker exec test-container-alpine-arm64 bash -c "
# Remove system ODBC installation
apk del msodbcsql18 mssql-tools18 unixodbc-dev || echo 'ODBC packages not installed via apk'
Expand All @@ -2091,7 +2145,7 @@ jobs:
odbcinst -u -d -n 'ODBC Driver 18 for SQL Server' || true
echo 'Uninstalled system ODBC Driver and cleaned up libraries'
echo 'Verifying arm64 alpine driver library signatures:'
ldd mssql_python/libs/linux/alpine/arm64/lib/libmsodbcsql-18.6.so.2.1 || echo 'Driver library not found'
ldd mssql_python/libs/linux/alpine/arm64/lib/libmsodbcsql-${DRIVER_MAJOR_MINOR}.so.2.1 || echo 'Driver library not found'
"
displayName: 'Uninstall system ODBC Driver before running tests in Alpine ARM64 container'

Expand Down
30 changes: 30 additions & 0 deletions mssql_python/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,36 @@ endif()
add_definitions(-DARCHITECTURE="${ARCHITECTURE}")
add_definitions(-DPLATFORM_NAME="${PLATFORM_NAME}")

# --- msodbcsql driver version (single source of truth) -----------------------
# The ODBC driver filename embeds the msodbcsql version (e.g.
# libmsodbcsql-18.6.so.2.1 on Linux, libmsodbcsql.18.dylib on macOS,
# msodbcsql18.dll on Windows). Derive that version from
# mssql_python_odbc.__version__ -- the single source of truth for the driver
# version -- and inject it into GetDriverPathCpp() via -D defines, so the native
# resolver and the Python package can never drift. The literal is read straight
# from the file (not by importing the package) to keep configure hermetic and
# independent of whatever packages the build interpreter happens to have.
set(MSODBCSQL_VERSION_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../../mssql_python_odbc/__init__.py")
if(NOT EXISTS "${MSODBCSQL_VERSION_SOURCE}")
message(FATAL_ERROR
"Cannot resolve the msodbcsql driver version: ${MSODBCSQL_VERSION_SOURCE} not found. "
"The native driver filename is derived from mssql_python_odbc.__version__; "
"build from a full repository checkout.")
endif()
file(STRINGS "${MSODBCSQL_VERSION_SOURCE}" _msodbcsql_version_line REGEX "^__version__")
string(REGEX REPLACE ".*['\"]([0-9]+\\.[0-9]+\\.[0-9]+)['\"].*" "\\1"
MSODBCSQL_VERSION "${_msodbcsql_version_line}")
if(NOT MSODBCSQL_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
message(FATAL_ERROR
"Failed to parse __version__ from ${MSODBCSQL_VERSION_SOURCE} "
"(got '${MSODBCSQL_VERSION}').")
endif()
string(REGEX MATCH "^[0-9]+" MSODBCSQL_VERSION_MAJOR "${MSODBCSQL_VERSION}")
string(REGEX MATCH "^[0-9]+\\.[0-9]+" MSODBCSQL_VERSION_MAJOR_MINOR "${MSODBCSQL_VERSION}")
message(STATUS "msodbcsql driver version (from mssql_python_odbc.__version__): ${MSODBCSQL_VERSION} -> major=${MSODBCSQL_VERSION_MAJOR}, major.minor=${MSODBCSQL_VERSION_MAJOR_MINOR}")
add_definitions(-DMSODBCSQL_VERSION_MAJOR="${MSODBCSQL_VERSION_MAJOR}")
add_definitions(-DMSODBCSQL_VERSION_MAJOR_MINOR="${MSODBCSQL_VERSION_MAJOR_MINOR}")

# For macOS, always set universal build
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architectures for macOS" FORCE)
Expand Down
2 changes: 1 addition & 1 deletion mssql_python/pybind/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fi

# TODO: Linux-specific: use patchelf to set RPATH of the driver .so file
# Currently added Driver SO files right now are already patched
# patchelf --set-rpath '$ORIGIN' libmsodbcsql-18.6.so.2.1
# patchelf --set-rpath '$ORIGIN' libmsodbcsql-<major>.<minor>.so.2.1
# This command sets the RPATH of the specified .so file to the directory containing the file (similar to Windows)
# Needed since libodbcinst.so.2 is located in the same directory and needs to be resolved

Expand Down
31 changes: 23 additions & 8 deletions mssql_python/pybind/configure_dylibs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

ODBC_VERSION_FILE="$PROJECT_DIR/../mssql_python_odbc/__init__.py"
if [ ! -f "$ODBC_VERSION_FILE" ]; then
echo "Error: SSOT version file not found: $ODBC_VERSION_FILE"
exit 1
fi

DRIVER_MAJOR=$(sed -nE "s/^__version__[[:space:]]*=[[:space:]]*['\"]([0-9]+)\.[0-9]+\.[0-9]+['\"].*/\1/p" "$ODBC_VERSION_FILE" | head -1)
if [ -z "$DRIVER_MAJOR" ]; then
echo "Error: failed to parse __version__ from $ODBC_VERSION_FILE"
exit 1
fi

DRIVER_DYLIB_NAME="libmsodbcsql.${DRIVER_MAJOR}.dylib"

# The universal2 wheel bundles a per-arch copy of the driver dylibs, so every
# bundled arch must be configured, not just the build host's ($(uname -m)).
# install_name_tool and codesign both work cross-arch. Fixing only the host arch
# is what shipped the broken arm64 driver in issue #656.
for ARCH in arm64 x86_64; do
LIB_DIR="$PROJECT_DIR/libs/macos/$ARCH/lib"
LIBMSODBCSQL_PATH="$LIB_DIR/libmsodbcsql.18.dylib"
LIBMSODBCSQL_PATH="$LIB_DIR/$DRIVER_DYLIB_NAME"
LIBMSODBCSQL_NAME="$DRIVER_DYLIB_NAME"
LIBODBCINST_PATH="$LIB_DIR/libodbcinst.2.dylib"
LIBLTDL_PATH="$LIB_DIR/libltdl.7.dylib"

Expand All @@ -23,7 +38,7 @@ if [ ! -d "$LIB_DIR" ]; then
fi

if [ ! -f "$LIBMSODBCSQL_PATH" ]; then
echo "Error: libmsodbcsql.18.dylib not found at: $LIBMSODBCSQL_PATH"
echo "Error: $DRIVER_DYLIB_NAME not found at: $LIBMSODBCSQL_PATH"
exit 1
fi

Expand All @@ -42,7 +57,7 @@ fi
echo "Configuring dylibs in: $LIB_DIR"

# Get the existing library paths which are linked to the dylibs
echo "Reading dependencies from libmsodbcsql.18.dylib..."
echo "Reading dependencies from $LIBMSODBCSQL_NAME..."
OTOOL_LIST=$(otool -L "$LIBMSODBCSQL_PATH")
OLD_LIBODBCINST_PATH=""

Expand All @@ -68,12 +83,12 @@ done <<< "$OTOOL_LIST"

# Configure the library paths if dependencies were found
if [ -n "$OLD_LIBODBCINST_PATH" ]; then
echo "Fixing libmsodbcsql.18.dylib dependency on libodbcinst.2.dylib..."
echo "Fixing $LIBMSODBCSQL_NAME dependency on libodbcinst.2.dylib..."
echo " Changing: $OLD_LIBODBCINST_PATH"
echo " To: @loader_path/libodbcinst.2.dylib"
install_name_tool -change "$OLD_LIBODBCINST_PATH" "@loader_path/libodbcinst.2.dylib" "$LIBMSODBCSQL_PATH"
else
echo "Warning: libodbcinst dependency not found in libmsodbcsql.18.dylib"
echo "Warning: libodbcinst dependency not found in $LIBMSODBCSQL_NAME"
fi

if [ -n "$OLD_LIBLTDL_PATH" ] && [ -f "$LIBLTDL_PATH" ]; then
Expand All @@ -89,8 +104,8 @@ fi

# First set the IDs of the libraries using @loader_path
echo "Setting library IDs with @loader_path..."
echo "Setting ID for libmsodbcsql.18.dylib..."
install_name_tool -id "@loader_path/libmsodbcsql.18.dylib" "$LIBMSODBCSQL_PATH"
echo "Setting ID for $LIBMSODBCSQL_NAME..."
install_name_tool -id "@loader_path/$LIBMSODBCSQL_NAME" "$LIBMSODBCSQL_PATH"

echo "Setting ID for libodbcinst.2.dylib..."
install_name_tool -id "@loader_path/libodbcinst.2.dylib" "$LIBODBCINST_PATH"
Expand All @@ -100,7 +115,7 @@ if [ -f "$LIBLTDL_PATH" ]; then
install_name_tool -id "@loader_path/libltdl.7.dylib" "$LIBLTDL_PATH"
fi

echo "Codesigning libmsodbcsql.18.dylib..."
echo "Codesigning $LIBMSODBCSQL_NAME..."
codesign -s - -f "$LIBMSODBCSQL_PATH" 2>/dev/null

echo "Codesigning libodbcinst.2.dylib..."
Expand Down
Loading
Loading