- Notifications
You must be signed in to change notification settings - Fork10
FIX: Use dynamic_lookup for Python Library in macOS#98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
… bewithgaurav/fix_mac_python_lib_linker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR simplifies and standardizes the linking process for Python symbols on macOS by always using the dynamic lookup flag, eliminating conditional logic previously required to link against the Python framework or a Python library.
- Removed conditional branching for library vs. framework linking.
- Always applies the -undefined dynamic_lookup flag to support various Python environments.
Comments suppressed due to low confidence (2)
mssql_python/pybind/CMakeLists.txt:244
- Include a brief note clarifying why eliminating the conditional logic improves compatibility across Python environments to assist future maintainers.
message(STATUS "Using dynamic lookup for Python symbols on macOS (best practice for Python extensions)")
mssql_python/pybind/CMakeLists.txt:245
- Review whether linking against 'dl' (done on the subsequent line) is still required when using dynamic_lookup on macOS, and remove it if redundant.
set_target_properties(ddbc_bindings PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
74037cf
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Summary
This pull request simplifies and standardizes the linking process for Python symbols on macOS in the
mssql_python/pybind/CMakeLists.txt
file. The change ensures compatibility across all Python environments, including virtual environments, by always using dynamic lookup for Python symbols.MacOS-specific changes:
mssql_python/pybind/CMakeLists.txt
: Removed conditional logic for linking against the Python framework or a specific Python library. Instead, the code now always uses the-undefined dynamic_lookup
flag for Python symbols, ensuring better compatibility across Python environments.Issue Reference
FixesAB#37773
Fixes the GH Issue -#99
###Additional context
The root cause is that the C extension binary was built with a hardcoded path to the Python framework at
/Library/Frameworks/Python.framework/Versions/3.13/Python
. This can be verified usingotool -L
on the .so file:The fix is to modify
CMakeLists.txt
to use the-undefined dynamic_lookup
linking approach, which is the recommended practice for Python extensions on macOS. This ensures the extension works regardless of where or how Python is installed.