Skip to content

FEAT: macOS support #96

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed

FEAT: macOS support #96

wants to merge 17 commits into from

Conversation

gargsaumya
Copy link
Contributor

This pull request includes significant changes to streamline the pipeline configuration and implement macOS-specific functionality for the MSSQL Python bindings. The most important changes involve removing redundant pipeline jobs, adding macOS-specific logic for handling SQLWCHAR strings, and introducing platform-agnostic code for driver handling.

Pipeline Configuration Updates:

  • Removed the PytestOnWindows job and its associated steps, including Python installation, LocalDB setup, test execution, and artifact publishing. This simplifies the pipeline and reduces redundancy.
  • Removed commented-out steps related to Colima-based Docker setup and SQL Server container initialization in the macOS job. These steps were unused and unnecessary.
  • Removed tasks for publishing test results and code coverage from the macOS job, aligning it with the streamlined pipeline approach.

macOS-Specific Enhancements:

  • Added macOS-specific logic for handling SQLWCHAR strings in connection.cpp, including buffer creation and null-termination to ensure compatibility with the ODBC driver.
  • Introduced macOS-specific headers and helper functions for string conversion in ddbc_bindings.h. These changes address differences in Unicode encoding between macOS and other platforms. [1] [2]

Platform-Agnostic Improvements:

  • Defined a platform-agnostic type for the driver handle (DriverHandle) and implemented a cross-platform function (GetFunctionPointer) to resolve function pointers from libraries. This ensures compatibility across Windows and macOS.
  • Modified the CMakeLists.txt file to comment out the macOS-specific source file block, indicating that only the standard source file is currently used.

Miscellaneous Updates:

  • Relaxed the MSVC warning level flags by removing the /WX option, which treats warnings as errors, to avoid build failures during development.

Checklist

  • Tests Passed (if applicable)

@Copilot Copilot AI review requested due to automatic review settings June 23, 2025 04:31
Copy link
Contributor

@Copilot Copilot AI 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 adds macOS support by streamlining the CI pipeline and introducing macOS‐specific logic for handling SQLWCHAR strings in the MSSQL Python bindings. Key changes include updating header and source files with macOS-specific string conversion helpers, implementing a platform-agnostic driver handle and function pointer retrieval, and simplifying the CI pipeline by removing redundant Windows jobs and unused steps.

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.

File Description
mssql_python/pybind/ddbc_bindings.h Added macOS-specific headers, string conversion helper functions, and API changes.
mssql_python/pybind/connection/connection.cpp Introduced macOS-specific connection string handling using a local buffer.
mssql_python/pybind/CMakeLists.txt Updated the source file selection and removed the /WX flag from MSVC build options.
eng/pipelines/pr-validation-pipeline.yml Removed unnecessary Windows-specific jobs and commented code for a streamlined macOS job.
Comments suppressed due to low confidence (1)

eng/pipelines/pr-validation-pipeline.yml:9

  • Review and remove any obsolete commented-out steps and jobs from the pipeline configuration to reduce noise and potential confusion.
jobs:

Comment on lines 182 to 194
# if(APPLE)
# set(DDBC_SOURCE "ddbc_bindings_mac.cpp")
# message(STATUS "Using macOS-specific source file: ${DDBC_SOURCE}")
# # Only ddbc_bindings_mac.cpp is used on macOS
# # TODO: Implement smart pointer in macOS
# add_library(ddbc_bindings MODULE ${DDBC_SOURCE})
# else()
# This is just windows block
set(DDBC_SOURCE "ddbc_bindings.cpp")
message(STATUS "Using standard source file: ${DDBC_SOURCE}")
# Include connection module for Windows
add_library(ddbc_bindings MODULE ${DDBC_SOURCE} connection/connection.cpp connection/connection_pool.cpp)
endif()
set(DDBC_SOURCE "ddbc_bindings.cpp")
message(STATUS "Using standard source file: ${DDBC_SOURCE}")
# Include connection module for Windows
add_library(ddbc_bindings MODULE ${DDBC_SOURCE} connection/connection.cpp connection/connection_pool.cpp)
# endif()
Copy link
Preview

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the commented-out macOS-specific source file block if it is no longer needed to improve clarity and maintainability.

Copilot uses AI. Check for mistakes.

@gargsaumya gargsaumya force-pushed the saumya/mac branch 7 times, most recently from 1d8dc8c to 34bd339 Compare June 23, 2025 07:37
@gargsaumya gargsaumya force-pushed the saumya/mac branch 8 times, most recently from 9c3a89c to bd8b56c Compare June 23, 2025 11:18
@gargsaumya gargsaumya force-pushed the saumya/mac branch 2 times, most recently from 8072499 to 6380f4a Compare June 23, 2025 11:28
fs::path primaryPath = fs::path(moduleDir) / "libs" / "macos" / runtimeArch / "lib" / "libmsodbcsql.18.dylib";
if (fs::exists(primaryPath)) {
driverPath = primaryPath;
LOG("macOS driver found at: {}", driverPath.string());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am facing an issue w.r.t stdout logs while running main.py normally, if you see main.py sends out all these logs from ddbc bindings to stdout
I noticed that these logs are not showing up while we run main, actually raising this since I'm working on top of this branch for linux and got an issue with logs even in linux. checked macOS logs in latest pipeline run of this branch, and looks like they're not there - https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=118869&view=logs&j=bee890e9-c040-5cc9-d6a5-bdcb2ba73021&t=e9a69565-b417-5aac-952f-906672102243

Copy link
Contributor Author

@gargsaumya gargsaumya Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried printing these directly to stdout. I have seen this issue with logger since quite sometime now, even on windows and I think we also have a work item related to this.

@bewithgaurav
Copy link
Collaborator

bewithgaurav commented Jun 27, 2025

merging main here for comparison purposes with the linux PR #110

@gargsaumya
Copy link
Contributor Author

Closing this PR. The mac support has been merged as part of following PRs:
#101
#102
#103

@gargsaumya gargsaumya closed this Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants