Skip to content

Commit 79d6844

Browse files
committed
Test for the creation of an already existing output wheel, and print a helpful warning about building for Python's limited API
1 parent 0de4608 commit 79d6844

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

cibuildwheel/linux.py

+12
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ def build(options: BuildOptions) -> None:
217217
# clean up test environment
218218
docker.call(['rm', '-rf', venv_dir])
219219

220+
existing_output_files = docker.call(['ls'], cwd=container_output_dir).split('\n')
221+
for repaired_wheel in repaired_wheels:
222+
if repaired_wheel.name in existing_output_files:
223+
message = f'Created wheel ({repaired_wheel}) already exists in output directory.'
224+
if 'abi3' in repaired_wheel.name:
225+
message += ('\n'
226+
"It looks like you are created wheels against Python's limited API/stable ABI;\n"
227+
'please limit your Python selection to a single version when building limited API\n'
228+
'wheels, with CIBW_BUILD.')
229+
log.error(message)
230+
sys.exit(1)
231+
220232
# move repaired wheels to output
221233
docker.call(['mkdir', '-p', container_output_dir])
222234
docker.call(['mv', *repaired_wheels, container_output_dir])

cibuildwheel/macos.py

+10
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ def build(options: BuildOptions) -> None:
293293
# clean up
294294
shutil.rmtree(venv_dir)
295295

296+
if (options.output_dir / repaired_wheel.name).exists():
297+
message = f'Created wheel ({repaired_wheel}) already exists in output directory.'
298+
if 'abi3' in repaired_wheel.name:
299+
message += ('\n'
300+
"It looks like you are created wheels against Python's limited API/stable ABI;\n"
301+
'please limit your Python selection to a single version when building limited API\n'
302+
'wheels, with CIBW_BUILD.')
303+
log.error(message)
304+
sys.exit(1)
305+
296306
# we're all done here; move it to output (overwrite existing)
297307
shutil.move(str(repaired_wheel), options.output_dir)
298308
log.build_end()

cibuildwheel/windows.py

+10
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,16 @@ def build(options: BuildOptions) -> None:
323323
# clean up
324324
shutil.rmtree(venv_dir)
325325

326+
if (options.output_dir / repaired_wheel.name).exists():
327+
message = f'Created wheel ({repaired_wheel}) already exists in output directory.'
328+
if 'abi3' in repaired_wheel.name:
329+
message += ('\n'
330+
"It looks like you are created wheels against Python's limited API/stable ABI;\n"
331+
'please limit your Python selection to a single version when building limited API\n'
332+
'wheels, with CIBW_BUILD.')
333+
log.error(message)
334+
sys.exit(1)
335+
326336
# we're all done here; move it to output (remove if already exists)
327337
shutil.move(str(repaired_wheel), options.output_dir)
328338
log.build_end()

0 commit comments

Comments
 (0)