- Generate stubs for extensions based on the Python/C API by analyzing C/C++ source ASTs
- Generate stubs for extensions based on pybind11 by parsing signature strings
We recommend using uv for fast, reproducible environment setup.
# Clone the repository
git clone https://github.com/PCART-tools/PCStubGen.git
cd PCStubGen
# Install system-level dependencies
sudo apt install llvm bear
# Sync the Python environment
uv sync --no-build-isolation-
Build the target project
See the system-level dependencies and notes for some target projects.
uv run pcstubgen build <target-project-directory>
After a successful build, the command outputs the paths to the wheel and
compile_commands.json. -
Install the wheel into the current environment
uv pip install <wheel-path>
-
Generate stubs
uv run pcstubgen gen <target-python-package-name> --compilation-database <compile_commands.json-path>
PCStubGen has been developed and tested on Ubuntu 24.04.2 LTS with Python 3.12 and LLVM 18.
It should work on Linux and macOS. Windows support is currently limited because PCStubGen only supports DWARF symbols, and building target projects on Windows is more challenging.
PCStubGen is licensed under the Apache License 2.0. See LICENSE.txt for details.