Skip to content

Commit ce76947

Browse files
committed
Updating ZetaSQL to v2024.11.1 and related dependencies.
* Adding patches to ZetaSQL (zetasql.patch and googleapis.patch) * Adding several new build dependencies (bazel-gazell, rules_proto, bazel_gazelle). * Update GCC version to gcc-11 * Updating the open-source build configuration (bazelrc.oss, .bazelversion, BUILD.bazel). PiperOrigin-RevId: 756061175
1 parent 6d22121 commit ce76947

File tree

12 files changed

+862
-22
lines changed

12 files changed

+862
-22
lines changed

.bazelrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# arrow.
33
# See tfx_bsl/cc/pybind11/arrow_casters.h
44
build --copt=-DTFX_BSL_USE_ARROW_C_ABI
5-
build --cxxopt="-std=c++17"
5+
build --cxxopt=-std=c++17
6+
build --host_cxxopt=-std=c++17
67

78
# Needed to avoid zetasql proto error.
89
build --protocopt=--experimental_allow_proto3_optional
@@ -13,3 +14,11 @@ build --protocopt=--experimental_allow_proto3_optional
1314
build --incompatible_require_linker_input_cc_api=false
1415
build:macos --apple_platform_type=macos
1516
build:macos_arm64 --cpu=darwin_arm64
17+
18+
# Most of these warnings are triggered from ZetaSQL, disable for now. Ideally,
19+
# we would disable these only for projects we don't control, but there does not
20+
# seem to be an easy way to do that yet.
21+
build --copt -Wno-sign-compare
22+
build --copt -Wno-deprecated-declarations
23+
build --copt -Wno-return-type
24+
build --copt -Wno-unused-but-set-parameter

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

BUILD.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@bazel_gazelle//:def.bzl", "gazelle")
2+
3+
package(
4+
default_visibility = [":__subpackages__"],
5+
)
6+
7+
licenses(["notice"])
8+
9+
exports_files(["LICENSE"])
10+
11+
gazelle(
12+
name = "gazelle-update-repos",
13+
args = [
14+
"-from_file=go.mod",
15+
"-to_macro=deps.bzl%go_dependencies",
16+
],
17+
command = "update-repos",
18+
)

RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* Depends on `protobuf>=4.25.2,<5` for Python 3.11 and on
1010
`protobuf>=4.21.6,<6.0.0` for 3.9 and 3.10.
1111
* Bumped the minimum bazel version required to build `tfx_bsl` to 6.5.0.
12+
* Updating ZetaSQL to v2024.11.1 and related dependencies.
13+
* Update GCC version to gcc-10 and the build configuration (.bazelrc,
14+
.bazelversion)
1215

1316
## Breaking Changes
1417

WORKSPACE

Lines changed: 106 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@ workspace(name = "tfx_bsl")
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44

5+
http_archive(
6+
name = "google_bazel_common",
7+
sha256 = "82a49fb27c01ad184db948747733159022f9464fc2e62da996fa700594d9ea42",
8+
strip_prefix = "bazel-common-2a6b6406e12208e02b2060df0631fb30919080f3",
9+
urls = ["https://github.com/google/bazel-common/archive/2a6b6406e12208e02b2060df0631fb30919080f3.zip"],
10+
)
11+
12+
################################################################################
13+
# Generic Bazel Support #
14+
################################################################################
15+
16+
http_archive(
17+
name = "rules_proto",
18+
sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
19+
strip_prefix = "rules_proto-6.0.2",
20+
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz",
21+
)
22+
23+
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
24+
25+
rules_proto_dependencies()
26+
27+
load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
28+
29+
rules_proto_setup()
30+
31+
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
32+
33+
rules_proto_toolchains()
34+
535
# Install version 0.9.0 of rules_foreign_cc, as default version causes an
636
# invalid escape sequence error to be raised, which can't be avoided with
737
# the --incompatible_restrict_string_escapes=false flag (flag was removed in
@@ -73,11 +103,11 @@ http_archive(
73103
urls = ["https://github.com/apache/arrow/archive/%s.zip" % ARROW_COMMIT],
74104
)
75105

76-
COM_GOOGLE_ABSL_COMMIT = "fb3621f4f897824c0dbe0615fa94543df6192f30" # lts_2023_08_0
106+
COM_GOOGLE_ABSL_COMMIT = "4447c7562e3bc702ade25105912dce503f0c4010" # lts_2023_08_0
77107

