From 63ace22ac96411579f84f94e9343fab1ca146d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Zim=C3=A1nyi?= Date: Mon, 2 Nov 2026 08:51:58 +0100 Subject: [PATCH] Keep every underscore helper of the generated wrappers out of the exports The package's __all__ lists each function functions.py defines except the helpers the generated wrappers call. The generator recognizes such a helper by its leading underscore, so _check_error, _read_string, _take_string and _take_bytes stay private, and so does any helper the template adds later. Witness: __init__.py lists "_read_string", "_take_string" and "_take_bytes" in __all__, so "from pymeos_cffi import *" binds them. Measured: the generator's export step over functions.py (5049 definitions, four with a leading underscore) writes an __init__.py that differs from the committed one by those three names alone, which this change removes. --- builder/build_pymeos_functions.py | 10 +++------- pymeos_cffi/__init__.py | 3 --- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/builder/build_pymeos_functions.py b/builder/build_pymeos_functions.py index 503dfee..532ef2f 100644 --- a/builder/build_pymeos_functions.py +++ b/builder/build_pymeos_functions.py @@ -59,12 +59,6 @@ def __init__(self, ctype: str, ptype: str, conversion: str | None) -> None: self.conversion = conversion -# List of functions defined in functions.py that shouldn't be exported - -hidden_functions = [ - "_check_error", -] - # List of MEOS functions that should not be defined in functions.py skipped_functions = [ "py_error_handler", @@ -214,7 +208,9 @@ def build_pymeos_functions(idl_path="builder/meos-idl.json", header_path="builde function_text = "" for fn in matches: function_name = fn.group(1) - if function_name in hidden_functions: + # A name with a leading underscore is a helper of the generated wrappers, such + # as _check_error or _take_string, and stays out of the package's exports + if function_name.startswith("_"): continue function_text += f" '{function_name}',\n" functions.append(function_name) diff --git a/pymeos_cffi/__init__.py b/pymeos_cffi/__init__.py index 2db6b03..6ac73d9 100644 --- a/pymeos_cffi/__init__.py +++ b/pymeos_cffi/__init__.py @@ -35,9 +35,6 @@ "SpatialRelation", # Functions "py_error_handler", - "_read_string", - "_take_string", - "_take_bytes", "create_pointer", "get_address", "datetime_to_timestamptz",