Skip to content

Commit

Permalink
Add stubs to python bindings to provide typing information.
Browse files Browse the repository at this point in the history
  • Loading branch information
0mdc committed Jun 25, 2024
1 parent ca1494b commit 181e7cd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ numba
numpy==1.26.4
numpy-quaternion
pillow
pybind11-stubgen
scipy>=1.10.1
tqdm
21 changes: 19 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ def run(self):
for ext in self.extensions:
self.build_extension(ext)

# Build stubs for 'habitat_sim_bindings' to provide type information.
subprocess.run(
[
"pybind11-stubgen",
"habitat_sim._ext.habitat_sim_bindings",
"-o",
"src_python",
]
)

def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))

Expand Down Expand Up @@ -450,21 +460,28 @@ def load(filename):
setup(
name="habitat_sim",
version=habitat_sim.__version__,
author="FAIR A-STAR",
author="Meta",
description="A high performance simulator for training embodied agents",
long_description="",
packages=find_packages(where="src_python"),
package_dir={"": "src_python"},
install_requires=requirements,
tests_require=["hypothesis", "pytest-benchmark", "pytest"],
setup_requires=["pybind11-stubgen"],
python_requires=">=3.9",
# add extension module
ext_modules=[CMakeExtension("habitat_sim._ext.habitat_sim_bindings", "src")],
# add custom build_ext command
cmdclass=dict(build_ext=CMakeBuild),
cmdclass={
"build_ext": CMakeBuild,
},
zip_safe=False,
include_package_data=True,
package_data={
"habitat_sim": ["py.typed", "**/*.pyi"],
},
)

pymagnum_build_dir = osp.join(
_cmake_build_dir, "deps", "magnum-bindings", "src", "python"
)
Expand Down
Empty file added src_python/habitat_sim/py.typed
Empty file.

0 comments on commit 181e7cd

Please sign in to comment.