From a3aa964cc52433671977bd9ce8f89866761aa2d1 Mon Sep 17 00:00:00 2001 From: Mikael Dallaire Cote <110583667+0mdc@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:03:04 -0400 Subject: [PATCH 1/3] Add stubs to python bindings to provide typing information. --- requirements.txt | 1 + setup.py | 21 +++++++++++++++++++-- src_python/habitat_sim/py.typed | 0 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src_python/habitat_sim/py.typed diff --git a/requirements.txt b/requirements.txt index f6901fc3ab..6316482d4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,6 @@ numba numpy==1.26.4 numpy-quaternion pillow==10.4.0 +pybind11-stubgen scipy>=1.10.1 tqdm diff --git a/setup.py b/setup.py index a4deb8e876..c3d0896d1f 100644 --- a/setup.py +++ b/setup.py @@ -258,6 +258,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))) @@ -441,21 +451,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" ) diff --git a/src_python/habitat_sim/py.typed b/src_python/habitat_sim/py.typed new file mode 100644 index 0000000000..e69de29bb2 From c70299f1b6087fe8cd8b7207c91afd5d7fe1fedc Mon Sep 17 00:00:00 2001 From: Mikael Dallaire Cote <110583667+0mdc@users.noreply.github.com> Date: Sun, 19 Jan 2025 12:11:32 -0500 Subject: [PATCH 2/3] Add pybind11-stubgen dependency to conda build. --- conda-build/habitat-sim/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda-build/habitat-sim/meta.yaml b/conda-build/habitat-sim/meta.yaml index 3eefc5b814..d316a2a1b8 100644 --- a/conda-build/habitat-sim/meta.yaml +++ b/conda-build/habitat-sim/meta.yaml @@ -28,6 +28,7 @@ requirements: - {{ cdt('libpng-devel') }} # [linux] - {{ cdt('xorg-x11-proto-devel') }} # [linux] - {{ cdt('libxxf86vm-devel') }} # [linux] + - pybind11-stubgen host: - python x.x From 6dd1dc03a418ba1e8fd2b7925ed8ca03495e83a1 Mon Sep 17 00:00:00 2001 From: Mikael Dallaire Cote <110583667+0mdc@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:27:23 -0500 Subject: [PATCH 3/3] Move pybind11-stubgen to host requirements. --- conda-build/habitat-sim/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-build/habitat-sim/meta.yaml b/conda-build/habitat-sim/meta.yaml index d316a2a1b8..14c6c9a388 100644 --- a/conda-build/habitat-sim/meta.yaml +++ b/conda-build/habitat-sim/meta.yaml @@ -28,7 +28,6 @@ requirements: - {{ cdt('libpng-devel') }} # [linux] - {{ cdt('xorg-x11-proto-devel') }} # [linux] - {{ cdt('libxxf86vm-devel') }} # [linux] - - pybind11-stubgen host: - python x.x @@ -39,6 +38,7 @@ requirements: - numba - numpy>=1.13 - gitpython + - pybind11-stubgen - quaternion - pillow - scipy>=1.3.0