@@ -75,22 +75,40 @@ def pybind_extension(
7575 }),
7676 linkshared = 1 ,
7777 tags = tags ,
78+ target_compatible_with = select ({
79+ "@platform//os:windows" : ["@platforms//:incompatible" ],
80+ "//conditions:default" : [],
81+ }),
7882 deps = deps + PYBIND_DEPS ,
7983 ** kwargs
8084 )
8185
82- copy_file (
83- name = name + "_copy_so_to_pyd" ,
84- src = name + ".so" ,
85- out = name + ".pyd" ,
86- testonly = kwargs .get ("testonly" ),
87- visibility = kwargs .get ("visibility" ),
86+ cc_binary (
87+ name = name + ".pyd" ,
88+ copts = copts + PYBIND_COPTS + select ({
89+ Label ("@pybind11//:msvc_compiler" ): [],
90+ "//conditions:default" : ["-fvisibility=hidden" ],
91+ }),
92+ features = features + PYBIND_FEATURES ,
93+ linkopts = linkopts + select ({
94+ "@platforms//os:osx" : ["-undefined" , "dynamic_lookup" ],
95+ Label ("@pybind11//:msvc_compiler" ): [],
96+ "//conditions:default" : ["-Wl,-Bsymbolic" ],
97+ }),
98+ linkshared = 1 ,
99+ tags = tags ,
100+ target_compatible_with = select ({
101+ "@platform//os:windows" : [],
102+ "//conditions:default" : ["@platforms//:incompatible" ],
103+ }),
104+ deps = deps + PYBIND_DEPS ,
105+ ** kwargs
88106 )
89107
90108 native .alias (
91109 name = name ,
92110 actual = select ({
93- "@platforms//os:windows" : name + "_copy_so_to_pyd " ,
111+ "@platforms//os:windows" : name + ".pyd " ,
94112 "//conditions:default" : name + ".so" ,
95113 }),
96114 testonly = kwargs .get ("testonly" ),
0 commit comments