InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.43k stars 665 forks source link

BUG: Building wrapping for an external module with no `.wrap` files returns a stub file generation failure #3595

Open tbirdso opened 2 years ago

tbirdso commented 2 years ago

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

  1. Create a new external module with no .wrap files
  2. 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

  1. fixing string splitting at https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/Python/itk/pyi_generator.py#L543 so that index_files parses correctly to 0 items when the list of wrapping index files is empty, then
  2. allowing pyi_generator.py to exit with a warning or status message rather than an error when index_files has zero elements. https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/Python/itk/pyi_generator.py#L566
dzenanz commented 2 years ago

Fun, new kind of error 😄