78108
http_archive(
79109
name = "com_google_absl",
80-
sha256 = "0320586856674d16b0b7a4d4afb22151bdc798490bb7f295eddd8f6a62b46fea",
110+
sha256 = "df8b3e0da03567badd9440377810c39a38ab3346fa89df077bb52e68e4d61e74",
81111
strip_prefix = "abseil-cpp-%s" % COM_GOOGLE_ABSL_COMMIT,
82112
url = "https://github.com/abseil/abseil-cpp/archive/%s.tar.gz" % COM_GOOGLE_ABSL_COMMIT,
83113
)
@@ -131,12 +161,75 @@ http_archive(
131161
],
132162
)
133163

134-
ZETASQL_COMMIT = "589026c410c42de9aa8ee92ad16f745977140041" # 11/01/2023
164+
################################################################################
165+
# Google APIs protos #
166+
################################################################################
167+
http_archive(
168+
name = "com_google_googleapis",
169+
patch_args = ["-p1"],
170+
patches = ["//third_party:googleapis.patch"],
171+
sha256 = "28e7fe3a640dd1f47622a4c263c40d5509c008cc20f97bd366076d5546cccb64",
172+
strip_prefix = "googleapis-4ce00b00904a7ce1df8c157e54fcbf96fda0dc49",
173+
url = "https://github.com/googleapis/googleapis/archive/4ce00b00904a7ce1df8c157e54fcbf96fda0dc49.tar.gz",
174+
)
175+
176+
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
177+
178+
switched_rules_by_language(
179+
name = "com_google_googleapis_imports",
180+
cc = True,
181+
go = True,
182+
)
183+
184+
###############################################################################
185+
# Gazelle Support #
186+
###############################################################################
187+
188+
_rules_go_version = "v0.48.1"
189+
190+
http_archive(
191+
name = "io_bazel_rules_go",
192+
sha256 = "b2038e2de2cace18f032249cb4bb0048abf583a36369fa98f687af1b3f880b26",
193+
urls = [
194+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip".format(_rules_go_version),
195+
"https://github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip.format(_rules_go_version)",
196+
],
197+
)
198+
199+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
200+
201+
go_rules_dependencies()
202+
203+
go_register_toolchains(version = "1.21.11")
204+
205+
_bazel_gazelle_version = "0.36.0"
206+
207+
http_archive(
208+
name = "bazel_gazelle",
209+
sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62",
210+
urls = [
211+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v{0}/bazel-gazelle-v{0}.tar.gz".format(_bazel_gazelle_version),
212+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v{0}/bazel-gazelle-v{0}.tar.gz".format(_bazel_gazelle_version),
213+
],
214+
)
215+
216+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") #, "go_repository")
217+
218+
gazelle_dependencies()
219+
220+
################################################################################
221+
# ZetaSQL #
222+
################################################################################
223+
224+
ZETASQL_COMMIT = "a516c6b26d183efc4f56293256bba92e243b7a61" # 11/01/2024
135225

136226
http_archive(
137227
name = "com_google_zetasql",
228+
patch_args = ["-p1"],
229+
patches = ["//third_party:zetasql.patch"],
230+
sha256 = "1afc2210d4aad371eff0a6bfdd8417ba99e02183a35dff167af2fa6097643f26",
138231
strip_prefix = "zetasql-%s" % ZETASQL_COMMIT,
139-
urls = ["https://github.com/google/zetasql/archive/%s.zip" % ZETASQL_COMMIT],
232+
urls = ["https://github.com/google/zetasql/archive/%s.tar.gz" % ZETASQL_COMMIT],
140233
)
141234

142235
load("@com_google_zetasql//bazel:zetasql_deps_step_1.bzl", "zetasql_deps_step_1")
@@ -153,13 +246,16 @@ zetasql_deps_step_2(
153246
tools_deps = False,
154247
)
155248

156-
# This is part of what zetasql_deps_step_3() does.
157-
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
249+
# No need to run zetasql_deps_step_3 and zetasql_deps_step_4 since all necessary dependencies are
250+
# already installed.
158251

159-
switched_rules_by_language(
160-
name = "com_google_googleapis_imports",
161-
cc = True,
162-
)
252+
# load("@com_google_zetasql//bazel:zetasql_deps_step_3.bzl", "zetasql_deps_step_3")
253+
254+
# zetasql_deps_step_3()
255+
256+
# load("@com_google_zetasql//bazel:zetasql_deps_step_4.bzl", "zetasql_deps_step_4")
257+
258+
# zetasql_deps_step_4()
163259

164260
_PLATFORMS_VERSION = "0.0.6"
165261

setup.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,25 @@ def finalize_options(self):
9393
self._additional_build_options = ['--macos_minimum_os=10.14']
9494

