From b62b17a223dfce88d35a2301b3aeaab1ade271d1 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Wed, 17 Jun 2020 11:57:16 +0200 Subject: [PATCH] Replace shutil.move with Path.rename or Path.replace --- cibuildwheel/macos.py | 5 ++--- cibuildwheel/windows.py | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 0e24f22d..bd78499d 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -207,7 +207,7 @@ def build(options: BuildOptions) -> None: repaired_wheel_dir.mkdir(parents=True) if built_wheel.name.endswith('none-any.whl') or not options.repair_command: # pure Python wheel or empty repair command - shutil.move(str(built_wheel), repaired_wheel_dir) + built_wheel.rename(repaired_wheel_dir / built_wheel.name) else: repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) call(repair_command_prepared, env=env, shell=True) @@ -257,5 +257,4 @@ def build(options: BuildOptions) -> None: shutil.rmtree(venv_dir) # we're all done here; move it to output (overwrite existing) - dst = options.output_dir / repaired_wheel.name - shutil.move(str(repaired_wheel), dst) + repaired_wheel.replace(options.output_dir / repaired_wheel.name) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index c81566d1..e81fe301 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -193,7 +193,7 @@ def build(options: BuildOptions) -> None: repaired_wheel_dir.mkdir(parents=True) if built_wheel.name.endswith('none-any.whl') or not options.repair_command: # pure Python wheel or empty repair command - shutil.move(str(built_wheel), repaired_wheel_dir) + built_wheel.rename(repaired_wheel_dir / built_wheel.name) else: repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) shell([repair_command_prepared], env=env) @@ -247,7 +247,4 @@ def build(options: BuildOptions) -> None: shutil.rmtree(venv_dir) # we're all done here; move it to output (remove if already exists) - dst = options.output_dir / repaired_wheel.name - if dst.is_file(): - dst.unlink() - shutil.move(str(repaired_wheel), dst) + repaired_wheel.replace(options.output_dir / repaired_wheel.name)