From f9f5530b8d0d2fffe97d9a221a24b3da47191b25 Mon Sep 17 00:00:00 2001 From: Mizux Seiha Date: Tue, 30 Sep 2025 18:22:04 +0200 Subject: [PATCH 1/2] examples: add py_wheel test $ bazel build -c opt ... Computing main repo mapping: Loading: Loading: 0 packages loaded Analyzing: 7 targets (1 packages loaded, 0 targets configured) Analyzing: 7 targets (1 packages loaded, 0 targets configured) ERROR: //examples/basic/BUILD.bazel:11:9: in deps attribute of py_wheel rule //:basic_wheel: alias '//:basic' referring to generated file '//:basic.pyd' is misplaced here (expected no files). Since this rule was created by the macro 'py_wheel', the error might have been caused by the macro implementation ERROR: //examples/basic/BUILD.bazel:11:9: Analysis of target '//:basic_wheel' (config: 307b5b1) failed Use --verbose_failures to see the command lines of failed build steps. ERROR: Analysis of target '//:basic_wheel' failed; build aborted INFO: Elapsed time: 0.334s, Critical Path: 0.02s INFO: 1 process: 1 internal. ERROR: Build did NOT complete successfully --- examples/basic/BUILD.bazel | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/basic/BUILD.bazel b/examples/basic/BUILD.bazel index 797bf56..2846923 100644 --- a/examples/basic/BUILD.bazel +++ b/examples/basic/BUILD.bazel @@ -1,18 +1,35 @@ load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") load("@rules_python//python:py_library.bzl", "py_library") load("@rules_python//python:py_test.bzl", "py_test") +load("@rules_python//python:packaging.bzl", "py_wheel") pybind_extension( name = "basic", srcs = ["basic.cpp"], ) +py_wheel( + name = "basic_wheel", + testonly = True, + distribution = "basic", + version = "1.0.0", + deps = [":basic"], +) + py_library( name = "basic_lib", data = [":basic"], imports = ["."], ) +py_wheel( + name = "basic_lib_wheel", + testonly = True, + distribution = "basic_lib", + version = "1.0.0", + deps = [":basic_lib"], +) + py_test( name = "basic_test", srcs = ["basic_test.py"], From 5154c10d0a51e1ab84dd95afdd5686d801e48ae9 Mon Sep 17 00:00:00 2001 From: Mizux Seiha Date: Tue, 30 Sep 2025 19:05:08 +0200 Subject: [PATCH 2/2] fix py_wheel support on windows --- build_defs.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_defs.bzl b/build_defs.bzl index 5c88f1c..bf740c6 100644 --- a/build_defs.bzl +++ b/build_defs.bzl @@ -87,7 +87,7 @@ def pybind_extension( native.alias( name = name, actual = select({ - "@platforms//os:windows": name + ".pyd", + "@platforms//os:windows": name + "_copy_so_to_pyd", "//conditions:default": name + ".so", }), testonly = kwargs.get("testonly"),