@@ -22,7 +22,6 @@ PYBIND_FEATURES = [
22
22
23
23
PYBIND_DEPS = [
24
24
Label ("@pybind11//:pybind11" ),
25
- "@rules_python//python/cc:current_py_cc_headers" ,
26
25
]
27
26
28
27
def pybind_extension (
@@ -32,6 +31,7 @@ def pybind_extension(
32
31
linkopts = [],
33
32
tags = [],
34
33
deps = [],
34
+ python_headers_target = "@rules_python//python/cc:current_py_cc_headers" ,
35
35
** kwargs ):
36
36
"""Builds a Python extension module using pybind11.
37
37
@@ -42,6 +42,7 @@ def pybind_extension(
42
42
linkopts: Linker options for building the module.
43
43
tags: Tags for the module.
44
44
deps: Dependencies required for building the module.
45
+ python_headers_target: The cc_library target that exposes the python C SDK headers
45
46
**kwargs: Additional keyword arguments.
46
47
47
48
This can be directly used in Python with the import statement.
@@ -72,7 +73,7 @@ def pybind_extension(
72
73
}),
73
74
linkshared = 1 ,
74
75
tags = tags ,
75
- deps = deps + PYBIND_DEPS ,
76
+ deps = deps + PYBIND_DEPS + [ python_headers_target ] ,
76
77
** kwargs
77
78
)
78
79
@@ -100,6 +101,7 @@ def pybind_library(
100
101
features = [],
101
102
tags = [],
102
103
deps = [],
104
+ python_headers_target = "@rules_python//python/cc:current_py_cc_headers" ,
103
105
** kwargs ):
104
106
"""Builds a pybind11 compatible library. This can be linked to a pybind_extension."""
105
107
@@ -111,7 +113,7 @@ def pybind_library(
111
113
copts = copts + PYBIND_COPTS ,
112
114
features = features + PYBIND_FEATURES ,
113
115
tags = tags ,
114
- deps = deps + PYBIND_DEPS ,
116
+ deps = deps + PYBIND_DEPS + [ python_headers_target ] ,
115
117
** kwargs
116
118
)
117
119
@@ -121,6 +123,8 @@ def pybind_library_test(
121
123
features = [],
122
124
tags = [],
123
125
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" ,
124
128
** kwargs ):
125
129
"""Builds a C++ test for a pybind_library."""
126
130
@@ -133,7 +137,8 @@ def pybind_library_test(
133
137
features = features + PYBIND_FEATURES ,
134
138
tags = tags ,
135
139
deps = deps + PYBIND_DEPS + [
136
- "@rules_python//python/cc:current_py_cc_libs" ,
140
+ python_headers_target ,
141
+ python_library_target ,
137
142
],
138
143
** kwargs
139
144
)
0 commit comments