Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade rules python #23730

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module(
# Bazel module dependencies
# =========================================

bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "rules_license", version = "0.0.8")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "grpc", version = "1.48.1.bcr.1", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "protobuf", version = "28.1", repo_name = "com_google_protobuf")
bazel_dep(name = "grpc", version = "1.66.0", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_pkg", version = "0.9.1")
bazel_dep(name = "stardoc", version = "0.7.1", repo_name = "io_bazel_skydoc")
Expand All @@ -27,17 +27,31 @@ bazel_dep(name = "rules_cc", version = "0.0.10")
bazel_dep(name = "rules_java", version = "7.11.1")
bazel_dep(name = "rules_graalvm", version = "0.11.1")
bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "rules_python", version = "0.33.2")
bazel_dep(name = "rules_jvm_external", version = "6.3")
bazel_dep(name = "rules_python", version = "0.36.0")
bazel_dep(name = "rules_testing", version = "0.6.0")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name = "com_google_googletest")
bazel_dep(name = "with_cfg.bzl", version = "0.2.4")
bazel_dep(name = "abseil-cpp", version = "20230802.1")
bazel_dep(name = "abseil-cpp", version = "20240116.1")

# TODO(pcloudy): Add remoteapis and googleapis as Bazel modules in the BCR.
bazel_dep(name = "remoteapis", version = "")
bazel_dep(name = "googleapis", version = "")

single_version_override(
module_name = "protobuf",
patch_strip = 1,
patches = [
"//third_party/protobuf:MODULE.bazel.patch",
],
)

bazel_dep(name = "rules_rust", version = "0.45.1")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2023")
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")

single_version_override(
module_name = "rules_jvm_external",
patch_strip = 1,
Expand All @@ -63,19 +77,13 @@ single_version_override(
],
)

single_version_override(
module_name = "protobuf",
patch_strip = 1,
patches = ["//third_party:protobuf_21.7.patch"],
)

