Skip to content

Commit 6e5e550

Browse files
committed
[https:://nvbugs/5628848][fix] Fix nanobind stub generation
Signed-off-by: Linda-Stadter <57756729+Linda-Stadter@users.noreply.github.com>
1 parent b130d58 commit 6e5e550

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

scripts/build_wheel.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,18 @@ def generate_python_stubs_linux(binding_type: str, venv_python: Path,
395395
try:
396396
if is_nanobind:
397397
build_run(
398-
f"\"{venv_python}\" -m nanobind.stubgen -m bindings -r -O .",
399-
env=env_stub_gen)
398+
f'"{venv_python}" -m nanobind.stubgen -m bindings -r -O bindings',
399+
env=env_stub_gen,
400+
)
401+
# Root stub needs renaming from bindings.pyi to __init__.pyi
402+
bindings_stub = Path("bindings/bindings.pyi")
403+
if bindings_stub.exists():
404+
bindings_stub.rename("bindings/__init__.pyi")
405+
# Remove any conflicting inline stub at root level, which could have been created by old versions, such as 1.1.0
406+
nanobind_stub_artifact = Path("bindings.pyi")
407+
if nanobind_stub_artifact.exists():
408+
nanobind_stub_artifact.unlink()
409+
400410
else:
401411
build_run(
402412
f"\"{venv_python}\" -m pybind11_stubgen -o . bindings --exit-code",

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def has_ext_modules(self):
128128
]
129129

130130
package_data += [
131-
'bindings.pyi',
132131
'bindings/*.pyi',
133132
'tools/plugin_gen/templates/*',
134133
'bench/build/benchmark_config.yml',

0 commit comments

Comments
 (0)