9595
def run(self):
96+
# Build the public protos to make sure they are buildable.
9697
subprocess.check_call(
97-
[self._bazel_cmd, 'run', '-c', 'opt'] + self._additional_build_options +
98-
['//tfx_bsl:move_generated_files'],
98+
[self._bazel_cmd, 'build', '-c', 'opt']
99+
+ self._additional_build_options
100+
+ ['//tfx_bsl/public/proto:public_protos'],
99101
# Bazel should be invoked in a directory containing bazel WORKSPACE
100102
# file, which is the root directory.
101103
cwd=os.path.dirname(os.path.realpath(__file__)),
102-
env=dict(os.environ, PYTHON_BIN_PATH=sys.executable))
104+
env=dict(os.environ, PYTHON_BIN_PATH=sys.executable),
105+
)
106+
subprocess.check_call(
107+
[self._bazel_cmd, 'run', '-c', 'opt']
108+
+ self._additional_build_options
109+
+ ['//tfx_bsl:move_generated_files'],
110+
# Bazel should be invoked in a directory containing bazel WORKSPACE
111+
# file, which is the root directory.
112+
cwd=os.path.dirname(os.path.realpath(__file__)),
113+
env=dict(os.environ, PYTHON_BIN_PATH=sys.executable),
114+
)
103115

104116

105117
class _BinaryDistribution(Distribution):

tfx_bsl/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ _py_extension = select({
6363
sh_binary(
6464
name = "move_generated_files",
6565
srcs = ["move_generated_files.sh"],
66-
data = _py_extension + _public_protos,
66+
data = _public_protos + _py_extension,
6767
)

tfx_bsl/build_macros.bzl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ def tfx_bsl_proto_library(name, **kwargs):
99
Args:
1010
name: Name of the cc proto library.
1111
**kwargs: Keyword arguments to pass to the proto libraries."""
12+
well_known_protos = [
13+
"@com_google_protobuf//:any_proto",
14+
"@com_google_protobuf//:duration_proto",
15+
"@com_google_protobuf//:timestamp_proto",
16+
"@com_google_protobuf//:struct_proto",
17+
"@com_google_protobuf//:empty_proto",
18+
"@com_google_protobuf//:wrappers_proto",
19+
]
20+
kwargs["deps"] = kwargs.get("deps", []) + well_known_protos
1221
native.proto_library(name = name + "_proto", **kwargs) # buildifier: disable=native-proto
1322
cc_proto_kwargs = {
1423
"deps": [":" + name + "_proto"],
@@ -29,12 +38,12 @@ def tfx_bsl_py_proto_library(
2938
visibility = None,
3039
testonly = 0):
3140
"""Opensource py_proto_library."""
32-
_ignore = [proto_library]
41+
_ignore = [proto_library] # buildifier: disable=unused-variable
3342
py_proto_library(
3443
name = name,
3544
srcs = srcs,
3645
srcs_version = "PY3",
37-
deps = ["@com_google_protobuf//:well_known_types_py_pb2"] + deps,
46+
deps = deps, # ["@com_google_protobuf//:well_known_types_py_pb2"] +
3847
default_runtime = "@com_google_protobuf//:protobuf_python",
3948
protoc = "@com_google_protobuf//:protoc",
4049
visibility = visibility,
@@ -56,7 +65,7 @@ def tfx_bsl_pybind_extension(
5665
deps: Dependencies.
5766
visibility: Visibility.
5867
"""
59-
_ignore = [module_name]
68+
_ignore = [module_name] # buildifier: disable=unused-variable
6069
p = name.rfind("/")
6170
if p == -1:
6271
sname = name

tfx_bsl/public/proto/BUILD

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Placeholder: load py_library # copybara:strip
2+
13
# Developers: use these two macros to define c++ or python proto targets.
24
load("//tfx_bsl:build_macros.bzl", "tfx_bsl_proto_library", "tfx_bsl_py_proto_library")
35

@@ -7,11 +9,11 @@ package(default_visibility = [
79

810
licenses(["notice"])
911

10-
filegroup(
12+
py_library(
1113
name = "public_protos",
12-
srcs = [
13-
"model_spec_pb2.py",
14-
"slicing_spec_pb2.py",
14+
deps = [
15+
":model_spec_proto_py_pb2",
16+
":slicing_spec_py_pb2",
1517
],
1618
)
1719

third_party/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ exports_files([
44
"pybind11.BUILD",
55
"python_configure.bzl",
66
])
7+
8+
filegroup(
9+
name = "zetasql_patch",
10+
srcs = ["zetasql.patch"],
11+
visibility = ["//visibility:public"],
12+
)

third_party/googleapis.patch

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- a/google/rpc/BUILD.bazel
2+
+++ b/google/rpc/BUILD.bazel
3+
@@ -80,6 +80,7 @@ go_proto_library(
4+
go_proto_library(
5+
name = "status_go_proto",
6+
importpath = "google.golang.org/genproto/googleapis/rpc/status",
7+
+ importmap = "unknown",
8+
protos = [":status_proto"],
9+
)
10+

0 commit comments

Comments
 (0)