@@ -22,7 +22,6 @@ PYBIND_FEATURES = [
2222
2323PYBIND_DEPS = [
2424 Label ("@pybind11//:pybind11" ),
25- "@rules_python//python/cc:current_py_cc_headers" ,
2625]
2726
2827def pybind_extension (
@@ -32,6 +31,7 @@ def pybind_extension(
3231 linkopts = [],
3332 tags = [],
3433 deps = [],
34+ python_headers_target = "@rules_python//python/cc:current_py_cc_headers" ,
3535 ** kwargs ):
3636 """Builds a Python extension module using pybind11.
3737
@@ -42,6 +42,7 @@ def pybind_extension(
4242 linkopts: Linker options for building the module.
4343 tags: Tags for the module.
4444 deps: Dependencies required for building the module.
45+ python_headers_target: The cc_library target that exposes the python C SDK headers
4546 **kwargs: Additional keyword arguments.
4647
4748 This can be directly used in Python with the import statement.
@@ -72,7 +73,7 @@ def pybind_extension(
7273 }),
7374 linkshared = 1 ,
7475 tags = tags ,
75- deps = deps + PYBIND_DEPS ,
76+ deps = deps + PYBIND_DEPS + [ python_headers_target ] ,
7677 ** kwargs
7778 )
7879
@@ -100,6 +101,7 @@ def pybind_library(
100101 features = [],
101102 tags = [],
102103 deps = [],
104+ python_headers_target = "@rules_python//python/cc:current_py_cc_headers" ,
103105 ** kwargs ):
104106 """Builds a pybind11 compatible library. This can be linked to a pybind_extension."""
105107
@@ -111,7 +113,7 @@ def pybind_library(
111113 copts = copts + PYBIND_COPTS ,
112114 features = features + PYBIND_FEATURES ,
113115 tags = tags ,
114- deps = deps + PYBIND_DEPS ,
116+ deps = deps + PYBIND_DEPS + [ python_headers_target ] ,
115117 ** kwargs
116118 )
117119
@@ -121,6 +123,8 @@ def pybind_library_test(
121123 features = [],
122124 tags = [],
123125 deps = [],
126+ python_headers_target = "@rules_python//python/cc:current_py_cc_headers" ,
127+ python_library_target = "@rules_python//python/cc:current_py_cc_libs" ,
124128 ** kwargs ):
125129 """Builds a C++ test for a pybind_library."""
126130
@@ -133,7 +137,8 @@ def pybind_library_test(
133137 features = features + PYBIND_FEATURES ,
134138 tags = tags ,
135139 deps = deps + PYBIND_DEPS + [
136- "@rules_python//python/cc:current_py_cc_libs" ,
140+ python_headers_target ,
141+ python_library_target ,
137142 ],
138143 ** kwargs
139144 )
0 commit comments