File 0001-Handle-a-missing-joblib.patch of Package python-tensile

From b75119c7b7e9f8b8f7c5ec1da3b6bd9bc7859eec Mon Sep 17 00:00:00 2001
From: Tom Rix <Tom.Rix@amd.com>
Date: Wed, 26 Feb 2025 04:33:46 -0800
Subject: [PATCH] Handle a missing joblib

Signed-off-by: Tom Rix <Tom.Rix@amd.com>
---
 Tensile/Parallel.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Tensile/Parallel.py b/Tensile/Parallel.py
index 9a7e7b57dc2c..18112f76f80d 100644
--- a/Tensile/Parallel.py
+++ b/Tensile/Parallel.py
@@ -26,11 +26,17 @@ import itertools
 import os
 from typing import Any, Callable
 
-from joblib import Parallel, delayed
+try:
+  import joblib
+except:
+  joblib = None
+
+if joblib != None:
+  from joblib import Parallel, delayed
 
 def CPUThreadCount(enable=True):
   from .Common import globalParameters
-  if not enable:
+  if not enable or joblib == None:
     return 1
   else:
     if os.name == "nt":
@@ -80,7 +86,7 @@ def ParallelMap(function: Callable, objects: Any, message: str="", enable: bool=
     from . import Utils
     threadCount = CPUThreadCount(enable)
     
-    if threadCount <= 1:
+    if threadCount <= 1 or joblib == None:
       return list(map(lambda objs: function(*objs), Utils.tqdm(objects, desc=message)))
         
     inputs = list(zip(objects, itertools.repeat(globalParameters)))
-- 
2.47.1

openSUSE Build Service is sponsored by