collect_header_dirs#

scikitplot.cython.collect_header_dirs(*paths, recursive=True, suffixes=None)[source]#

Collect unique directories that contain C/C++ header files.

This complements collect_c_api_sources for Scenario 5: given a source tree, automatically discover all directories containing .h / .hpp headers and return them as an include_dirs list.

Parameters:
*pathsstr or os.PathLike

Root directories or explicit header file paths to search.

recursivebool, default=True

If True, subdirectories are searched recursively.

suffixesfrozenset[str] or None, default=None

Override the set of header suffixes. Default accepts {".h", ".hpp", ".hxx", ".hh"}.

Returns:
list[pathlib.Path]

Deduplicated, sorted, absolute directory paths that contain at least one header file.

Parameters:
Return type:

list[Path]

Notes

Scenario 5d user note:

inc_dirs = collect_header_dirs("include/", "third_party/mylib/")
result = compile_and_load(code, include_dirs=inc_dirs)

Examples

>>> import tempfile, pathlib
>>> with tempfile.TemporaryDirectory() as td:
...     p = pathlib.Path(td)
...     (p / "mylib.h").write_text("#pragma once")
...     dirs = collect_header_dirs(td)
...     len(dirs)
1