106 lines
2.5 KiB
Python
106 lines
2.5 KiB
Python
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
|
load("@rules_python//python:defs.bzl", "py_library")
|
|
load("@py_deps//:requirements.bzl", "requirement")
|
|
load("@rules_python//experimental/python:wheel.bzl", "py_package", "py_wheel")
|
|
load("//:defs.bzl", "anki_version")
|
|
load("//pylib:orjson.bzl", "orjson_if_available")
|
|
|
|
copy_file(
|
|
name = "buildinfo",
|
|
src = "//:buildinfo.txt",
|
|
out = "buildinfo.txt",
|
|
)
|
|
|
|
genrule(
|
|
name = "hooks_gen",
|
|
outs = ["hooks_gen.py"],
|
|
cmd = "$(location //pylib/tools:genhooks) $@",
|
|
tools = ["//pylib/tools:genhooks"],
|
|
)
|
|
|
|
_py_srcs = glob(
|
|
["**/*.py"],
|
|
exclude = [
|
|
"hooks_gen.py",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "anki",
|
|
srcs = _py_srcs,
|
|
data = [
|
|
"py.typed",
|
|
":buildinfo",
|
|
":hooks_gen",
|
|
"//pylib/anki/_backend",
|
|
],
|
|
imports = [
|
|
"..",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
requirement("beautifulsoup4"),
|
|
requirement("decorator"),
|
|
requirement("distro"),
|
|
requirement("protobuf"),
|
|
requirement("requests"),
|
|
requirement("flask"),
|
|
requirement("waitress"),
|
|
requirement("markdown"),
|
|
] + orjson_if_available(),
|
|
)
|
|
|
|
py_package(
|
|
name = "anki_pkg",
|
|
packages = ["pylib.anki"],
|
|
deps = [":anki"],
|
|
)
|
|
|
|
py_wheel(
|
|
name = "wheel",
|
|
abi = "abi3",
|
|
description_file = "wheel_description.txt",
|
|
distribution = "anki",
|
|
extra_requires = {
|
|
"syncserver": [
|
|
"flask",
|
|
"waitress",
|
|
],
|
|
},
|
|
platform = select({
|
|
"//platforms:windows_x86_64": "win_amd64",
|
|
"//platforms:macos_x86_64": "macosx_10_7_x86_64",
|
|
"//platforms:linux_x86_64": "manylinux2014_x86_64",
|
|
"//platforms:linux_arm64": "manylinux2014_aarch64",
|
|
}),
|
|
python_tag = "cp38",
|
|
python_version = ">=3.8",
|
|
requires = [
|
|
"beautifulsoup4",
|
|
"requests[socks]",
|
|
"decorator",
|
|
"protobuf",
|
|
"markdown",
|
|
'orjson; platform_machine == "x86_64"',
|
|
'psutil; sys_platform == "win32"',
|
|
'distro; sys_platform != "darwin" and sys_platform != "win32"',
|
|
],
|
|
strip_path_prefixes = [
|
|
"pylib/",
|
|
],
|
|
tags = ["manual"],
|
|
version = anki_version,
|
|
visibility = ["//visibility:public"],
|
|
deps = [":anki_pkg"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "py_source_files",
|
|
srcs = _py_srcs + [
|
|
"//pylib/anki/_backend:py_source_files",
|
|
],
|
|
visibility = [
|
|
"//pylib:__subpackages__",
|
|
],
|
|
)
|