Skip to content

Commit 04f7203

Browse files
authored
Match private extension modules against the in-package path only (#2504)
check_cython_abi's private-module filter tested `so_path.parts` on the absolute path, so any ancestor directory starting with an underscore made every module look private. That is the normal layout under manylinux (/opt/_internal/cpython-*/) and in GitHub Actions containers (/__w/), where `generate` then writes zero ABI files and exits 0 -- a green run with no coverage at all. `check`'s new-module scan had no filter, while `generate` skipped private modules. Since `generate` never wrote an .abi.json for them, `check` reported every private module as "New module added" on every run and set has_allowed_changes, so it could not print "No changes found" for a package shipping private submodules (cuda.bindings has _bindings/, _internal/, _lib/). Extract the predicate into iter_public_extension_modules() so both paths use it, and match only on the path relative to the package root.
1 parent 25062e4 commit 04f7203

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

toolshed/check_cython_abi.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ def is_cython_module(module: object) -> bool:
9292
return hasattr(module, "__pyx_capi__")
9393

9494

95+
def iter_public_extension_modules(build_dir: Path):
96+
"""Yield the extension modules under `build_dir` that are part of the public ABI.
97+
98+
Private modules (e.g. cuda/bindings/_internal/utils.so) are skipped. Only the
99+
path *inside* the package is inspected: directories above it routinely start
100+
with an underscore (manylinux installs Python under /opt/_internal, GitHub
101+
Actions containers check out under /__w), and those must not make every
102+
module look private.
103+
"""
104+
for so_path in Path(build_dir).glob(f"**/*{EXT_SUFFIX}"):
105+
if any(part.startswith("_") for part in so_path.relative_to(build_dir).parts):
106+
continue
107+
yield so_path
108+
109+
95110
######################################################################################
96111
# STRUCTS
97112

@@ -473,7 +488,7 @@ def check(package: str, abi_dir: Path) -> bool:
473488
print(f"No module found for {abi_path.relative_to(abi_dir)}")
474489
has_errors = True
475490

476-
for so_path in Path(build_dir).glob(f"**/*{EXT_SUFFIX}"):
491+
for so_path in iter_public_extension_modules(build_dir):
477492
module = import_from_path(package, build_dir, so_path)
478493
if hasattr(module, "__pyx_capi__"):
479494
abi_path = so_path_to_abi_path(so_path, build_dir, abi_dir)
@@ -498,10 +513,7 @@ def generate(package: str, abi_dir: Path) -> bool:
498513
return True
499514

500515
build_dir = get_package_path(package)
501-
for so_path in Path(build_dir).glob(f"**/*{EXT_SUFFIX}"):
502-
if any(x.startswith("_") for x in so_path.parts):
503-
# Skip private modules (e.g. _driver.so) since they are not part of the public ABI
504-
continue
516+
for so_path in iter_public_extension_modules(build_dir):
505517
try:
506518
module = import_from_path(package, build_dir, so_path)
507519
except ImportError:

0 commit comments

Comments
 (0)