Skip to content

Commit

Permalink
Bump pybind
Browse files Browse the repository at this point in the history
Fixes #425

Our previous version of pybind didn't support py3.11.  pybind 2.13.6
supports all versions of python that we support.  There isn't much
downside to downloading an additional copy of pybind if you have an
older one installed that supports your version of python.  If we wanted
to we could write some table of minimum required versions based on
SYMFORCE_PYTHON's version

Topic: sf-pybind
  • Loading branch information
aaron-skydio committed Feb 24, 2025
1 parent d1ced09 commit c59bca2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
6 changes: 3 additions & 3 deletions symforce/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

include(FetchContent)

find_package(pybind11 2.9.2 QUIET)
find_package(pybind11 2.13.6 QUIET)
if (NOT pybind11_FOUND)
message(STATUS "pybind11 not found, adding with FetchContent")
# NOTE(brad): Set PYTHON_EXECUTABLE to ensure pybind11 uses the same
# python as the rest of symforce.
set(PYTHON_EXECUTABLE ${SYMFORCE_PYTHON})
FetchContent_Declare(
pybind11
URL https://github.com/pybind/pybind11/archive/v2.9.2.zip
URL_HASH SHA256=d1646e6f70d8a3acb2ddd85ce1ed543b5dd579c68b8fb8e9638282af20edead8
URL https://github.com/pybind/pybind11/archive/v2.13.6.zip
URL_HASH SHA256=d0a116e91f64a4a2d8fb7590c34242df92258a61ec644b79127951e821b47be6
)
FetchContent_MakeAvailable(pybind11)
else()
Expand Down
35 changes: 35 additions & 0 deletions symforce/test_util/stubs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,38 @@ def handle_field(
return result

pybind11_stubgen.parser.mixins.fix.FixMissingNoneHashFieldAnnotation.handle_field = handle_field # type: ignore[method-assign]


def patch_filter_pybind_internals() -> None:
"""
See https://github.com/sizmailov/pybind11-stubgen/pull/243
"""

def handle_class_member(
self: pybind11_stubgen.parser.mixins.filter.FilterPybindInternals,
path: pybind11_stubgen.structs.QualifiedName,
class_: type,
member: T.Any,
) -> T.Union[
pybind11_stubgen.structs.Docstring,
pybind11_stubgen.structs.Alias,
pybind11_stubgen.structs.Class,
T.List[pybind11_stubgen.structs.Method],
pybind11_stubgen.structs.Field,
pybind11_stubgen.structs.Property,
None,
]:
name = path[-1]
if name in self.__class_blacklist:
return None
if name.startswith("__pybind11_module"):
return None
if name.startswith("_pybind11_conduit_v1_"):
return None
return super( # type: ignore[safe-super]
pybind11_stubgen.parser.mixins.filter.FilterPybindInternals, self
).handle_class_member(path, class_, member)

pybind11_stubgen.parser.mixins.filter.FilterPybindInternals.handle_class_member = ( # type: ignore[method-assign]
handle_class_member
)
2 changes: 2 additions & 0 deletions test/symforce_cc_sym_stubs_codegen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
from symforce import path_util
from symforce.codegen import format_util
from symforce.test_util import TestCase
from symforce.test_util.stubs_util import patch_filter_pybind_internals
from symforce.test_util.stubs_util import patch_handle_docstring
from symforce.test_util.stubs_util import patch_lcmtype_imports
from symforce.test_util.stubs_util import patch_remove_parameters

patch_lcmtype_imports()
patch_handle_docstring()
patch_remove_parameters()
patch_filter_pybind_internals()


class SymforceCCSymStubsCodegenTest(TestCase):
Expand Down

0 comments on commit c59bca2

Please sign in to comment.