Skip to content

Commit 515b673

Browse files
committed
fix: address Copilot review comments
- setup.py: filter find_packages to exclude build_ddbc from wheel - build_backend.py: add _is_truthy() for PEP 517 config_settings boolean coercion - test_001_globals.py: clean up test_windows_x64_detection (remove dead reload/patch)
1 parent ee794b5 commit 515b673

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

build_ddbc/build_backend.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
from .compiler import compile_ddbc
2424

2525

26+
def _is_truthy(value):
27+
"""Convert a config_settings value to a boolean.
28+
29+
PEP 517 frontends pass config_settings values as strings (e.g., "true"),
30+
not Python booleans. This helper normalises them.
31+
"""
32+
if isinstance(value, bool):
33+
return value
34+
if isinstance(value, str):
35+
return value.lower() in ("true", "1", "yes")
36+
return bool(value)
37+
38+
2639
# =============================================================================
2740
# PEP 517 Required Hooks
2841
# =============================================================================
@@ -55,7 +68,7 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
5568
# Check if we should skip compilation (e.g., for sdist-only builds)
5669
skip_compile = False
5770
if config_settings:
58-
skip_compile = config_settings.get("--skip-ddbc-compile", False)
71+
skip_compile = _is_truthy(config_settings.get("--skip-ddbc-compile", False))
5972

6073
if not skip_compile:
6174
# Extract build options from config_settings
@@ -64,7 +77,7 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
6477

6578
if config_settings:
6679
arch = config_settings.get("--arch")
67-
coverage = config_settings.get("--coverage", False)
80+
coverage = _is_truthy(config_settings.get("--coverage", False))
6881

6982
print("[build_backend] Compiling ddbc_bindings...")
7083
try:

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222

2323
from mssql_python.platform_utils import get_platform_info
2424

25-
2625
# =============================================================================
2726
# Platform-Specific Package Discovery
2827
# =============================================================================
2928

3029

3130
def get_platform_packages():
3231
"""Get platform-specific package list."""
33-
packages = find_packages()
32+
packages = find_packages(include=["mssql_python", "mssql_python.*"])
3433
arch, _ = get_platform_info()
3534

3635
if sys.platform.startswith("win"):

tests/test_001_globals.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -781,27 +781,13 @@ def test_get_platform_info_current_platform(self):
781781
def test_windows_x64_detection(self):
782782
"""Test Windows x64 platform detection."""
783783
from unittest.mock import patch
784+
from mssql_python import platform_utils
784785

785-
with (
786-
patch("mssql_python.platform_utils.sys") as mock_sys,
787-
patch("mssql_python.platform_utils.os") as mock_os,
788-
):
789-
mock_sys.platform = "win32"
790-
mock_os.environ.get.return_value = "x64"
791-
792-
from mssql_python import platform_utils
793-
794-
# Force reimport to pick up mocked values
795-
import importlib
796-
797-
importlib.reload(platform_utils)
798-
799-
# Restore for actual test
800-
with patch.object(platform_utils.sys, "platform", "win32"):
801-
with patch.object(platform_utils.os.environ, "get", return_value="x64"):
802-
arch, tag = platform_utils.get_platform_info()
803-
assert arch == "x64"
804-
assert tag == "win_amd64"
786+
with patch.object(platform_utils.sys, "platform", "win32"):
787+
with patch.object(platform_utils.os.environ, "get", return_value="x64"):
788+
arch, tag = platform_utils.get_platform_info()
789+
assert arch == "x64"
790+
assert tag == "win_amd64"
805791

806792
def test_windows_x86_detection(self):
807793
"""Test Windows x86 platform detection."""

0 commit comments

Comments
 (0)