Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a63d996
FEAT: MacOS Support
bewithgaurav May 23, 2025
d3e1fb1
restoring LICENSING
bewithgaurav May 23, 2025
efc738d
reverting unnecessary changes
bewithgaurav May 23, 2025
afdd03f
reverting back tests
bewithgaurav May 23, 2025
519a99a
cmakelists print lib dirs
bewithgaurav May 23, 2025
1b9575f
merged to main
bewithgaurav May 29, 2025
79b2f68
fixed python lib dir variable
bewithgaurav May 29, 2025
69fa4a7
removed unixodbc altogether and modified readme and setup
bewithgaurav May 29, 2025
59f59d6
restored connection and created a new for MacOS
bewithgaurav May 29, 2025
20577b7
separate windows and mac connections
bewithgaurav May 29, 2025
213ba41
db_connection attrs
bewithgaurav May 29, 2025
3cbf54e
helpers restored
bewithgaurav May 29, 2025
a852242
separated cursor
bewithgaurav May 29, 2025
c936eec
odbc decoding from utf-16 to utf-16-le
bewithgaurav May 29, 2025
2a8adc4
reverted test_exceptions
bewithgaurav May 29, 2025
3650a46
use both Data/ProgrammingError in one exception testcase
bewithgaurav May 29, 2025
4c5c2ce
Merge branch 'main' into bewithgaurav/mac_support
bewithgaurav May 29, 2025
350e1a6
not using separate connection module for macOS
bewithgaurav May 30, 2025
323dbae
include cmake_current_source_dir
bewithgaurav May 30, 2025
81a8529
connection error diff in mac and windows
bewithgaurav May 30, 2025
c88299b
added TODO in code
bewithgaurav May 30, 2025
e9b2f89
fixed merge conflicts
bewithgaurav Jun 2, 2025
5edeb64
removed cursor no_data redundant case
bewithgaurav Jun 2, 2025
f406e4f
Sanitization of connection string before logging
bewithgaurav Jun 2, 2025
1e89686
remove conn str logging in python
bewithgaurav Jun 2, 2025
d4341ff
FIX: Added @loader for DYLIBS
bewithgaurav Jun 2, 2025
6d9b207
fixed bdist_wheel
bewithgaurav Jun 2, 2025
4b4cb71
merged to main
bewithgaurav Jun 2, 2025
b1025b2
fix python libs for python <3.13
bewithgaurav Jun 2, 2025
0921f81
fix python libs for python <3.13
bewithgaurav Jun 2, 2025
8061b14
fix python libs for python <3.13
bewithgaurav Jun 2, 2025
58c57d5
fix python libs for python <3.13
bewithgaurav Jun 2, 2025
71e22d2
fix python lib path for arm64
bewithgaurav Jun 2, 2025
4b548b2
fix python lib path for arm64
bewithgaurav Jun 2, 2025
3ea7ccc
case insensitive search for conn str
bewithgaurav Jun 2, 2025
179bbd7
case insensitive search for conn str
bewithgaurav Jun 2, 2025
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
Binary file modified mssql_python/libs/macos/lib/libltdl.7.dylib
Binary file not shown.
Binary file modified mssql_python/libs/macos/lib/libmsodbcsql.18.dylib
Binary file not shown.
Binary file modified mssql_python/libs/macos/lib/libodbcinst.2.dylib
Binary file not shown.
22 changes: 22 additions & 0 deletions mssql_python/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ else()
message(STATUS "Auto-detected pybind11 include directory: ${PYBIND11_INCLUDE_DIR}")
endif()


