-
-
Notifications
You must be signed in to change notification settings - Fork 708
Updated min tested Bazel version to 4.0.0 #533
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0903d49
Updated min tested Bazel version to 4.0.0
UebelAndre 7c936b7
feat: assert that Bazel is at least 4.0.0 LTS
alexeagle 2626118
Add third_party bzl files to integration test rules_python distro
hrfuller 155d024
fix docs by adding bzl_library back to vendored skylib
hrfuller 05d445d
re-buildifier
hrfuller 96a71cd
remove helloworld test that relies on python2
hrfuller f0f4874
Merge branch 'main' into lts
hrfuller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.3.1 | ||
| 4.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # vendored copy of skylib | ||
|
|
||
| This exists so that users of rules_python don't have to install bazel-skylib | ||
| copied from https://github.com/bazelbuild/bazel-skylib/blob/1.0.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
|
||
| licenses(["notice"]) | ||
|
|
||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| # export bzl files for the documentation | ||
| exports_files( | ||
| glob(["*.bzl"]), | ||
| visibility = ["//:__subpackages__"], | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "distribution", | ||
| srcs = glob(["**"]), | ||
| visibility = ["//:__pkg__"], | ||
| ) | ||
|
|
||
| bzl_library( | ||
| name = "versions", | ||
| srcs = ["versions.bzl"], | ||
| ) |
128 changes: 128 additions & 0 deletions
128
third_party/github.com/bazelbuild/bazel-skylib/lib/versions.bzl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # Copyright 2018 The Bazel Authors. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Skylib module containing functions for checking Bazel versions.""" | ||
|
|
||
| def _get_bazel_version(): | ||
| """Returns the current Bazel version""" | ||
|
|
||
| return native.bazel_version | ||
|
|
||
| def _extract_version_number(bazel_version): | ||
| """Extracts the semantic version number from a version string | ||
|
|
||
| Args: | ||
| bazel_version: the version string that begins with the semantic version | ||
| e.g. "1.2.3rc1 abc1234" where "abc1234" is a commit hash. | ||
|
|
||
| Returns: | ||
| The semantic version string, like "1.2.3". | ||
| """ | ||
| for i in range(len(bazel_version)): | ||
| c = bazel_version[i] | ||
| if not (c.isdigit() or c == "."): | ||
| return bazel_version[:i] | ||
| return bazel_version | ||
|
|
||
| # Parse the bazel version string from `native.bazel_version`. | ||
| # e.g. | ||
| # "0.10.0rc1 abc123d" => (0, 10, 0) | ||
| # "0.3.0" => (0, 3, 0) | ||
| def _parse_bazel_version(bazel_version): | ||
| """Parses a version string into a 3-tuple of ints | ||
|
|
||
| int tuples can be compared directly using binary operators (<, >). | ||
|
|
||
| Args: | ||
| bazel_version: the Bazel version string | ||
|
|
||
| Returns: | ||
| An int 3-tuple of a (major, minor, patch) version. | ||
| """ | ||
|
|
||
| version = _extract_version_number(bazel_version) | ||
| return tuple([int(n) for n in version.split(".")]) | ||
|
|
||
| def _is_at_most(threshold, version): | ||
| """Check that a version is lower or equals to a threshold. | ||
|
|
||
| Args: | ||
| threshold: the maximum version string | ||
| version: the version string to be compared to the threshold | ||
|
|
||
| Returns: | ||
| True if version <= threshold. | ||
| """ | ||
| return _parse_bazel_version(version) <= _parse_bazel_version(threshold) | ||
|
|
||
| def _is_at_least(threshold, version): | ||
| """Check that a version is higher or equals to a threshold. | ||
|
|
||
| Args: | ||
| threshold: the minimum version string | ||
| version: the version string to be compared to the threshold | ||
|
|
||
| Returns: | ||
| True if version >= threshold. | ||
| """ | ||
|
|
||
| return _parse_bazel_version(version) >= _parse_bazel_version(threshold) | ||
|
|
||
| def _check_bazel_version(minimum_bazel_version, maximum_bazel_version = None, bazel_version = None): | ||
| """Check that the version of Bazel is valid within the specified range. | ||
|
|
||
| Args: | ||
| minimum_bazel_version: minimum version of Bazel expected | ||
| maximum_bazel_version: maximum version of Bazel expected | ||
| bazel_version: the version of Bazel to check. Used for testing, defaults to native.bazel_version | ||
| """ | ||
| if not bazel_version: | ||
| if "bazel_version" not in dir(native): | ||
| fail("Current Bazel version is lower than 0.2.1; expected at least {}".format( | ||
| minimum_bazel_version, | ||
| )) | ||
| elif not native.bazel_version: | ||
| # Using a non-release version, assume it is good. | ||
| return | ||
| else: | ||
| bazel_version = native.bazel_version | ||
|
|
||
| if not _is_at_least( | ||
| threshold = minimum_bazel_version, | ||
| version = bazel_version, | ||
| ): | ||
| fail("Current Bazel version is {}; expected at least {}".format( | ||
| bazel_version, | ||
| minimum_bazel_version, | ||
| )) | ||
|
|
||
| if maximum_bazel_version: | ||
| if not _is_at_most( | ||
| threshold = maximum_bazel_version, | ||
| version = bazel_version, | ||
| ): | ||
| fail("Current Bazel version is {}; expected at most {}".format( | ||
| bazel_version, | ||
| maximum_bazel_version, | ||
| )) | ||
|
|
||
| pass | ||
|
|
||
| versions = struct( | ||
| get = _get_bazel_version, | ||
| parse = _parse_bazel_version, | ||
| check = _check_bazel_version, | ||
| is_at_most = _is_at_most, | ||
| is_at_least = _is_at_least, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like versions.bzl tries to load skylib anyway. https://github.com/bazelbuild/rules_python/pull/533/files#diff-86c5bb17276af4fdb85612635eabfdaf9b91676ae6bac37ee78a09947dfd6045R1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for fixing it!