Skip to content

Commit 181e7cd

Browse files
committed
Add stubs to python bindings to provide typing information.
1 parent ca1494b commit 181e7cd

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ numba
77
numpy==1.26.4
88
numpy-quaternion
99
pillow
10+
pybind11-stubgen
1011
scipy>=1.10.1
1112
tqdm

setup.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ def run(self):
264264
for ext in self.extensions:
265265
self.build_extension(ext)
266266

267+
# Build stubs for 'habitat_sim_bindings' to provide type information.
268+
subprocess.run(
269+
[
270+
"pybind11-stubgen",
271+
"habitat_sim._ext.habitat_sim_bindings",
272+
"-o",
273+
"src_python",
274+
]
275+
)
276+
267277
def build_extension(self, ext):
268278
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
269279

@@ -450,21 +460,28 @@ def load(filename):
450460
setup(
451461
name="habitat_sim",
452462
version=habitat_sim.__version__,
453-
author="FAIR A-STAR",
463+
author="Meta",
454464
description="A high performance simulator for training embodied agents",
455465
long_description="",
456466
packages=find_packages(where="src_python"),
457467
package_dir={"": "src_python"},
458468
install_requires=requirements,
459469
tests_require=["hypothesis", "pytest-benchmark", "pytest"],
470+
setup_requires=["pybind11-stubgen"],
460471
python_requires=">=3.9",
461472
# add extension module
462473
ext_modules=[CMakeExtension("habitat_sim._ext.habitat_sim_bindings", "src")],
463474
# add custom build_ext command
464-
cmdclass=dict(build_ext=CMakeBuild),
475+
cmdclass={
476+
"build_ext": CMakeBuild,
477+
},
465478
zip_safe=False,
466479
include_package_data=True,
480+
package_data={
481+
"habitat_sim": ["py.typed", "**/*.pyi"],
482+
},
467483
)
484+
468485
pymagnum_build_dir = osp.join(
469486
_cmake_build_dir, "deps", "magnum-bindings", "src", "python"
470487
)

src_python/habitat_sim/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)