# The following Bazel modules are not direct dependencies for building Bazel,
# but are required for visibility from DIST_ARCHIVE_REPOS in repositories.bzl
bazel_dep(name = "apple_support", version = "1.8.1")
bazel_dep(name = "apple_support", version = "1.15.1")
bazel_dep(name = "c-ares", version = "1.15.0")
bazel_dep(name = "rules_go", version = "0.39.1")
bazel_dep(name = "rules_go", version = "0.48.0")
bazel_dep(name = "rules_kotlin", version = "1.9.6")
bazel_dep(name = "upb", version = "0.0.0-20220923-a547704")
bazel_dep(name = "upb", version = "0.0.0-20230907-e7430e6")
single_version_override(
module_name = "upb",
patch_strip = 1,
Expand Down
4 changes: 2 additions & 2 deletions src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ use_repo(buildozer_binary, "buildozer_binary")

# Dependencies used to auto-load removed symbols and rules from Bazel (due to Starlarkification)
# See also: --incompatible_autoload_externally, AutoloadSymbols
bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "28.1", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_java", version = "7.11.1")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_python", version = "0.22.1")
bazel_dep(name = "rules_python", version = "0.36.0")
# add rules_android
# add apple_support
8 changes: 4 additions & 4 deletions third_party/grpc/00_disable_layering_check.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/BUILD b/BUILD
index 83e6a3f740..b27df5b71e 100644
index 65fadbc85c..ee8f03f9aa 100644
--- a/BUILD
+++ b/BUILD
@@ -29,7 +29,7 @@ licenses(["reciprocal"])
package(
@@ -33,7 +33,7 @@ package(
default_visibility = ["//visibility:public"],
features = [
"-parse_headers",
- "layering_check",
+ "-layering_check",
"-parse_headers",
],
)

170 changes: 170 additions & 0 deletions third_party/protobuf/MODULE.bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
diff --git a/MODULE.bazel b/MODULE.bazel
index c1deb0fb2..2544841a9 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -12,21 +12,78 @@ module(
# Bzlmod follows MVS:
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
# Thus the highest version in their module graph is resolved.
-bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
-bazel_dep(name = "bazel_skylib", version = "1.4.1")
-bazel_dep(name = "jsoncpp", version = "1.9.5")
-bazel_dep(name = "rules_cc", version = "0.0.9")
-bazel_dep(name = "rules_fuzzing", version = "0.5.2")
-bazel_dep(name = "rules_java", version = "5.3.5")
-bazel_dep(name = "rules_jvm_external", version = "5.1")
-bazel_dep(name = "rules_pkg", version = "0.7.0")
-bazel_dep(name = "rules_python", version = "0.28.0")
-bazel_dep(name = "rules_rust", version = "0.45.1")
-bazel_dep(name = "platforms", version = "0.0.8")
-bazel_dep(name = "zlib", version = "1.3.1")
-
-# TODO: remove after toolchain types are moved to protobuf
-bazel_dep(name = "rules_proto", version = "4.0.0")
+bazel_dep(
+ name = "abseil-cpp",
+ version = "20230802.0.bcr.1",
+ repo_name = "com_google_absl",
+)
+
+bazel_dep(
+ name = "bazel_skylib",
+ version = "1.7.0",
+)
+
+bazel_dep(
+ name = "jsoncpp",
+ version = "1.9.5",
+)
+
+bazel_dep(
+ name = "rules_cc",
+ version = "0.0.9",
+)
+
+bazel_dep(
+ name = "rules_fuzzing",
+ version = "0.5.2",
+)
+
+bazel_dep(
+ name = "rules_java",
+ version = "7.11.1",
+)
+
+bazel_dep(
+ name = "rules_jvm_external",
+ version = "6.3",
+)
+
+bazel_dep(
+ name = "rules_kotlin",
+ version = "1.9.0",
+)
+
+bazel_dep(
+ name = "rules_license",
+ version = "1.0.0",
+)
+
+bazel_dep(
+ name = "rules_pkg",
+ version = "1.0.1",
+)
+
+bazel_dep(
+ name = "rules_python",
+ version = "0.28.0",
+)
+
+bazel_dep(
+ name = "platforms",
+ version = "0.0.8",
+)
+
+bazel_dep(
+ name = "zlib",
+ version = "1.3.1",
+)
+
+bazel_dep(
+ name = "bazel_features",
+ version = "1.17.0",
+ repo_name = "proto_bazel_features",
+)
+

SUPPORTED_PYTHON_VERSIONS = [
"3.8",
@@ -35,7 +92,9 @@ SUPPORTED_PYTHON_VERSIONS = [
"3.11",
"3.12",
]
+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+
[
python.toolchain(
is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1],
@@ -43,8 +102,14 @@ python = use_extension("@rules_python//python/extensions:python.bzl", "python")
)
for python_version in SUPPORTED_PYTHON_VERSIONS
]
-use_repo(python, system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")))
+
+use_repo(
+ python,
+ system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")),
+)
+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
+
[
pip.parse(
hub_name = "pip_deps",
@@ -53,20 +118,30 @@ pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
)
for python_version in SUPPORTED_PYTHON_VERSIONS
]
+
use_repo(pip, "pip_deps")

-rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
-rust.toolchain(edition = "2021")
-use_repo(rust, "rust_toolchains")
-register_toolchains("@rust_toolchains//:all")
-crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
-crate.spec(
- package = "googletest",
- version = ">0.0.0",
-)
-crate.spec(
- package = "paste",
- version = ">=1",
-)
-crate.from_specs()
-use_repo(crate, crate_index = "crates")
+maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
+
+maven.install(
+ artifacts = [
+ "com.google.caliper:caliper:1.0-beta-3",
+ "com.google.code.findbugs:jsr305:3.0.2",
+ "com.google.code.gson:gson:2.8.9",
+ "com.google.errorprone:error_prone_annotations:2.5.1",
+ "com.google.j2objc:j2objc-annotations:2.8",
+ "com.google.guava:guava:32.0.1-jre",
+ "com.google.guava:guava-testlib:32.0.1-jre",
+ "com.google.truth:truth:1.1.2",
+ "junit:junit:4.13.2",
+ "org.mockito:mockito-core:4.3.1",
+ "biz.aQute.bnd:biz.aQute.bndlib:6.4.0",
+ "info.picocli:picocli:4.6.3",
+ ],
+ repositories = [
+ "https://repo1.maven.org/maven2",
+ "https://repo.maven.apache.org/maven2",
+ ],
+)
+
+use_repo(maven, "maven")
13 changes: 0 additions & 13 deletions third_party/protobuf_21.7.patch

This file was deleted.

11 changes: 6 additions & 5 deletions third_party/upb/00_remove_toolchain_transition.patch
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl
index cb9800ca..08d03edc 100644
index 31853532..6b349817 100644
--- a/bazel/upb_proto_library.bzl
+++ b/bazel/upb_proto_library.bzl
@@ -316,7 +316,6 @@ _upb_proto_library_aspect = aspect(
@@ -382,7 +382,6 @@ upb_proto_library_aspect = aspect(
attr_aspects = ["deps"],
fragments = ["cpp"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = use_cpp_toolchain(),
- incompatible_use_toolchain_transition = True,
)

upb_proto_library = rule(
@@ -369,7 +368,6 @@ _upb_proto_reflection_library_aspect = aspect(
@@ -435,7 +434,6 @@ _upb_proto_reflection_library_aspect = aspect(
attr_aspects = ["deps"],
fragments = ["cpp"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = use_cpp_toolchain(),
- incompatible_use_toolchain_transition = True,
)

upb_proto_reflection_library = rule(

16 changes: 5 additions & 11 deletions third_party/upb/01_remove_werror.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl
diff --git a/bazel/build_defs.bzl b/bazel/build_defs.bzl
index e4212b3c..1aaa6562 100644
--- a/bazel/build_defs.bzl
+++ b/bazel/build_defs.bzl
@@ -34,13 +34,13 @@
@@ -32,7 +32,7 @@ _DEFAULT_COPTS = []
_DEFAULT_CPPOPTS.extend([
"-Wextra",
# "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang)
- "-Werror",
+ # "-Werror",
+# "-Werror",
"-Wno-unused-parameter",
"-Wno-long-long",
])
_DEFAULT_COPTS.extend([
"-std=c99",
"-pedantic",
- "-Werror=pedantic",
+ # "-Werror=pedantic",
"-Wall",
"-Wstrict-prototypes",
# GCC (at least) emits spurious warnings for this that cannot be fixed
Loading