Skip to main content
Version: 1.5.x

versions

Skylib module containing functions for checking Bazel versions.

Macros and Functions

versions.get

Returns the current Bazel version

Example usage (generated):

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

versions.get(
)

versions.parse

Parses a version string into a 3-tuple of ints

int tuples can be compared directly using binary operators (<, >).

For a development build of Bazel, this returns an unspecified version tuple that compares higher than any released version.

Example usage (generated):

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

versions.parse(
# the Bazel version string
bazel_version = None,
)

bazel_version

Required.

the Bazel version string

versions.check

Check that the version of Bazel is valid within the specified range.

Example usage (generated):

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

versions.check(
# minimum version of Bazel expected
minimum_bazel_version = None,
)

minimum_bazel_version

Required.

minimum version of Bazel expected

maximum_bazel_version

Optional. Default: None

maximum version of Bazel expected

bazel_version

Optional. Default: None

the version of Bazel to check. Used for testing, defaults to native.bazel_version

versions.is_at_most

Check that a version is lower or equals to a threshold.

Example usage (generated):

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

versions.is_at_most(
# the maximum version string
threshold = None,
# the version string to be compared to the threshold
version = None,
)

threshold

Required.

the maximum version string

version

Required.

the version string to be compared to the threshold

versions.is_at_least

Check that a version is higher or equals to a threshold.

Example usage (generated):

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

versions.is_at_least(
# the minimum version string
threshold = None,
# the version string to be compared to the threshold
version = None,
)

threshold

Required.

the minimum version string

version

Required.

the version string to be compared to the threshold