@@ -260,6 +260,51 @@ def test_default_blas_ldflags_no_cxx():
260
260
assert default_blas_ldflags () == ""
261
261
262
262
263
+ @pytest .fixture ()
264
+ def windows_conda_libs (blas_libs ):
265
+ libtemplate = "{lib}.dll"
266
+ libraries = []
267
+ with tempfile .TemporaryDirectory () as d :
268
+ subdir = os .path .join (d , "Library" , "bin" )
269
+ os .makedirs (subdir , exist_ok = True )
270
+ flags = f'-L"{ subdir } "'
271
+ for lib in blas_libs :
272
+ lib_path = os .path .join (subdir , libtemplate .format (lib = lib ))
273
+ with open (lib_path , "wb" ) as f :
274
+ f .write (b"1" )
275
+ libraries .append (lib_path )
276
+ flags += f" -l{ lib } "
277
+ if "gomp" in blas_libs and "mkl_gnu_thread" not in blas_libs :
278
+ flags += " -fopenmp"
279
+ if len (blas_libs ) == 0 :
280
+ flags = ""
281
+ yield d , flags
282
+
283
+
284
+ @patch ("pytensor.link.c.cmodule.std_lib_dirs" , return_value = [])
285
+ @patch ("pytensor.link.c.cmodule.check_mkl_openmp" , return_value = None )
286
+ def test_default_blas_ldflags_conda_windows (
287
+ mock_std_lib_dirs , mock_check_mkl_openmp , windows_conda_libs
288
+ ):
289
+ mock_sys_prefix , expected_blas_ldflags = windows_conda_libs
290
+ mock_process = MagicMock ()
291
+ mock_process .communicate = lambda * args , ** kwargs : (b"" , b"" )
292
+ mock_process .returncode = 0
293
+ with patch ("sys.platform" , "win32" ):
294
+ with patch ("sys.prefix" , mock_sys_prefix ):
295
+ with patch (
296
+ "pytensor.link.c.cmodule.subprocess_Popen" , return_value = mock_process
297
+ ):
298
+ with patch .object (
299
+ pytensor .link .c .cmodule .GCC_compiler ,
300
+ "try_compile_tmp" ,
301
+ return_value = (True , True ),
302
+ ):
303
+ assert set (default_blas_ldflags ().split (" " )) == set (
304
+ expected_blas_ldflags .split (" " )
305
+ )
306
+
307
+
263
308
@patch (
264
309
"os.listdir" , return_value = ["mkl_core.1.dll" , "mkl_rt.1.0.dll" , "mkl_rt.1.1.lib" ]
265
310
)
0 commit comments