-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMODULE.bazel
More file actions
390 lines (331 loc) · 11.6 KB
/
MODULE.bazel
File metadata and controls
390 lines (331 loc) · 11.6 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Define a constant for the base image URL
BASE_DISTROLESS_IMAGE_URL = "nvcr.io/nvidia/distroless/"
BASE_IMAGE_URL = "nvcr.io/nvidia/osmo/"
IMAGE_TAG = ""
################
# Workspace #
################
# This needs to be defined before any other rules.
module(
name = "osmo_workspace",
)
################
# Repo Rules #
################
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
################
# Bazelisk #
################
http_file(
name = "bazelisk_linux_amd64",
executable = True,
sha256 = "e1508323f347ad1465a887bc5d2bfb91cffc232d11e8e997b623227c6b32fb76",
urls = ["https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-amd64"],
)
http_file(
name = "bazelisk_linux_arm64",
executable = True,
sha256 = "bb608519a440d45d10304eb684a73a2b6bb7699c5b0e5434361661b25f113a5d",
urls = ["https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-arm64"],
)
osmo_constants = use_repo_rule("//bzl:osmo_constants_repo.bzl", "osmo_constants")
osmo_constants(
name = "osmo_constants",
base_image_url = BASE_IMAGE_URL,
image_tag = IMAGE_TAG,
)
################
# Common #
################
bazel_dep(name = "aspect_bazel_lib", version = "2.19.3")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_shell", version = "0.4.1")
################
# Python #
################
bazel_dep(name = "aspect_rules_py", version = "1.8.4")
bazel_dep(name = "rules_python", version = "1.8.4")
# Patch: single_version_platform_override.coverage_tool is attr.label() but
# python_repository.coverage_tool is attr.string(), causing a type mismatch.
# This one-line patch converts the Label to string before it flows through.
# TODO: Remove once rules_python fixes this upstream.
single_version_override(
module_name = "rules_python",
patches = ["//bzl/patches:rules_python_coverage_tool_label.patch"],
patch_strip = 1,
)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
ignore_root_user_error = True,
is_default = True,
python_version = "3.10.19",
)
# Python coverage tool for `bazel coverage` on CI (Linux x86_64).
# Workaround: rules_python 1.8.4 configure_coverage_tool=True silently fails in bzlmod,
# so we create the coverage repo manually and wire it via single_version_platform_override.
# TODO: Remove once rules_python fixes this upstream.
# NOTE: When changing python_version above, also update:
# 1. The coverage wheel URL below (cp3XX must match the new Python major.minor)
# 2. python.single_version_platform_override(python_version = ...) below
http_archive(
name = "python_coverage_linux_x86_64",
build_file_content = """\
filegroup(
name = "coverage",
srcs = ["coverage/__main__.py"],
data = glob(["coverage/*.py", "coverage/**/*.py", "coverage/*.so"]),
visibility = ["//visibility:public"],
)
""",
patch_args = ["-p1"],
patches = ["@rules_python//python/private:coverage.patch"],
sha256 = "8f59d57baca39b32db42b83b2a7ba6f47ad9c394ec2076b084c3f029b7afca23",
type = "zip",
urls = ["https://files.pythonhosted.org/packages/53/23/9e2c114d0178abc42b6d8d5281f651a8e6519abfa0ef460a00a91f80879d/coverage-7.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl"],
)
python.single_version_platform_override(
coverage_tool = "@python_coverage_linux_x86_64//:coverage",
platform = "x86_64-unknown-linux-gnu",
python_version = "3.10.19",
)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
# MyPy
pip.parse(
experimental_index_url = "https://pypi.org/simple/",
extra_pip_args = [
"--retries",
"10",
"--timeout",
"30",
],
hub_name = "osmo_mypy_deps",
python_version = "3.10.19",
requirements_lock = "//bzl/mypy:locked_requirements.txt",
)
use_repo(pip, "osmo_mypy_deps")
# Linting
pip.parse(
experimental_index_url = "https://pypi.org/simple/",
extra_pip_args = [
"--retries",
"10",
"--timeout",
"30",
],
hub_name = "pylint_python_deps",
python_version = "3.10.19",
requirements_lock = "//bzl/linting:locked_requirements.txt",
)
use_repo(pip, "pylint_python_deps")
# Osmo Python Dependencies
pip.parse(
experimental_index_url = "https://pypi.org/simple/",
extra_pip_args = [
"--retries",
"10",
"--timeout",
"30",
],
hub_name = "osmo_python_deps",
python_version = "3.10.19",
requirements_lock = "//src:locked_requirements.txt",
)
use_repo(pip, "osmo_python_deps")
# Testing Python Dependencies
pip.parse(
experimental_index_url = "https://pypi.org/simple/",
extra_pip_args = [
"--retries",
"10",
"--timeout",
"30",
],
hub_name = "osmo_tests_python_deps",
python_version = "3.10.19",
requirements_lock = "//src/tests:locked_requirements.txt",
)
use_repo(pip, "osmo_tests_python_deps")
################
# MyPy #
################
bazel_dep(name = "rules_mypy", version = "0.40.0")
types = use_extension("@rules_mypy//mypy:types.bzl", "types")
types.requirements(
name = "pip_types",
pip_requirements = "@osmo_python_deps//:requirements.bzl",
requirements_txt = "//src:locked_requirements.txt",
)
use_repo(types, "pip_types")
#############################
# Formatter/Linting #
#############################
# TODO: Re-enable when rules_diff@1.0.0 502 error from gitlab.arm.com is fixed
# bazel_dep(name = "aspect_rules_lint", version = "1.5.1") # Temporarily disabled due to rules_diff@1.0.0 502 error from gitlab.arm.com
################
# Bazel Skylib #
################
bazel_dep(name = "bazel_skylib", version = "1.8.2")
################
# Go #
################
bazel_dep(name = "rules_go", version = "0.54.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.42.0", repo_name = "bazel_gazelle")
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.from_file(
go_mod = "//src:go.mod",
)
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//src:go.mod")
# Additional dependencies for building rsync for CLI distribution
go_deps.module(
path = "github.com/BurntSushi/toml",
sum = "h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=",
version = "v1.4.0",
)
go_deps.module(
path = "github.com/coreos/go-systemd",
sum = "h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=",
version = "v0.0.0-20191104093116-d3cd4ed1dbcf",
)
# Gazelle overrides - using dev_dependency so they only apply when this module
# is the root. When used as a dependency of osmo_internal, the parent's
# MODULE.bazel provides these overrides instead.
go_deps_overrides = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps", dev_dependency = True)
go_deps_overrides.gazelle_override(
build_file_generation = "on",
path = "github.com/cncf/xds/go",
)
use_repo(
go_deps,
"com_github_conduitio_bwlimit",
"com_github_creack_pty",
"com_github_gokrazy_rsync",
"com_github_google_shlex",
"com_github_gorilla_websocket",
"com_github_jackc_pgx_v5",
"com_github_redis_go_redis_v9",
"com_github_hashicorp_golang_lru_v2",
"in_gopkg_yaml_v3",
# Dependencies for building rsync for CLI distribution
"com_github_burntsushi_toml",
"com_github_coreos_go_systemd",
# For GRPC
"org_golang_google_genproto_googleapis_rpc",
"org_golang_google_grpc",
# For Envoy (note: module is github.com/envoyproxy/go-control-plane/envoy)
"com_github_envoyproxy_go_control_plane_envoy",
# For testcontainers (integration testing)
"com_github_testcontainers_testcontainers_go",
"com_github_testcontainers_testcontainers_go_modules_postgres",
)
################
# Rules Docker #
################
http_archive(
name = "io_bazel_rules_docker",
sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
url = "https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz",
)
################
# OCI #
################
bazel_dep(name = "rules_oci", version = "2.2.3")
bazel_dep(name = "rules_distroless", version = "0.5.1")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
# Configure distroless apt packages
apt = use_extension("@rules_distroless//apt:extensions.bzl", "apt")
apt.install(
name = "debian_packages",
lock = "//bzl/debian_packages:debian_packages.lock.json",
manifest = "//bzl/debian_packages:debian_packages.yaml",
)
apt.install(
name = "debian_packages_arm64",
lock = "//bzl/debian_packages:debian_packages_arm64.lock.json",
manifest = "//bzl/debian_packages:debian_packages_arm64.yaml",
)
apt.install(
name = "dev_builder_debian_packages_x86_64",
lock = "//bzl/debian_packages:dev_builder_debian_packages_x86_64.lock.json",
manifest = "//bzl/debian_packages:dev_builder_debian_packages_x86_64.yaml",
)
apt.install(
name = "dev_builder_debian_packages_arm64",
lock = "//bzl/debian_packages:dev_builder_debian_packages_arm64.lock.json",
manifest = "//bzl/debian_packages:dev_builder_debian_packages_arm64.yaml",
)
oci.pull(
name = "distroless_python3_10",
digest = "sha256:d84b0a23be412faa58856365f069f7e2d364a2b589f4f7bb1d1080e215b61b16",
image = BASE_DISTROLESS_IMAGE_URL + "python:3.10-v4.0.3",
platforms = [
"linux/arm64",
"linux/amd64",
],
)
# Used for local debugging
# oci.pull(
# name = "distroless_python3_10_dev",
# image = BASE_DISTROLESS_IMAGE_URL + "python:3.10-v4.0.3-dev",
# platforms = [
# "linux/amd64",
# "linux/arm64/v8"
# ],
# digest = "sha256:a1870afc12027e3976f9c4982a4c8e8c4f0b97f0bb1554b66db7786effd834f2",
# )
oci.pull(
name = "ubuntu_22_04",
digest = "sha256:be0d0eb70eb824666ab98a76ad74780fe1a68e3a9390efea9268c56e5a531226",
image = "nvcr.io/nvidia/base/ubuntu:jammy-20250619",
platforms = [
"linux/amd64",
"linux/arm64",
],
)
use_repo(
oci,
"distroless_python3_10",
"distroless_python3_10_linux_amd64",
"distroless_python3_10_linux_arm64",
# "distroless_python3_10_dev",
# "distroless_python3_10_dev_linux_amd64",
# "distroless_python3_10_dev_linux_arm64_v8",
"ubuntu_22_04",
"ubuntu_22_04_linux_amd64",
"ubuntu_22_04_linux_arm64",
)
use_repo(
apt,
"debian_packages",
"debian_packages_arm64",
"dev_builder_debian_packages_arm64",
"dev_builder_debian_packages_x86_64",
)
################
# Packaging #
################
bazel_dep(name = "rules_pkg", version = "1.1.0")
####################
# Python Library #
####################
wheel_requires = use_repo_rule("//src/lib/distribution:requires.bzl", "wheel_requires_repo")
wheel_requires(
name = "osmo_wheel_requires",
requirements_txt = "//src:requirements.txt",
)