@@ -29,6 +29,14 @@ def make_fake_whl(dll_path : Path):
2929 shutil .rmtree (whl_dir )
3030
3131def patch_whl (out_dir ,libs_dir ):
32+ def copy_libs (src_wheel ):
33+ temp_dir = Path ("patched_whl" )
34+ shutil .unpack_archive (src_wheel , temp_dir , "zip" )
35+ shutil .copytree (Path (temp_dir ) / "dummy.libs" , Path (out_dir ), dirs_exist_ok = True )
36+ if SYSTEM == "Darwin" :
37+ shutil .copytree (Path (temp_dir ) / "dummy.dylibs" , Path (out_dir ), dirs_exist_ok = True )
38+ shutil .rmtree (temp_dir )
39+
3240 # use mangling tool on whl file
3341 # store result dlls in `content/dummy.libs/`
3442 try :
@@ -53,6 +61,9 @@ def patch_whl(out_dir,libs_dir):
5361 "dummy-1.0-py3-none-any.whl"
5462 ]
5563 )
64+ repaired_files = list (Path ("wheelhouse" ).glob ("dummy-*.whl" ))
65+ copy_libs (repaired_files [0 ])
66+ shutil .rmtree ("wheelhouse" )
5667 elif SYSTEM == "Linux" :
5768 sys .path .append (libs_dir ) # to find SO files
5869 # see also: https://github.com/mayeut/pep600_compliance
@@ -65,28 +76,17 @@ def patch_whl(out_dir,libs_dir):
6576 "dummy-1.0-py3-none-any.whl"
6677 ]
6778 )
79+ repaired_files = list (Path ("wheelhouse" ).glob ("dummy-*.whl" ))
80+ copy_libs (repaired_files [0 ])
81+ shutil .rmtree ("wheelhouse" )
6882 elif SYSTEM == "Darwin" :
6983 subprocess .check_call (
7084 ["delocate-wheel" , "-v" , "dummy-1.0-py3-none-any.whl" ]
7185 )
72- # The commands below seem to assume that the new wheel is in the `wheelhouse` directory, move it to match that.
73- os .mkdir ("wheelhouse" )
74- os .rename ("dummy-1.0-py3-none-any.whl" , "wheelhouse/dummy-1.0-py3-none-any.whl" )
86+ copy_libs ("dummy-1.0-py3-none-any.whl" )
7587 except subprocess .CalledProcessError as e :
7688 print (e )
7789 sys .exit (e .returncode )
7890
79- try :
80- # not needed anymore
81- os .remove ("dummy-1.0-py3-none-any.whl" )
82- except OSError :
83- pass # On MacOS we move the original file, so this will not exist.
84-
85- repaired_files = []
86- for repaired_wheel_file in Path ("." ).glob ("wheelhouse/dummy-*.whl" ):
87- repaired_files .append (repaired_wheel_file )
88- shutil .unpack_archive (repaired_files [0 ],"patched_whl" ,"zip" )
89- shutil .copytree (Path ("patched_whl" ) / "dummy.libs/" ,Path (out_dir ))
90- #clean
91- shutil .rmtree ("wheelhouse" )
92- shutil .rmtree ("patched_whl" )
91+ # clean
92+ os .remove ("dummy-1.0-py3-none-any.whl" )
0 commit comments