Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
bewithgaurav merged 4 commits intomainfrombewithgaurav/fix_mac_python_lib_linker
Jun 29, 2025

Conversation

bewithgaurav
Copy link
Collaborator

@bewithgauravbewithgaurav commentedJun 24, 2025
edited
Loading

Summary

This pull request simplifies and standardizes the linking process for Python symbols on macOS in themssql_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:

mssql_python/ddbc_bindings.cp313-universal2.so (architecture x86_64):    /Library/Frameworks/Python.framework/Versions/3.13/Python (compatibility version 3.13.0, current version 3.13.0)    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1900.180.0)

The fix is to modifyCMakeLists.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.

@CopilotCopilotAI review requested due to automatic review settingsJune 24, 2025 12:30
Copy link
Contributor

@CopilotCopilotAI left a 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")

@bewithgauravbewithgaurav merged commit74037cf intomainJun 29, 2025
9 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@jahnvi480jahnvi480jahnvi480 approved these changes

@gargsaumyagargsaumyagargsaumya approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Python extension fails on macOS due to hardcoded Python framework path
3 participants
@bewithgaurav@jahnvi480@gargsaumya

[8]ページ先頭

©2009-2025 Movatter.jp