Skip to content

Commit

Permalink
[BUILD] Use bazel-skylib rule to check bazel version (ray-project#20990)
Browse files Browse the repository at this point in the history
Bazel has a rule for enforcing the version so we can just reuse that.

This redundant bazel version check logic in setup.py is also causing issue when building conda package, because conda has its own version of bazel and it doesn't support `--version`.
  • Loading branch information
jjyao authored Dec 9, 2021
1 parent 2410ec5 commit 5b21bc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
4 changes: 3 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ grpc_extra_deps()

load("@bazel_skylib//lib:versions.bzl", "versions")

versions.check(minimum_bazel_version = "3.4.0")
# When the bazel version is updated, make sure to update it
# in setup.py as well.
versions.check(minimum_bazel_version = "4.2.1")
14 changes: 2 additions & 12 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import zipfile

from itertools import chain
from itertools import takewhile
from enum import Enum

import urllib.error
Expand All @@ -23,6 +22,8 @@
logger = logging.getLogger(__name__)

SUPPORTED_PYTHONS = [(3, 6), (3, 7), (3, 8), (3, 9)]
# When the bazel version is updated, make sure to update it
# in WORKSPACE file as well.
SUPPORTED_BAZEL = (4, 2, 1)

ROOT_DIR = os.path.dirname(__file__)
Expand Down Expand Up @@ -485,17 +486,6 @@ def build(build_python, build_java, build_cpp):
] + pip_packages,
env=dict(os.environ, CC="gcc"))

version_info = bazel_invoke(subprocess.check_output, ["--version"])
bazel_version_str = version_info.rstrip().decode("utf-8").split(" ", 1)[1]
bazel_version_split = bazel_version_str.split(".")
bazel_version_digits = [
"".join(takewhile(str.isdigit, s)) for s in bazel_version_split
]
bazel_version = tuple(map(int, bazel_version_digits))
if bazel_version < SUPPORTED_BAZEL:
logger.warning("Expected Bazel version {} but found {}".format(
".".join(map(str, SUPPORTED_BAZEL)), bazel_version_str))

bazel_flags = ["--verbose_failures"]
if BAZEL_LIMIT_CPUS:
n = int(BAZEL_LIMIT_CPUS) # the value must be an int
Expand Down

0 comments on commit 5b21bc5

Please sign in to comment.