Skip to content

Commit 0b047c5

Browse files
committed
on windows generate a .dll then copy it
note: internally rules_cc do some stuff when extension is .so or .dll BUT not if it's .pyd see: https://github.com/search?q=repo%3Abazelbuild%2Frules_cc%20.dll&type=code
1 parent ec8dc68 commit 0b047c5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

build_defs.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def pybind_extension(
8484
)
8585

8686
cc_binary(
87-
name = name + ".pyd",
87+
name = name + ".dll",
8888
copts = copts + PYBIND_COPTS + select({
8989
Label("@pybind11//:msvc_compiler"): [],
9090
"//conditions:default": ["-fvisibility=hidden"],
@@ -105,10 +105,18 @@ def pybind_extension(
105105
**kwargs
106106
)
107107

108+
copy_file(
109+
name = name + "_copy_dll_to_pyd",
110+
src = name + ".dll",
111+
out = name + ".pyd",
112+
testonly = kwargs.get("testonly"),
113+
visibility = kwargs.get("visibility"),
114+
)
115+
108116
native.alias(
109117
name = name,
110118
actual = select({
111-
"@platforms//os:windows": name + ".pyd",
119+
"@platforms//os:windows": name + "_copy_dll_to_pyd",
112120
"//conditions:default": name + ".so",
113121
}),
114122
testonly = kwargs.get("testonly"),

0 commit comments

Comments
 (0)