Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cansik/nanobind-stubgen
Generate python stub files for code completion in IDEs for nanobind modules.
https://github.com/cansik/nanobind-stubgen
nanogui python stubgen stubs
Last synced: 19 days ago
JSON representation
Generate python stub files for code completion in IDEs for nanobind modules.
- Host: GitHub
- URL: https://github.com/cansik/nanobind-stubgen
- Owner: cansik
- License: mit
- Created: 2023-03-31T08:29:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-21T23:16:35.000Z (8 months ago)
- Last Synced: 2024-10-03T12:39:46.730Z (about 2 months ago)
- Topics: nanogui, python, stubgen, stubs
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 32
- Watchers: 6
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nanobind-stubgen [![PyPI](https://img.shields.io/pypi/v/nanobind-stubgen)](https://pypi.org/project/nanobind-stubgen/)
⚠️ This project has been archived. Please use the official [nanobind stubgen](https://nanobind.readthedocs.io/en/latest/typing.html#stub-generation).
Generate Python stub files (`pyi`) for code completion in IDEs for [nanobind](https://github.com/wjakob/nanobind) modules.
### Installation
```
pip install nanobind-stubgen
```### Usage
Nanobind stubgen uses the `inspect` module to reverse engineer the module structure and detects nanobind types. The doc
string of the nanobind types contains the function signature, which will be used to create the stub files.To create pyi files for a module, first install the module and call `nanobind-stubgen` with the module name as first argument.
Here is an example on how to generate stubs for [nanogui](https://github.com/mitsuba-renderer/nanogui):```bash
nanobind-stubgen nanogui
```It is possible to change the output path (by default it is the current directory) by specifying the parameter `--out`. To
create the pyi files directly in the nanogui package directory, the following command can be used (note the
changing python version):```bash
nanobind-stubgen nanogui --out venv/lib/python3.9/site-packages
```### Limitations
- The stub generator does not use the nanobind project, but the actual compiled python module. This means, that the generator can only detect module and function information that has been writen into the `__doc__` string by nanobind.
- Only some imports in the pyi files are added
- Method overloading is supported but only to some extent
### Help```bash
positional arguments:
module Module to create stubs (e.g. nanogui).optional arguments:
-h, --help show this help message and exit
--package PACKAGE Optional package path to import module from.
--out OUT Output path for the generated pyi files.
```### About
MIT License