Skip to content

Commit c59bca2

Browse files
committed
Bump pybind
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
1 parent d1ced09 commit c59bca2

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

symforce/pybind/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99

1010
include(FetchContent)
1111

12-
find_package(pybind11 2.9.2 QUIET)
12+
find_package(pybind11 2.13.6 QUIET)
1313
if (NOT pybind11_FOUND)
1414
message(STATUS "pybind11 not found, adding with FetchContent")
1515
# NOTE(brad): Set PYTHON_EXECUTABLE to ensure pybind11 uses the same
1616
# python as the rest of symforce.
1717
set(PYTHON_EXECUTABLE ${SYMFORCE_PYTHON})
1818
FetchContent_Declare(
1919
pybind11
20-
URL https://github.com/pybind/pybind11/archive/v2.9.2.zip
21-
URL_HASH SHA256=d1646e6f70d8a3acb2ddd85ce1ed543b5dd579c68b8fb8e9638282af20edead8
20+
URL https://github.com/pybind/pybind11/archive/v2.13.6.zip
21+
URL_HASH SHA256=d0a116e91f64a4a2d8fb7590c34242df92258a61ec644b79127951e821b47be6
2222
)
2323
FetchContent_MakeAvailable(pybind11)
2424
else()

symforce/test_util/stubs_util.py

+35
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,38 @@ def handle_field(
8080
return result
8181

8282
pybind11_stubgen.parser.mixins.fix.FixMissingNoneHashFieldAnnotation.handle_field = handle_field # type: ignore[method-assign]
83+
84+
85+
def patch_filter_pybind_internals() -> None:
86+
"""
87+
See https://github.com/sizmailov/pybind11-stubgen/pull/243
88+
"""
89+
90+
def handle_class_member(
91+
self: pybind11_stubgen.parser.mixins.filter.FilterPybindInternals,
92+
path: pybind11_stubgen.structs.QualifiedName,
93+
class_: type,
94+
member: T.Any,
95+
) -> T.Union[
96+
pybind11_stubgen.structs.Docstring,
97+
pybind11_stubgen.structs.Alias,
98+
pybind11_stubgen.structs.Class,
99+
T.List[pybind11_stubgen.structs.Method],
100+
pybind11_stubgen.structs.Field,
101+
pybind11_stubgen.structs.Property,
102+
None,
103+
]:
104+
name = path[-1]
105+
if name in self.__class_blacklist:
106+
return None
107+
if name.startswith("__pybind11_module"):
108+
return None
109+
if name.startswith("_pybind11_conduit_v1_"):
110+
return None
111+
return super( # type: ignore[safe-super]
112+
pybind11_stubgen.parser.mixins.filter.FilterPybindInternals, self
113+
).handle_class_member(path, class_, member)
114+
115+
pybind11_stubgen.parser.mixins.filter.FilterPybindInternals.handle_class_member = ( # type: ignore[method-assign]
116+
handle_class_member
117+
)

test/symforce_cc_sym_stubs_codegen_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
from symforce import path_util
1616
from symforce.codegen import format_util
1717
from symforce.test_util import TestCase
18+
from symforce.test_util.stubs_util import patch_filter_pybind_internals
1819
from symforce.test_util.stubs_util import patch_handle_docstring
1920
from symforce.test_util.stubs_util import patch_lcmtype_imports
2021
from symforce.test_util.stubs_util import patch_remove_parameters
2122

2223
patch_lcmtype_imports()
2324
patch_handle_docstring()
2425
patch_remove_parameters()
26+
patch_filter_pybind_internals()
2527

2628

2729
class SymforceCCSymStubsCodegenTest(TestCase):

0 commit comments

Comments
 (0)