InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

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

Open
#3,595 2 comments 0 reactions 0 assignees View on GitHub
type:Bug
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

### 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

```none
[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
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](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](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/Python/itk/pyi_generator.py#L566)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.