Replace shutil.move with Path.rename or Path.replace

This commit is contained in:
Yannick Jadoul
2020-06-18 00:23:25 +02:00
parent 265708854a
commit b62b17a223
2 changed files with 4 additions and 8 deletions
+2 -3
View File
@@ -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)
+2 -5
View File
@@ -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)