Skip to content

Commit f797db3

Browse files
committed
fix: Address David's code review feedback
- Fix Alpine musl detection with glob fallback for /lib/ld-musl* - Remove shell=True from Windows subprocess call (security) - Fix version duplication - import __version__ from __init__.py - Add OSError handling in build_wheel and build_editable - Sync build_ddbc version to 1.2.0 (matches package)
1 parent 2084bb1 commit f797db3

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

build_ddbc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .compiler import compile_ddbc, get_platform_info
1616

1717
__all__ = ["compile_ddbc", "get_platform_info"]
18-
__version__ = "1.0.0"
18+
__version__ = "1.2.0"

build_ddbc/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import argparse
1212
import sys
1313

14+
from . import __version__
1415
from .compiler import compile_ddbc, get_platform_info
1516

1617

@@ -50,7 +51,7 @@ def main() -> int:
5051
parser.add_argument(
5152
"--version", "-V",
5253
action="version",
53-
version="%(prog)s 1.0.0",
54+
version=f"%(prog)s {__version__}",
5455
)
5556

5657
args = parser.parse_args()

build_ddbc/build_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
7373
except FileNotFoundError:
7474
# If build scripts don't exist, assume pre-compiled binaries
7575
print("[build_backend] Build scripts not found, assuming pre-compiled binaries")
76-
except RuntimeError as e:
76+
except (RuntimeError, OSError) as e:
7777
print(f"[build_backend] Compilation failed: {e}")
7878
raise
7979
else:
@@ -119,7 +119,7 @@ def build_editable(wheel_directory, config_settings=None, metadata_directory=Non
119119
print("[build_backend] Compilation successful!")
120120
except FileNotFoundError:
121121
print("[build_backend] Build scripts not found, assuming pre-compiled binaries")
122-
except RuntimeError as e:
122+
except (RuntimeError, OSError) as e:
123123
print(f"[build_backend] Compilation failed: {e}")
124124
raise
125125

build_ddbc/compiler.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module contains the platform detection and build script execution logic.
55
"""
66

7+
import glob
78
import os
89
import platform
910
import sys
@@ -40,14 +41,16 @@ def get_platform_info() -> Tuple[str, str]:
4041
elif sys.platform.startswith("linux"):
4142
target_arch = os.environ.get("targetArch", platform.machine())
4243
libc_name, _ = platform.libc_ver()
43-
# Empty libc_name could indicate detection failure; default to glibc (manylinux)
44+
4445
if not libc_name:
45-
print(
46-
"[build_ddbc] Warning: libc detection failed (platform.libc_ver() "
47-
"returned an empty name); defaulting to glibc (manylinux) tags.",
48-
file=sys.stderr,
49-
)
50-
is_musl = False
46+
# Fallback: check for musl linker (Alpine Linux)
47+
# platform.libc_ver() returns empty string on Alpine
48+
is_musl = bool(glob.glob("/lib/ld-musl*"))
49+
if not is_musl:
50+
print(
51+
"[build_ddbc] Warning: libc detection failed; defaulting to glibc.",
52+
file=sys.stderr,
53+
)
5154
else:
5255
is_musl = "musl" in libc_name.lower()
5356

@@ -131,7 +134,6 @@ def _run_windows_build(pybind_dir: Path, arch: str, verbose: bool) -> bool:
131134
result = subprocess.run(
132135
cmd,
133136
cwd=pybind_dir,
134-
shell=True,
135137
check=False,
136138
capture_output=not verbose,
137139
)

0 commit comments

Comments
 (0)