From 73f2b361e03415e746e45e826eee3b2bd3e74740 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 31 Jan 2021 00:07:37 +0100 Subject: [PATCH] Test for the creation of an already existing output wheel, and print a helpful warning about building for Python's limited API --- cibuildwheel/linux.py | 12 ++++++++++++ cibuildwheel/macos.py | 10 ++++++++++ cibuildwheel/windows.py | 10 ++++++++++ 3 files changed, 32 insertions(+) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 13354f439..779657b67 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -217,6 +217,18 @@ def build(options: BuildOptions) -> None: # clean up test environment docker.call(['rm', '-rf', venv_dir]) + existing_output_files = docker.call(['ls'], cwd=container_output_dir).split('\n') + for repaired_wheel in repaired_wheels: + if str(repaired_wheel) in existing_output_files: + message = f'Created wheel ({repaired_wheel}) already exists in output directory.' + if 'abi3' in str(repaired_wheel): + message += ('\n' + "It looks like you are created wheels against Python's limited API/stable ABI;\n" + 'please limit your Python selection to a single version when building limited API\n' + 'wheels, with CIBW_BUILD.') + log.error(message) + sys.exit(1) + # move repaired wheels to output docker.call(['mkdir', '-p', container_output_dir]) docker.call(['mv', *repaired_wheels, container_output_dir]) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index cf6919951..2ca764c59 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -293,6 +293,16 @@ def build(options: BuildOptions) -> None: # clean up shutil.rmtree(venv_dir) + if (options.output_dir / repaired_wheel).exists(): + message = f'Created wheel ({repaired_wheel}) already exists in output directory.' + if 'abi3' in str(repaired_wheel): + message += ('\n' + "It looks like you are created wheels against Python's limited API/stable ABI;\n" + 'please limit your Python selection to a single version when building limited API\n' + 'wheels, with CIBW_BUILD.') + log.error(message) + sys.exit(1) + # we're all done here; move it to output (overwrite existing) shutil.move(str(repaired_wheel), options.output_dir) log.build_end() diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 4d3487ca4..689e891cf 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -323,6 +323,16 @@ def build(options: BuildOptions) -> None: # clean up shutil.rmtree(venv_dir) + if (options.output_dir / repaired_wheel).exists(): + message = f'Created wheel ({repaired_wheel}) already exists in output directory.' + if 'abi3' in str(repaired_wheel): + message += ('\n' + "It looks like you are created wheels against Python's limited API/stable ABI;\n" + 'please limit your Python selection to a single version when building limited API\n' + 'wheels, with CIBW_BUILD.') + log.error(message) + sys.exit(1) + # we're all done here; move it to output (remove if already exists) shutil.move(str(repaired_wheel), options.output_dir) log.build_end()