stub tool
This commit is contained in:
parent
aa741d23da
commit
40dd695cf3
1 changed files with 27 additions and 0 deletions
27
C++/tools/pybind11_auto_pyi.py
Normal file
27
C++/tools/pybind11_auto_pyi.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Derived from code by Aaron.Ma
|
||||||
|
# which was posted here:
|
||||||
|
# https://blog.csdn.net/sinat_40922660/article/details/123850832
|
||||||
|
|
||||||
|
# %%
|
||||||
|
# pip install pybind11-stubgen
|
||||||
|
from pybind11_stubgen import ModuleStubsGenerator # type: ignore
|
||||||
|
import glob
|
||||||
|
|
||||||
|
|
||||||
|
def process(module_name: str) -> None:
|
||||||
|
module = ModuleStubsGenerator(module_name)
|
||||||
|
module.parse()
|
||||||
|
module.write_setup_py = False
|
||||||
|
|
||||||
|
with open(module_name + ".pyi", "w") as fp:
|
||||||
|
fp.write("#\n# AUTOMATICALLY GENERATED FILE, DO NOT EDIT!\n#\n\n")
|
||||||
|
fp.write("\n".join(module.to_lines()))
|
||||||
|
|
||||||
|
|
||||||
|
Files = glob.glob("*.so")
|
||||||
|
|
||||||
|
for fid in Files:
|
||||||
|
Idx: int = fid.find(".")
|
||||||
|
module_name: str = fid[:Idx]
|
||||||
|
print("Processing: " + module_name)
|
||||||
|
process(module_name)
|
Loading…
Reference in a new issue