Skip to content

Commit

Permalink
Use sysconfig.get_config_var('EXT_SUFFIX') in `intel/backend/driver…
Browse files Browse the repository at this point in the history
….py` (#2637)

Part of #2478

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Nov 6, 2024
1 parent ee9dc3a commit 133e266
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions third_party/intel/backend/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import hashlib
import shutil
import sysconfig
import tempfile
from pathlib import Path
from functools import cached_property
Expand Down Expand Up @@ -115,7 +116,8 @@ def libsycl_dir(self) -> Optional[str]:
def compile_module_from_src(src, name):
key = hashlib.sha256(src.encode("utf-8")).hexdigest()
cache = get_cache_manager(key)
cache_path = cache.get_file(f"{name}.so")
file_name = f"{name}.{sysconfig.get_config_var('EXT_SUFFIX').split('.')[-1]}"
cache_path = cache.get_file(file_name)
if cache_path is None:
with tempfile.TemporaryDirectory() as tmpdir:
src_path = os.path.join(tmpdir, "main.cpp")
Expand All @@ -127,7 +129,7 @@ def compile_module_from_src(src, name):
so = _build(name, src_path, tmpdir, compilation_helper.library_dir, compilation_helper.include_dir,
compilation_helper.libraries, extra_compile_args=extra_compiler_args)
with open(so, "rb") as f:
cache_path = cache.put(f.read(), f"{name}.so", binary=True)
cache_path = cache.put(f.read(), file_name, binary=True)
import importlib.util
spec = importlib.util.spec_from_file_location(name, cache_path)
mod = importlib.util.module_from_spec(spec)
Expand Down

0 comments on commit 133e266

Please sign in to comment.