forked from aarnphm/whispercpp
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
168 lines (154 loc) · 4.49 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
load("@rules_python//python:versions.bzl", "gen_python_config_settings")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_python//python:packaging.bzl", "py_wheel")
load("@com_github_bentoml_plugins//rules/py:packaging.bzl", "py_package")
load("@python_abi//:abi.bzl", "python_abi")
package(default_visibility = ["//visibility:public"])
gen_python_config_settings()
filegroup(
name = "pyproject",
srcs = ["pyproject.toml"],
)
exports_files([
"LICENSE",
"README.md",
"README.rst",
])
buildifier(
name = "buildifier",
)
COPTS = [
"-O3",
"-pthread",
"-std=c++11",
"-fPIC",
"-Wall",
] + selects.with_or({
"//conditions:default": [],
"@bazel_tools//src/conditions:linux_x86_64": [
"-mavx",
"-mavx2",
"-mfma",
"-mf16c",
"-msse3",
],
})
cc_library(
name = "context",
srcs = [
"//src/whispercpp:context.cc",
"//src/whispercpp:context.h",
],
hdrs = [
"//src/whispercpp:context.h",
"@com_github_ggerganov_whisper//:whisper.h",
],
copts = COPTS,
defines = ["BAZEL_BUILD"],
deps = [
"@com_github_ggerganov_whisper//:whisper",
"@pybind11",
],
)
pybind_extension(
name = "api",
srcs = [
"//src/whispercpp:api_export.cc",
"//src/whispercpp:api_export.h",
"//src/whispercpp:context.h",
"@com_github_ggerganov_whisper//:examples/common.h",
"@com_github_ggerganov_whisper//:whisper.h",
],
copts = COPTS,
defines = ["BAZEL_BUILD"],
deps = [
":context",
"@com_github_ggerganov_whisper//:common",
],
)
write_file(
name = "gen_extensions",
out = "extensions.sh",
content = [
"#!/usr/bin/env bash",
"cd $BUILD_WORKSPACE_DIRECTORY",
"cp -fv bazel-bin/api.so src/whispercpp/api.so",
],
)
sh_binary(
name = "extensions",
srcs = [":gen_extensions"],
data = [":api.so"],
)
# public exports
alias(
name = "whispercpp_lib",
actual = "//src/whispercpp:whispercpp_lib",
)
py_package(
name = "whispercpp_pkg",
layout = "src",
packages = ["src.whispercpp"],
deps = [":whispercpp_lib"],
)
config_setting(
name = "ci",
values = {
"define": "ci=true",
"compilation_mode": "dbg",
},
)
py_wheel(
name = "whispercpp_wheel",
abi = python_abi(),
author = "Aaron Pham",
author_email = "aarnphm@bentoml.com",
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: C++",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
],
description_file = "README.rst",
distribution = "whispercpp",
homepage = "https://github.com/aarnphm/whispercpp",
license = "Apache 2.0",
platform = select({
"//:aarch64-apple-darwin": "macosx_11_0_arm64",
"//:aarch64-unknown-linux-gnu": "manylinux2014_aarch64",
"//:x86_64-apple-darwin": "macosx_11_0_x86_64", # this is typically macosx_10_9_x86_64?
"//:x86_64-pc-windows-msvc": "win_amd64",
"//:x86_64-unknown-linux-gnu": "manylinux2014_x86_64",
}),
python_tag = python_abi(),
strip_path_prefixes = ["src"],
twine = "@pypi_twine//:pkg",
# NOTE: This can be replaced by building with --stamp --embed_label=1.2.3
version = select({
"//conditions:default": "0.0.9.dev0",
":ci": "{BUILD_EMBED_LABEL}",
}),
visibility = ["//:__subpackages__"],
deps = [
":api.so",
":whispercpp_pkg",
],
)