我正在尝试使用 bazel 为具有 pybind 依赖项的目标生成轮文件。该包本身工作正常(尽管经过测试),但是当我打包它时,
site_packges
文件夹中缺少 .so 文件。
这是我的构建文件:
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@python_pip_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@rules_python//python:packaging.bzl", "py_wheel", "py_package")
# wrapper for so file
py_library(
name = "example",
srcs = ["example.py","__init__.py"],
deps = [
],
data = [":pyexample_inf"],
imports = ["."],
)
# compile pybind cpp
pybind_extension(
name = "pyexample_inf",
srcs = ["pyexample_inf.cpp"],
deps = [],
linkstatic = True,
)
# test wrapper
py_test(
name = "pyexample_test",
srcs = ["tests/pyexample_test.py"],
deps = [
":example",
],
)
# Use py_package to collect all transitive dependencies of a target,
# selecting just the files within a specific python package.
py_package(
name = "pyexample_pkg",
visibility = ["//visibility:private"],
# Only include these Python packages.
deps = [":example"],
)
# using pip, this copies the files to the site_packges, but not the so file
py_wheel(
name = "wheel",
abi = "cp311",
author = "me",
distribution = "example",
license = "Apache 2.0",
platform = select({
"@bazel_tools//src/conditions:linux_x86_64": "linux_x86_64",
}),
python_requires = ">=3.9.0",
python_tag = "cpython",
version = "0.0.1",
deps = [":example"],
)
如何让py_wheel复制so文件?
尝试 deps = [":example.so"]