[None][chore] always try-catch when clear build folder in build_wheel.py (#6748)

Signed-off-by: Zhenhua Wang <zhenhuaw@nvidia.com>
This commit is contained in:
Zhenhua Wang 2025-08-11 20:02:17 +08:00 committed by GitHub
parent 5145e9d40e
commit 7e33ed6d61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,13 +68,13 @@ def get_build_dir(build_dir, build_type):
def clear_folder(folder_path):
for item in os.listdir(folder_path):
item_path = os.path.join(folder_path, item)
if os.path.isdir(item_path) and not os.path.islink(item_path):
rmtree(item_path)
else:
try:
try:
if os.path.isdir(item_path) and not os.path.islink(item_path):
rmtree(item_path)
else:
os.remove(item_path)
except (OSError, IOError) as e:
print(f"Failed to remove {item_path}: {e}", file=sys.stderr)
except (OSError, IOError) as e:
print(f"Failed to remove {item_path}: {e}", file=sys.stderr)
def sysconfig_scheme(override_vars=None):