Skip to content

Commit

Permalink
fix: fix errors with bazel@head (bazelbuild#2332)
Browse files Browse the repository at this point in the history
Fix various errors with upcoming Bazel versions

* Use rules_cc 0.0.13 for integration tests.
* Set `allow_empty=True` in local toolchains setup

Fixes bazelbuild#2310
  • Loading branch information
rickeylev authored Oct 23, 2024
1 parent 72ddf0c commit 5f28550
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
18 changes: 13 additions & 5 deletions python/private/local_runtime_repo_setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,26 @@ def define_local_runtime_toolchain_impl(
cc_library(
name = "_python_headers",
# NOTE: Keep in sync with watch_tree() called in local_runtime_repo
srcs = native.glob(["include/**/*.h"]),
srcs = native.glob(
["include/**/*.h"],
# A Python install may not have C headers
allow_empty = True,
),
includes = ["include"],
)

cc_library(
name = "_libpython",
# Don't use a recursive glob because the lib/ directory usually contains
# a subdirectory of the stdlib -- lots of unrelated files
srcs = native.glob([
"lib/*{}".format(lib_ext), # Match libpython*.so
"lib/*{}*".format(lib_ext), # Also match libpython*.so.1.0
]),
srcs = native.glob(
[
"lib/*{}".format(lib_ext), # Match libpython*.so
"lib/*{}*".format(lib_ext), # Also match libpython*.so.1.0
],
# A Python install may not have shared libraries.
allow_empty = True,
),
hdrs = [":_python_headers"],
)

Expand Down
16 changes: 16 additions & 0 deletions tests/integration/compile_pip_requirements/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
)

http_archive(
name = "rules_cc",
sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
strip_prefix = "rules_cc-0.0.13",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
)

local_repository(
name = "rules_python",
path = "../../..",
Expand Down
18 changes: 16 additions & 2 deletions tests/integration/ignore_root_user_error/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
)

http_archive(
name = "rules_cc",
sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
strip_prefix = "rules_cc-0.0.13",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
)

local_repository(
name = "rules_python",
path = "../../..",
Expand All @@ -13,8 +29,6 @@ python_register_toolchains(
python_version = "3.9",
)

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

http_archive(
name = "bazel_skylib",
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/pip_parse/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
)

http_archive(
name = "rules_cc",
sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
strip_prefix = "rules_cc-0.0.13",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
)

local_repository(
name = "rules_python",
path = "../../..",
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/py_cc_toolchain_registered/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
)

http_archive(
name = "rules_cc",
sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
strip_prefix = "rules_cc-0.0.13",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
)

local_repository(
name = "rules_python",
path = "../../..",
Expand Down

0 comments on commit 5f28550

Please sign in to comment.