@@ -78,6 +78,11 @@ def build_extension(self, ext: CMakeExtension):
7878 "-DBUILD_PYTHON_BINDINGS=ON" ,
7979 ]
8080
81+ if platform .system () == "Windows" :
82+ cmake_args += [
83+ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{ cfg .upper ()} ={ extdir } "
84+ ]
85+
8186 # Add macOS-specific CMake prefix paths for Homebrew dependencies
8287 if platform .system () == "Darwin" : # macOS
8388 try :
@@ -155,6 +160,33 @@ def build_extension(self, ext: CMakeExtension):
155160 else :
156161 print ("Warning: No TBB shared libraries found to copy." )
157162
163+ elif platform .system () == "Windows" :
164+ print (f"Searching for TBB DLLs in { build_temp } ..." )
165+ # Look for tbb*.dll recursively
166+ tbb_dlls = list (build_temp .glob ("**/tbb*.dll" ))
167+
168+ if tbb_dlls :
169+ print (f"Found TBB DLLs: { tbb_dlls } " )
170+ # We want to copy them to the 'dsf' package directory so we can load them in __init__.py
171+ # extdir is where dsf_cpp.pyd is (site-packages root usually)
172+ # We want site-packages/dsf/
173+
174+ # self.build_lib is usually the root of the build (e.g. build/lib.win...)
175+ # So we can construct the path to dsf package
176+ dsf_pkg_dir = Path (self .build_lib ) / "dsf"
177+ dsf_pkg_dir .mkdir (parents = True , exist_ok = True )
178+
179+ # Also copy to source directory for editable installs
180+ source_dsf_dir = Path (__file__ ).parent / "src" / "dsf"
181+
182+ for dll in tbb_dlls :
183+ print (f"Copying { dll } to { dsf_pkg_dir } " )
184+ shutil .copy2 (dll , dsf_pkg_dir )
185+ print (f"Copying { dll } to { source_dsf_dir } " )
186+ shutil .copy2 (dll , source_dsf_dir )
187+ else :
188+ print ("Warning: No TBB DLLs found. This might cause import errors." )
189+
158190 def pre_build (self ):
159191 """Extracts doxygen documentation from XML files and creates a C++ unordered_map"""
160192
0 commit comments