Skip to content

Commit

Permalink
Test for the creation of an already existing output wheel, and print …
Browse files Browse the repository at this point in the history
…a helpful warning about building for Python's limited API
  • Loading branch information
YannickJadoul committed Jan 30, 2021
1 parent 0de4608 commit 73f2b36
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
10 changes: 10 additions & 0 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 73f2b36

Please sign in to comment.