Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubs to python bindings to provide typing information. #2415

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.