77import sys
88from datetime import datetime
99from typing import Optional , Callable
10+ from glob import glob
1011
1112import importlib .metadata
1213from packaging .requirements import Requirement
@@ -252,6 +253,14 @@ def layout(self):
252253 self .folders .build = str (self .options .get_safe ("buildFolder" ))
253254
254255 def generate (self ):
256+ if self .settings .os == "Windows" :
257+ # Ensure dependent DLLs are copied into the Basilisk package
258+ # directory inside the build folder so they can be discovered by
259+ # packaging tools (delvewheel) and included in wheels.
260+ basilisk_dst = os .path .join (self .build_folder , "Basilisk" )
261+ for dep in self .dependencies .values ():
262+ for bindir in dep .cpp_info .bindirs :
263+ copy (self , "*.dll" , bindir , basilisk_dst )
255264 if self .settings .os == "Windows" :
256265 for dep in self .dependencies .values ():
257266 for libdir in dep .cpp_info .bindirs :
@@ -309,6 +318,8 @@ def generate(self):
309318 # Set the minimum buildable MacOS version.
310319 # tc.cache_variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.13"
311320 tc .parallel = True
321+ if self .options .get_safe ("pyLimitedAPI" ):
322+ tc .cache_variables ["PY_LIMITED_API" ] = str (self .options .pyLimitedAPI )
312323
313324 # Generate!
314325 tc .generate ()
@@ -329,6 +340,41 @@ def build(self):
329340 cmake .build ()
330341 print ("Total Build Time: " + str (datetime .now () - start ))
331342 print (f"{ statusColor } The Basilisk build is successful and the scripts are ready to run{ endColor } " )
343+ # On Windows, copy project-built DLLs next to the Python extension modules
344+ # so they are bundled in the wheel and resolvable at runtime without PATH tweaks.
345+ if self .settings .os == "Windows" :
346+ basilisk_dst_root = os .path .join (self .build_folder , "Basilisk" )
347+ common_srcs = [
348+ os .path .join (self .build_folder , "bin" ),
349+ os .path .join (self .build_folder , "Release" ),
350+ os .path .join (self .build_folder , "Debug" ),
351+ ]
352+ for src in common_srcs :
353+ if os .path .isdir (src ):
354+ try :
355+ copy (self , "*.dll" , src , basilisk_dst_root )
356+ except Exception as e :
357+ self .output .warning (f"Failed to copy DLLs from { src } : { e } " )
358+
359+ # As a fallback, scan the build tree for any remaining DLLs.
360+ for root , _dirs , files in os .walk (self .build_folder ):
361+ # Skip the destination to avoid self-copy
362+ if os .path .commonpath ([root , basilisk_dst_root ]) == basilisk_dst_root :
363+ continue
364+ if any (f .lower ().endswith (".dll" ) for f in files ):
365+ try :
366+ copy (self , "*.dll" , root , basilisk_dst_root )
367+ except Exception as e :
368+ self .output .warning (f"Failed to copy DLLs from { root } : { e } " )
369+
370+ # Rename DLLs to lowercase
371+ for path in glob (os .path .join (basilisk_dst_root , "*.dll" )):
372+ base = os .path .basename (path )
373+ lower = base .lower ()
374+ if base != lower :
375+ tmp = os .path .join (basilisk_dst_root , f".{ lower } .tmp" )
376+ os .replace (path , tmp )
377+ os .replace (tmp , os .path .join (basilisk_dst_root , lower ))
332378 else :
333379 print (f"{ statusColor } Finished configuring the Basilisk project.{ endColor } " )
334380 if self .settings .os != "Linux" :
0 commit comments