From fdeeb7c710abdc168dba82740876e2e1ffee6722 Mon Sep 17 00:00:00 2001 From: An Long Date: Sun, 2 Aug 2026 03:13:42 +0900 Subject: [PATCH 1/3] fix: derive ggml version from runtime library --- ggml/ggml.py | 10 ++++++---- tests/test_ggml.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ggml/ggml.py b/ggml/ggml.py index ac0f41ec..ad891ece 100644 --- a/ggml/ggml.py +++ b/ggml/ggml.py @@ -306,10 +306,12 @@ def f_(*args: Any, **kwargs: Any): # #define GGML_EXIT_ABORTED 1 GGML_EXIT_ABORTED = 1 -GGML_VERSION_MAJOR = 0 -GGML_VERSION_MINOR = 15 -GGML_VERSION_PATCH = 3 -GGML_VERSION = "0.15.3" +lib.ggml_version.argtypes = [] +lib.ggml_version.restype = ctypes.c_char_p +GGML_VERSION = lib.ggml_version().decode("utf-8") +GGML_VERSION_MAJOR, GGML_VERSION_MINOR, GGML_VERSION_PATCH = ( + int(component) for component in GGML_VERSION.split(".") +) GGML_ROPE_TYPE_NORMAL = 0 GGML_ROPE_TYPE_NEOX = 2 diff --git a/tests/test_ggml.py b/tests/test_ggml.py index 9a6b9d22..c2837a93 100644 --- a/tests/test_ggml.py +++ b/tests/test_ggml.py @@ -7,6 +7,17 @@ import numpy as np +def test_ggml_version_constants_match_runtime_library(): + version = ggml.ggml_version().decode("utf-8") + + assert ggml.GGML_VERSION == version + assert ( + ggml.GGML_VERSION_MAJOR, + ggml.GGML_VERSION_MINOR, + ggml.GGML_VERSION_PATCH, + ) == tuple(int(component) for component in version.split(".")) + + def test_ggml(): assert ggml.GGML_FILE_VERSION == 2 From 7bd90a835e45f651130d384a6b03790aecb1baf8 Mon Sep 17 00:00:00 2001 From: An Long Date: Sun, 2 Aug 2026 03:19:30 +0900 Subject: [PATCH 2/3] fix: restore CI compatibility --- ggml/ggml.py | 7 ++++++- pyproject.toml | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ggml/ggml.py b/ggml/ggml.py index ad891ece..d4d047da 100644 --- a/ggml/ggml.py +++ b/ggml/ggml.py @@ -104,7 +104,12 @@ def load_shared_library(module_name: str, lib_base_name: str): for lib_name in lib_names: try: - with importlib_resources.as_file(importlib_resources.files(module_name).joinpath("lib", lib_name)) as p: # type: ignore + resource = ( + importlib_resources.files(module_name) + .joinpath("lib") + .joinpath(lib_name) + ) + with importlib_resources.as_file(resource) as p: # type: ignore p = cast(pathlib.Path, p) if os.path.exists(p): path = p diff --git a/pyproject.toml b/pyproject.toml index a6bbbbf4..ca5ef16f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,9 @@ testpaths = "tests" target-version = "py38" extend-exclude = ["ggml/contrib/onnx.py", "tests/test_ggml_onnx.py"] +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F"] + [tool.ruff.lint.per-file-ignores] "ggml/__init__.py" = ["F403"] From fd24e51e4135199438a85209f2b7f414b62b48b7 Mon Sep 17 00:00:00 2001 From: An Long Date: Sun, 2 Aug 2026 03:22:03 +0900 Subject: [PATCH 3/3] fix: load local libraries directly --- ggml/ggml.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ggml/ggml.py b/ggml/ggml.py index d4d047da..02033b94 100644 --- a/ggml/ggml.py +++ b/ggml/ggml.py @@ -103,6 +103,11 @@ def load_shared_library(module_name: str, lib_base_name: str): path: Optional[pathlib.Path] = None for lib_name in lib_names: + local_path = base_path / lib_name + if local_path.exists(): + path = local_path + break + try: resource = ( importlib_resources.files(module_name)