# Find Python Library for linking
execute_process(
COMMAND python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"
Expand Down Expand Up @@ -154,8 +155,29 @@ if(APPLE AND (NOT PYTHON_LIB_DIR OR "${PYTHON_LIB_DIR}" STREQUAL ""))
message(STATUS "Python library not found in standard locations, will try using framework")
# When using a framework, we don't specify the library directly
endif()
elseif(WIN32 AND (NOT PYTHON_LIB_DIR OR "${PYTHON_LIB_DIR}" STREQUAL "" OR "${PYTHON_LIB_DIR}" STREQUAL "None"))
# On Windows, if PYTHON_LIB_DIR is not set, we will try to find it using sysconfig
message(STATUS "PYTHON_LIB_DIR is None or empty for Windows, trying to find it using sysconfig")
# Use Python Executable to find the library directory
execute_process(
COMMAND python -c "import sys, os; print(os.path.dirname(sys.executable))"
OUTPUT_VARIABLE PYTHON_EXEC_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Python executable directory: ${PYTHON_EXEC_DIR}")
# Set the library directory based on the executable directory
set(PYTHON_LIB_DIR "${PYTHON_EXEC_DIR}/libs")
message(STATUS "Using Python library directory: ${PYTHON_LIB_DIR}")
endif()

if(DEFINED ENV{CUSTOM_PYTHON_LIB_DIR} AND NOT "$ENV{CUSTOM_PYTHON_LIB_DIR}" STREQUAL "" AND NOT "$ENV{CUSTOM_PYTHON_LIB_DIR}" STREQUAL "None")
message(STATUS "CUSTOM_PYTHON_LIB_DIR is set, using it")
set(PYTHON_LIB_DIR $ENV{CUSTOM_PYTHON_LIB_DIR})
message(STATUS "Using custom Python library directory: ${PYTHON_LIB_DIR}")
endif()

message(STATUS "Final Python library directory: ${PYTHON_LIB_DIR}")

# Determine which source file to use based on platform
if(APPLE)
set(DDBC_SOURCE "ddbc_bindings_mac.cpp")
Expand Down
22 changes: 18 additions & 4 deletions mssql_python/pybind/configure_dylibs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,36 @@ done <<< "$OTOOL_LIST"
if [ -n "$OLD_LIBODBCINST_PATH" ]; then
echo "Fixing libmsodbcsql.18.dylib dependency on libodbcinst.2.dylib..."
echo " Changing: $OLD_LIBODBCINST_PATH"
echo " To: $LIBODBCINST_PATH"
install_name_tool -change "$OLD_LIBODBCINST_PATH" "$LIBODBCINST_PATH" "$LIBMSODBCSQL_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"
fi

if [ -n "$OLD_LIBLTDL_PATH" ] && [ -f "$LIBLTDL_PATH" ]; then
echo "Fixing libodbcinst.2.dylib dependency on libltdl.7.dylib..."
echo " Changing: $OLD_LIBLTDL_PATH"
echo " To: $LIBLTDL_PATH"
install_name_tool -change "$OLD_LIBLTDL_PATH" "$LIBLTDL_PATH" "$LIBODBCINST_PATH"
echo " To: @loader_path/libltdl.7.dylib"
install_name_tool -change "$OLD_LIBLTDL_PATH" "@loader_path/libltdl.7.dylib" "$LIBODBCINST_PATH"
else
echo "Note: libltdl dependency not found or not needed"
fi

# Force codesign the dylibs

# 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 libodbcinst.2.dylib..."
install_name_tool -id "@loader_path/libodbcinst.2.dylib" "$LIBODBCINST_PATH"

if [ -f "$LIBLTDL_PATH" ]; then
echo "Setting ID for libltdl.7.dylib..."
install_name_tool -id "@loader_path/libltdl.7.dylib" "$LIBLTDL_PATH"
fi

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

Expand Down
17 changes: 14 additions & 3 deletions mssql_python/pybind/ddbc_bindings_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,23 +1083,34 @@ ErrorInfo SQLCheckError_Wrap(SQLSMALLINT handleType, intptr_t handle, SQLRETURN
std::wstring SanitizeConnectionString(const std::wstring& connectionString) {
// This function will remove the UID and Pwd parameters for security reasons
std::wstring sanitizedString = connectionString;
// Remove UID and Pwd parameters
size_t uidPos = sanitizedString.find(L"UID=");
std::wstring lowerCaseString = sanitizedString;
// Convert the string to lowercase for case-insensitive search
// Using lowerCaseString to avoid modifying the original string
// This is necessary because towlower works on wide characters
std::transform(lowerCaseString.begin(), lowerCaseString.end(), lowerCaseString.begin(),
::towlower);
// Can be UID or uid or UID, test only on lowercase uid
size_t uidPos = lowerCaseString.find(L"uid=");
if (uidPos != std::wstring::npos) {
size_t endPos = sanitizedString.find(L';', uidPos);
if (endPos != std::wstring::npos) {
sanitizedString.erase(uidPos, endPos - uidPos + 1);
lowerCaseString.erase(uidPos, endPos - uidPos + 1);
} else {
sanitizedString.erase(uidPos);
lowerCaseString.erase(uidPos);
}
}
size_t pwdPos = sanitizedString.find(L"Pwd=");
// Can be Pwd or pwd or PWD, test only on lowercase pwd
size_t pwdPos = lowerCaseString.find(L"pwd=");
if (pwdPos != std::wstring::npos) {
size_t endPos = sanitizedString.find(L';', pwdPos);
if (endPos != std::wstring::npos) {
sanitizedString.erase(pwdPos, endPos - pwdPos + 1);
lowerCaseString.erase(pwdPos, endPos - pwdPos + 1);
} else {
sanitizedString.erase(pwdPos);
lowerCaseString.erase(pwdPos);
}
}
return sanitizedString;
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from setuptools import setup, find_packages
from setuptools.dist import Distribution
from setuptools.command.bdist_wheel import bdist_wheel
from wheel.bdist_wheel import bdist_wheel

# Custom distribution to force platform-specific wheel
class BinaryDistribution(Distribution):
Expand Down