Skip to content

Commit b21a32d

Browse files
committed
Add stubs to python bindings to provide typing information.
1 parent ea34a0e commit b21a32d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ numba
77
numpy==1.26.4
88
numpy-quaternion
99
pillow==10.4.0
10+
pybind11-stubgen
1011
scipy>=1.10.1
1112
tqdm

setup.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ def run(self):
258258
for ext in self.extensions:
259259
self.build_extension(ext)
260260

261+
# Build stubs for 'habitat_sim_bindings' to provide type information.
262+
subprocess.run(
263+
[
264+
"pybind11-stubgen",
265+
"habitat_sim._ext.habitat_sim_bindings",
266+
"-o",
267+
"src_python",
268+
]
269+
)
270+
261271
def build_extension(self, ext):
262272
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
263273

@@ -441,21 +451,28 @@ def load(filename):
441451
setup(
442452
name="habitat_sim",
443453
version=habitat_sim.__version__,
444-
author="FAIR A-STAR",
454+
author="Meta",
445455
description="A high performance simulator for training embodied agents",
446456
long_description="",
447457
packages=find_packages(where="src_python"),
448458
package_dir={"": "src_python"},
449459
install_requires=requirements,
450460
tests_require=["hypothesis", "pytest-benchmark", "pytest"],
461+
setup_requires=["pybind11-stubgen"],
451462
python_requires=">=3.9",
452463
# add extension module
453464
ext_modules=[CMakeExtension("habitat_sim._ext.habitat_sim_bindings", "src")],
454465
# add custom build_ext command
455-
cmdclass=dict(build_ext=CMakeBuild),
466+
cmdclass={
467+
"build_ext": CMakeBuild,
468+
},
456469
zip_safe=False,
457470
include_package_data=True,
471+
package_data={
472+
"habitat_sim": ["py.typed", "**/*.pyi"],
473+
},
458474
)
475+
459476
pymagnum_build_dir = osp.join(
460477
_cmake_build_dir, "deps", "magnum-bindings", "src", "python"
461478
)

src_python/habitat_sim/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)