diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb050caab..9942a6fba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,7 +89,7 @@ jobs: - name: "(vcpkg only) install setuptools" if: ${{ matrix.package_manager == 'vcpkg' }} run: | - pip install setuptools + pip install setuptools wheel - name: Configure CMake run: > diff --git a/cmake/MakePythonWheel.cmake b/cmake/MakePythonWheel.cmake index 8fddd0758..226098796 100644 --- a/cmake/MakePythonWheel.cmake +++ b/cmake/MakePythonWheel.cmake @@ -26,6 +26,23 @@ except ImportError as e: message(FATAL_ERROR "Python module `setuptools` required for correct wheel filename generation.") endif() + execute_process( + COMMAND ${Python3_EXECUTABLE} -c " +import sys +try: + from wheel.bdist_wheel import bdist_wheel + sys.exit(0) +except ImportError as e: + print(f'{e}. Search paths:', file=sys.stderr) + for p in sys.path: print(f' {p}', file=sys.stderr) + sys.exit(1) +" + RESULT_VARIABLE has_bdist_wheel) + + if(has_bdist_wheel EQUAL "1") + message(FATAL_ERROR "Python module `wheel.bdist_wheel` required for correct wheel filename generation.") + endif() + execute_process( COMMAND ${Python3_EXECUTABLE} -c " from setuptools.dist import Distribution @@ -46,9 +63,13 @@ print(wheel_name(name='${python_module}', version='${version}', ext_modules=[Ext " OUTPUT_VARIABLE wheel_filename OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET + RESULT_VARIABLE has_wheel_filename ) + if(NOT has_wheel_filename EQUAL "0") + message(FATAL_ERROR "Cannot format wheel filename via 'setuptools'.") + endif() + set(wheel_filename "${CMAKE_BINARY_DIR}/${wheel_filename}.whl") set(wheel_distinfo "${CMAKE_BINARY_DIR}/${python_module}-${version}.dist-info") set(wheel_data "${CMAKE_BINARY_DIR}/${python_module}-${version}.data")