From 53e7a34e5ce83c48a3e2342caab44c4670c31d80 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 25 Aug 2026 09:34:15 +0300 Subject: [PATCH] fix: import mako lazily to avoid dependency --- pyopencl/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyopencl/tools.py b/pyopencl/tools.py index 421dffa9b..0e0dd4c43 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -167,8 +167,6 @@ import mako import pytest from numpy.typing import DTypeLike, NDArray -else: - import pyopencl._mymako as mako # Do not add a pyopencl import here: This will add an import cycle. @@ -1325,6 +1323,8 @@ class _MakoTextTemplate(_TextTemplate): template: mako.template.Template = field(init=False) def __post_init__(self) -> None: + import pyopencl._mymako as mako + object.__setattr__(self, "template", mako.template.Template(self.txt, strict_undefined=True))