ITK
ITK copied to clipboard
BUG: Building wrapping for an external module with no `.wrap` files returns a stub file generation failure
Description
Before .wrap files were added to ITKCLEsperanto the error trace below was observed in Python CI at build time.
This is a low-severity issue as it is not typical that developers would try to build wrappings for a module defining no wrappings. However, it is not obvious from the index file is missing warning that the cause is that wrappings are built with no wrapping files present.
Steps to Reproduce
- Create a new external module with no
.wrapfiles - Attempt to build with Python wrappings turned on
Expected behavior
Build succeeds with no errors (do-nothing) OR fails with error clearly stating that at least one .wrap file must be present for wrapping to succeed.
Actual behavior
[4/111] Generating .pyi files for Python wrapper interface
FAILED: Wrapping/CMakeFiles/itk-stub-files C:/P/IPP/ITK-win_37-x64/Wrapping/Generators/Python/itk-stubs/_proxies.pyi C:/P/IPP/ITK-win_37-x64/Wrapping/Generators/Python/itk-stubs/__init__.pyi D:/a/im/_skbuild/win-amd64-3.7/cmake-build/Wrapping/CMakeFiles/itk-stub-files
cmd.exe /C "cd /D D:\a\im\_skbuild\win-amd64-3.7\cmake-build\Wrapping && C:\P\IPP\venv-37-x64\Scripts\python.exe C:/P/IPP/ITK-source/ITK/Wrapping/Generators/Python/itk/pyi_generator.py --pyi_dir C:/P/IPP/ITK-win_37-x64/Wrapping/Generators/Python/itk-stubs --pkl_dir C:/P/IPP/ITK-win_37-x64/Wrapping/Generators/Python/itk-pkl --index_list_file D:/a/im/_skbuild/win-amd64-3.7/cmake-build/Wrapping/GlobalIdxFilesList.txt"
WARNING: index file is missing, Python stub hints will not be generated for this file.
Exception: No index files were found in directory 'C:/P/IPP/ITK-win_37-x64/Wrapping/Generators/Python/itk-pkl'
Traceback (most recent call last):
File "C:/P/IPP/ITK-source/ITK/Wrapping/Generators/Python/itk/pyi_generator.py", line 569, in <module>
raise Exception(except_comment)
Exception: No index files were found in directory 'C:/P/IPP/ITK-win_37-x64/Wrapping/Generators/Python/itk-pkl'
Reproducibility
100%
Versions
v5.3rc04.post2 tag
Environment
CMake 3.22.3 Visual Studio 2022 Windows 10
Additional Information
The issue may be sufficiently resolved by
- fixing string splitting at https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/Python/itk/pyi_generator.py#L543 so that
index_filesparses correctly to 0 items when the list of wrapping index files is empty, then - allowing
pyi_generator.pyto exit with a warning or status message rather than an error whenindex_fileshas zero elements. https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/Python/itk/pyi_generator.py#L566
Fun, new kind of error 😄