File tree Expand file tree Collapse file tree 5 files changed +71
-14
lines changed Expand file tree Collapse file tree 5 files changed +71
-14
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,12 @@ wheel.repair.cross-wheel = false
232232#  A list of external library files that will be bundled in the wheel.
233233wheel.repair.bundle-external  = []
234234
235+ #  Automatically patch every top-level packages/modules to import the dlls on Windows wheels.
236+ wheel.repair.patch-imports  = true 
237+ 
238+ #  The generated file containing any necessary top-level imports.
239+ wheel.repair.imports-file  = " " 
240+ 
235241#  If CMake is less than this value, backport a copy of FindPython.
236242backport.find-python  = " 3.26.1" 
237243
Original file line number Diff line number Diff line change @@ -611,6 +611,18 @@ print(mk_skbuild_docs())
611611     This is an experimental feature gated by :confval:`experimental` 
612612``` 
613613
614+ ``` {eval-rst} 
615+ .. confval:: wheel.repair.imports-file 
616+   :type: ``Path`` 
617+ 
618+   The generated file containing any necessary top-level imports. 
619+ 
620+   This files should be imported as early as possible in all top-level modules and packages. 
621+ 
622+   On Windows wheels, this file contains all ``os.add_dll_directory`` needed in the current wheel. 
623+   On other OS, this is an empty file. 
624+ ``` 
625+ 
614626``` {eval-rst} 
615627.. confval:: wheel.repair.in-wheel 
616628  :type: ``bool`` 
@@ -619,4 +631,14 @@ print(mk_skbuild_docs())
619631  Patch the dynamic links to libraries installed in the current wheel. 
620632``` 
621633
634+ ``` {eval-rst} 
635+ .. confval:: wheel.repair.patch-imports 
636+   :type: ``bool`` 
637+   :default: true 
638+ 
639+   Automatically patch every top-level packages/modules to import the dlls on Windows wheels. 
640+ 
641+   Alternatively, set this to ``false`` and use :confval:`wheel.repair.imports-file` instead. 
642+ ``` 
643+ 
622644<!--  [[[end]]] --> 
Original file line number Diff line number Diff line change @@ -281,17 +281,20 @@ def repair_wheel(self) -> None:
281281            "Patching dll directories: {dll_dirs}" ,
282282            dll_dirs = self .dll_dirs ,
283283        )
284-         # TODO: Not handling namespace packages with this 
285-         for  path  in  platlib .iterdir ():
286-             assert  isinstance (path , Path )
287-             if  path .is_dir ():
288-                 pkg_file  =  path  /  "__init__.py" 
289-                 if  not  pkg_file .exists ():
290-                     logger .debug (
291-                         "Ignoring non-python package: {pkg_file}" ,
292-                         pkg_file = pkg_file ,
293-                     )
294-                     continue 
295-                 self .patch_python_file (pkg_file )
296-             elif  path .suffix  ==  ".py" :
297-                 self .patch_python_file (path )
284+         if  self .settings .wheel .repair .imports_file :
285+             imports_file  =  platlib  /  self .settings .wheel .repair .imports_file 
286+             self .patch_python_file (imports_file )
287+         else :
288+             for  path  in  platlib .iterdir ():
289+                 assert  isinstance (path , Path )
290+                 if  path .is_dir ():
291+                     pkg_file  =  path  /  "__init__.py" 
292+                     if  not  pkg_file .exists ():
293+                         logger .debug (
294+                             "Ignoring non-python package: {pkg_file}" ,
295+                             pkg_file = pkg_file ,
296+                         )
297+                         continue 
298+                     self .patch_python_file (pkg_file )
299+                 elif  path .suffix  ==  ".py" :
300+                     self .patch_python_file (path )
Original file line number Diff line number Diff line change 265265                "type" : " string" 
266266              },
267267              "description" : " A list of external library files that will be bundled in the wheel." 
268+             },
269+             "patch-imports" : {
270+               "type" : " boolean" 
271+               "default" : true ,
272+               "description" : " Automatically patch every top-level packages/modules to import the dlls on Windows wheels." 
273+             },
274+             "imports-file" : {
275+               "type" : " string" 
276+               "description" : " The generated file containing any necessary top-level imports." 
268277            }
269278          },
270279          "description" : " Wheel repair options" 
Original file line number Diff line number Diff line change @@ -256,6 +256,23 @@ class WheelRepair:
256256    build. The bundled libraries are installed under ``site-packages/${name}.libs`` 
257257    """ 
258258
259+     patch_imports : bool  =  True 
260+     """ 
261+     Automatically patch every top-level packages/modules to import the dlls on Windows wheels. 
262+ 
263+     Alternatively, set this to ``false`` and use :confval:`wheel.repair.imports-file` instead. 
264+     """ 
265+ 
266+     imports_file : Optional [Path ] =  None 
267+     """ 
268+     The generated file containing any necessary top-level imports. 
269+ 
270+     This files should be imported as early as possible in all top-level modules and packages. 
271+ 
272+     On Windows wheels, this file contains all ``os.add_dll_directory`` needed in the current wheel. 
273+     On other OS, this is an empty file. 
274+     """ 
275+ 
259276
260277@dataclasses .dataclass  
261278class  WheelSettings :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments