Skip to content

Commit f7a488d

Browse files
cpcloudclaude
andcommitted
fix(core.utils): lazy-import sqlite3 to avoid libsqlite3 dep at import
sqlite3 was imported at module level, which fails on CI containers that don't have libsqlite3.so.0 installed (e.g., CUDA 12.9.1 test images). Move the import into SQLiteProgramCache.__init__ so the module is loadable even without sqlite3 — only constructing a SQLiteProgramCache requires it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ac38a68 commit f7a488d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

cuda_core/cuda/core/utils/_program_cache.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import hashlib
2222
import os
2323
import pickle
24-
import sqlite3
2524
import tempfile
2625
import time
2726
from pathlib import Path
@@ -336,6 +335,9 @@ def __init__(
336335
self._path = Path(path)
337336
self._path.parent.mkdir(parents=True, exist_ok=True)
338337
self._max_size_bytes = max_size_bytes
338+
import sqlite3
339+
340+
self._sqlite3 = sqlite3
339341
self._conn: Optional[sqlite3.Connection] = None
340342
self._open()
341343

@@ -346,7 +348,7 @@ def _open(self) -> None:
346348
# each statement is its own transaction; ``check_same_thread=False``
347349
# lets a cache be created in one thread and used from another (writes
348350
# are still serialised by sqlite's own lock).
349-
self._conn = sqlite3.connect(
351+
self._conn = self._sqlite3.connect(
350352
self._path,
351353
isolation_level=None,
352354
check_same_thread=False,
@@ -385,7 +387,7 @@ def close(self) -> None:
385387
finally:
386388
self._conn = None
387389

388-
def _require_open(self) -> sqlite3.Connection:
390+
def _require_open(self):
389391
if self._conn is None:
390392
raise RuntimeError("SQLiteProgramCache is closed")
391393
return self._conn

0 commit comments

Comments
 (0)