@@ -65,7 +65,7 @@ def remove_extension(core, *args):
6565 tracer.*.pyd
6666 """ .split ()
6767
68- if 1 : # "--from-install" in args:
68+ if "--from-install" in args :
6969 # Get the install location using a subprocess to avoid
7070 # locking the file we are about to delete
7171 root = os .path .dirname (
@@ -88,19 +88,30 @@ def remove_extension(core, *args):
8888 ".tox/*/[Ll]ib/site-packages/coverage" ,
8989 ]
9090
91+ # On windows at least, we can't delete a loaded .pyd file. So move them
92+ # out of the way into the tmp/ directory.
93+ os .makedirs ("tmp" , exist_ok = True )
9194 for root , pattern in itertools .product (roots , so_patterns ):
9295 pattern = os .path .join (root , pattern )
9396 if VERBOSITY > 1 :
9497 print (f"Searching for { pattern } from { os .getcwd ()} " )
9598 for filename in glob .glob (pattern ):
9699 if os .path .exists (filename ):
100+ hidden = f"tmp/{ os .path .basename (filename )} "
97101 if VERBOSITY > 1 :
98- print (f"Removing { os . path . abspath ( filename ) } " )
102+ print (f"Moving { filename } to { hidden } " )
99103 try :
100- os .remove (filename )
104+ if os .path .exists (hidden ):
105+ os .remove (hidden )
101106 except OSError as exc :
102107 if VERBOSITY > 1 :
103- print (f"Couldn't remove { os .path .abspath (filename )} : { exc } " )
108+ print (f"Couldn't remove { hidden } : { exc } " )
109+ else :
110+ try :
111+ os .rename (filename , hidden )
112+ except OSError as exc :
113+ if VERBOSITY > 1 :
114+ print (f"Couldn't rename: { exc } " )
104115
105116
106117def label_for_core (core ):
0 commit comments