mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00

Will allow importing the Protobuf without pulling in the rest of the library. This is not a full PEP420 namespace, and the wheel still bundles everything - it just makes things easier in a Bazel workspace. I originally tried with PEP420, but it required more invasive changes, and I ran into issues with mypy.
93 lines
1.8 KiB
Text
93 lines
1.8 KiB
Text
load("@rules_python//python:defs.bzl", "py_binary")
|
|
load("@py_deps//:requirements.bzl", "requirement")
|
|
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
|
|
|
py_binary(
|
|
name = "genbackend",
|
|
srcs = [
|
|
"genbackend.py",
|
|
],
|
|
deps = [
|
|
requirement("black"),
|
|
requirement("stringcase"),
|
|
requirement("protobuf"),
|
|
"//pylib/anki:proto",
|
|
],
|
|
)
|
|
|
|
genrule(
|
|
name = "rsbackend_gen",
|
|
outs = ["generated.py"],
|
|
cmd = "$(location genbackend) $@",
|
|
tools = ["genbackend"],
|
|
)
|
|
|
|
py_binary(
|
|
name = "genfluent",
|
|
srcs = [
|
|
"genfluent.py",
|
|
],
|
|
deps = [
|
|
requirement("black"),
|
|
requirement("stringcase"),
|
|
],
|
|
)
|
|
|
|
genrule(
|
|
name = "fluent_gen",
|
|
outs = ["fluent.py"],
|
|
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $@",
|
|
tools = [
|
|
"genfluent",
|
|
"//rslib/i18n:strings.json",
|
|
],
|
|
)
|
|
|
|
copy_file(
|
|
name = "rsbridge_unix",
|
|
src = "//pylib/rsbridge",
|
|
out = "rsbridge.so",
|
|
)
|
|
|
|
copy_file(
|
|
name = "rsbridge_win",
|
|
src = "//pylib/rsbridge",
|
|
out = "rsbridge.pyd",
|
|
)
|
|
|
|
alias(
|
|
name = "rsbridge",
|
|
actual = selects.with_or({
|
|
(
|
|
"@rules_rust//rust/platform:x86_64-pc-windows-msvc",
|
|
): ":rsbridge_win",
|
|
"//conditions:default": ":rsbridge_unix",
|
|
}),
|
|
)
|
|
|
|
_py_srcs = [
|
|
"genbackend.py",
|
|
"__init__.py",
|
|
]
|
|
|
|
# for format check
|
|
filegroup(
|
|
name = "py_source_files",
|
|
srcs = _py_srcs,
|
|
visibility = [
|
|
"//pylib:__subpackages__",
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "_backend",
|
|
srcs = [
|
|
"__init__.py",
|
|
"rsbridge.pyi",
|
|
":fluent_gen",
|
|
":rsbackend_gen",
|
|
":rsbridge",
|
|
],
|
|
visibility = ["//pylib:__subpackages__"],
|
|
)
|