From c9fffab6ea0f51cde85ffcaf5675a0d8deeea83e Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 5 Sep 2018 11:19:48 +0100 Subject: [PATCH] remove same-named wheel before shutil.move In https://github.com/adobe-type-tools/afdko/pull/595 we attempt to build a py2.py3 wheel thus the filename of the wheel is the same as the previous ones, and it causes a shutil.Error https://travis-ci.org/adobe-type-tools/afdko/jobs/424691105#L1460 just remove the previous existing file before moving the new one (they'll be identical anyway, or at least they *should*). --- cibuildwheel/macos.py | 7 +++++-- cibuildwheel/windows.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 09db2030..d073ecf7 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -130,5 +130,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be test_command_prepared = prepare_command(test_command, project=abs_project_dir) call(test_command_prepared, cwd=os.environ['HOME'], env=env, shell=True) - # we're all done here; move it to output - shutil.move(delocated_wheel, output_dir) + # we're all done here; move it to output (remove if already exists) + dst = os.path.join(output_dir, os.path.basename(delocated_wheel)) + if os.path.isfile(dst): + os.remove(dst) + shutil.move(delocated_wheel, dst) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 1c2ed1d3..4118bd33 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -101,5 +101,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be test_command_prepared = prepare_command(test_command, project=abs_project_dir) shell([test_command_prepared], cwd='c:\\', env=env) - # we're all done here; move it to output - shutil.move(built_wheel, output_dir) + # we're all done here; move it to output (remove if already exists) + dst = os.path.join(output_dir, os.path.basename(built_wheel)) + if os.path.isfile(dst): + os.remove(dst) + shutil.move(built_wheel, dst)