collect_c_api_sources#
- scikitplot.cython.collect_c_api_sources(*paths, recursive=True, suffixes=None, exclude_patterns=None)[source]#
Collect C/C++ source files from one or more files, directories, or globs.
This is the primary helper for Scenario 5 (master, own C-API with single/multi files or folder hierarchies).
- Parameters:
- *pathsstr or os.PathLike
One or more of:
A single
.c/.cpp/.cxxfile path.A directory path (all matching sources below it are collected).
A glob pattern (e.g.,
"src/**/*.c").
- recursivebool, default=True
If
True, directories are searched recursively. Ignored for explicit file paths.- suffixesfrozenset[str] or None, default=None
Override the set of accepted suffixes. Default accepts
{".c", ".cc", ".cpp", ".cxx", ".C"}.- exclude_patternssequence of str or None, default=None
Glob-style name patterns to exclude (matched against file names only, not full paths). Example:
["test_*.c", "*_debug.cpp"].
- Returns:
- list[pathlib.Path]
Deduplicated, sorted, absolute paths of matching source files.
- Raises:
- FileNotFoundError
If an explicit file path does not exist.
- ValueError
If an explicit file path has an unsupported suffix.
- Parameters:
- Return type:
Notes
Scenario 5a — single C file:
sources = collect_c_api_sources("mylib.c")
Scenario 5b — multiple files:
sources = collect_c_api_sources("add.c", "mul.c", "div.c")
Scenario 5c — folder with headers ignored automatically:
sources = collect_c_api_sources("src/mylib/")
Scenario 5d — nested folder tree:
sources = collect_c_api_sources("src/", recursive=True)
Examples
>>> import tempfile, pathlib >>> with tempfile.TemporaryDirectory() as td: ... p = pathlib.Path(td) ... _ = (p / "a.c").write_text("int a() { return 1; }") ... _ = (p / "b.cpp").write_text("int b() { return 2; }") ... srcs = collect_c_api_sources(td) ... len(srcs) 2