You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
REFACTOR: Shift get_driver_path from Python to DDBC bindings with tests (#168)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#38102](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/38102)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request refactors the ODBC driver path resolution logic to be
implemented entirely in C++ instead of Python. The main motivation is to
eliminate a circular import issue that caused failures on Alpine Linux
due to musl libc's stricter dynamic loading rules. The Python helper and
its associated test have been removed, and equivalent logic is now
handled in C++. The test suite has been updated to validate the new
C++-based resolution.
Refactor: Move driver path resolution to C++
* Removed the `get_driver_path` function from `mssql_python/helpers.py`,
eliminating Python-based driver path resolution.
* Implemented `GetDriverPathCpp` in
`mssql_python/pybind/ddbc_bindings.cpp` to handle all platform and
architecture-specific ODBC driver path resolution in C++. This avoids
Python dependencies during module initialization and resolves the Alpine
Linux circular import issue.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L640-R713)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L665-R729)
* Updated the C++ Python bindings to expose `GetDriverPathCpp` instead
of the removed Python function.
Testing updates
* Removed tests for the old Python helper and added a new test to
validate the C++ `GetDriverPathCpp` function against expected driver
paths derived in Python.
[[1]](diffhunk://#diff-e489a2a29f29954dcd0b17a34b15e53ee2aa4fa1def0a5a466bcee81df59ddf0L318-L332)
[[2]](diffhunk://#diff-e489a2a29f29954dcd0b17a34b15e53ee2aa4fa1def0a5a466bcee81df59ddf0R364-R380)
* Added helper imports and a method to compute the expected driver path
in the test suite for accurate cross-validation.
[[1]](diffhunk://#diff-e489a2a29f29954dcd0b17a34b15e53ee2aa4fa1def0a5a466bcee81df59ddf0R12-R14)
[[2]](diffhunk://#diff-e489a2a29f29954dcd0b17a34b15e53ee2aa4fa1def0a5a466bcee81df59ddf0R170-L168)
<!--
### PR Title Guide
> For feature requests
FEAT: (short-description)
> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description)
> For Fix requests
FIX: (short-description)
> For doc update requests
DOC: (short-description)
> For Formatting, indentation, or styling update
STYLE: (short-description)
> For Refactor, without any feature changes
REFACTOR: (short-description)
> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description)
### Contribution Guidelines
External contributors:
- Create a GitHub issue first:
https://github.com/microsoft/mssql-python/issues/new
- Link the GitHub issue in the "GitHub Issue" section above
- Follow the PR title format and provide a meaningful summary
mssql-python maintainers:
- Create an ADO Work Item following internal processes
- Link the ADO Work Item in the "ADO Work Item" section above
- Follow the PR title format and provide a meaningful summary
-->
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0 commit comments