Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d09d60c

Browse filesBrowse files
UebelAndrealexeaglehrfuller
authored
Updated min tested Bazel version to 4.0.0 (bazel-contrib#533)
* Updated min tested Bazel version to 4.0.0 * Assert that Bazel is at least 4.0.0 LTS Since we only test against bazel 4.0 now, and will start using features that require it, this gives users an obvious error message that they need to update. * Add third_party bzl files to integration test rules_python distro * remove helloworld test that relies on python2 Co-authored-by: Alex Eagle <eagle@post.harvard.edu> Co-authored-by: Henry Fuller <hrofuller@gmail.com>
1 parent 86e7135 commit d09d60c
Copy full SHA for d09d60c

File tree

Expand file treeCollapse file tree

14 files changed

+173
-119
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+173
-119
lines changed

‎.bazelversion

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1
1+
4.0.0

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
*~
3333

3434
# Bazel directories
35-
bazel-*
36-
bazel-bin
37-
bazel-genfiles
38-
bazel-out
39-
bazel-testlogs
35+
/bazel-*
36+
/bazel-bin
37+
/bazel-genfiles
38+
/bazel-out
39+
/bazel-testlogs
4040

4141
# vim swap files
4242
*.swp

‎BUILD

Copy file name to clipboardExpand all lines: BUILD
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ filegroup(
2929
"internal_setup.bzl",
3030
"//python:distribution",
3131
"//python/pip_install:distribution",
32+
"//third_party/github.com/bazelbuild/bazel-skylib/lib:distribution",
3233
"//tools:distribution",
3334
],
3435
visibility = ["//distro:__pkg__"],

‎docs/BUILD

Copy file name to clipboardExpand all lines: docs/BUILD
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ stardoc(
8484
deps = [
8585
":bazel_repo_tools",
8686
":pip_install_bzl",
87+
"//third_party/github.com/bazelbuild/bazel-skylib/lib:versions",
8788
],
8889
)
8990

‎examples/legacy_pip_import/WORKSPACE

Copy file name to clipboardExpand all lines: examples/legacy_pip_import/WORKSPACE
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ load("@rules_python//python/legacy_pip_import:pip.bzl", "pip_import", "pip_repos
1212

1313
pip_repositories()
1414

15-
pip_import(
16-
name = "helloworld_deps",
17-
requirements = "//helloworld:requirements.txt",
18-
)
19-
20-
load("@helloworld_deps//:requirements.bzl", _helloworld_install = "pip_install")
21-
22-
_helloworld_install()
23-
2415
pip_import(
2516
name = "boto_deps",
2617
requirements = "//boto:requirements.txt",

‎examples/legacy_pip_import/helloworld/BUILD

Copy file name to clipboardExpand all lines: examples/legacy_pip_import/helloworld/BUILD
-33Lines changed: 0 additions & 33 deletions
This file was deleted.

‎examples/legacy_pip_import/helloworld/helloworld.py

Copy file name to clipboardExpand all lines: examples/legacy_pip_import/helloworld/helloworld.py
-29Lines changed: 0 additions & 29 deletions
This file was deleted.

‎examples/legacy_pip_import/helloworld/helloworld_test.py

Copy file name to clipboardExpand all lines: examples/legacy_pip_import/helloworld/helloworld_test.py
-40Lines changed: 0 additions & 40 deletions
This file was deleted.

‎examples/legacy_pip_import/helloworld/requirements.txt

Copy file name to clipboardExpand all lines: examples/legacy_pip_import/helloworld/requirements.txt
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎python/pip_install/repositories.bzl

Copy file name to clipboardExpand all lines: python/pip_install/repositories.bzl
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
55

6+
# Avoid a load from @bazel_skylib repository as users don't necessarily have it installed
7+
load("//third_party/github.com/bazelbuild/bazel-skylib/lib:versions.bzl", "versions")
8+
69
_RULE_DEPS = [
710
(
811
"pypi__click",
@@ -63,6 +66,13 @@ def pip_install_dependencies():
6366
6467
(However we call it from pip_install, making it optional for users to do so.)
6568
"""
69+
70+
# We only support Bazel LTS and rolling releases.
71+
# Give the user an obvious error to upgrade rather than some obscure missing symbol later.
72+
# It's not guaranteed that users call this function, but it's used by all the pip fetch
73+
# repository rules so it's likely that most users get the right error.
74+
versions.check("4.0.0")
75+
6676
for (name, url, sha256) in _RULE_DEPS:
6777
maybe(
6878
http_archive,
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# vendored copy of skylib
2+
3+
This exists so that users of rules_python don't have to install bazel-skylib
4+
copied from https://github.com/bazelbuild/bazel-skylib/blob/1.0.3
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
3+
licenses(["notice"])
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
# export bzl files for the documentation
8+
exports_files(
9+
glob(["*.bzl"]),
10+
visibility = ["//:__subpackages__"],
11+
)
12+
13+
filegroup(
14+
name = "distribution",
15+
srcs = glob(["**"]),
16+
visibility = ["//:__pkg__"],
17+
)
18+
19+
bzl_library(
20+
name = "versions",
21+
srcs = ["versions.bzl"],
22+
)
+128Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Copyright 2018 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Skylib module containing functions for checking Bazel versions."""
16+
17+
def _get_bazel_version():
18+
"""Returns the current Bazel version"""
19+
20+
return native.bazel_version
21+
22+
def _extract_version_number(bazel_version):
23+
"""Extracts the semantic version number from a version string
24+
25+
Args:
26+
bazel_version: the version string that begins with the semantic version
27+
e.g. "1.2.3rc1 abc1234" where "abc1234" is a commit hash.
28+
29+
Returns:
30+
The semantic version string, like "1.2.3".
31+
"""
32+
for i in range(len(bazel_version)):
33+
c = bazel_version[i]
34+
if not (c.isdigit() or c == "."):
35+
return bazel_version[:i]
36+
return bazel_version
37+
38+
# Parse the bazel version string from `native.bazel_version`.
39+
# e.g.
40+
# "0.10.0rc1 abc123d" => (0, 10, 0)
41+
# "0.3.0" => (0, 3, 0)
42+
def _parse_bazel_version(bazel_version):
43+
"""Parses a version string into a 3-tuple of ints
44+
45+
int tuples can be compared directly using binary operators (<, >).
46+
47+
Args:
48+
bazel_version: the Bazel version string
49+
50+
Returns:
51+
An int 3-tuple of a (major, minor, patch) version.
52+
"""
53+
54+
version = _extract_version_number(bazel_version)
55+
return tuple([int(n) for n in version.split(".")])
56+
57+
def _is_at_most(threshold, version):
58+
"""Check that a version is lower or equals to a threshold.
59+
60+
Args:
61+
threshold: the maximum version string
62+
version: the version string to be compared to the threshold
63+
64+
Returns:
65+
True if version <= threshold.
66+
"""
67+
return _parse_bazel_version(version) <= _parse_bazel_version(threshold)
68+
69+
def _is_at_least(threshold, version):
70+
"""Check that a version is higher or equals to a threshold.
71+
72+
Args:
73+
threshold: the minimum version string
74+
version: the version string to be compared to the threshold
75+
76+
Returns:
77+
True if version >= threshold.
78+
"""
79+
80+
return _parse_bazel_version(version) >= _parse_bazel_version(threshold)
81+
82+
def _check_bazel_version(minimum_bazel_version, maximum_bazel_version = None, bazel_version = None):
83+
"""Check that the version of Bazel is valid within the specified range.
84+
85+
Args:
86+
minimum_bazel_version: minimum version of Bazel expected
87+
maximum_bazel_version: maximum version of Bazel expected
88+
bazel_version: the version of Bazel to check. Used for testing, defaults to native.bazel_version
89+
"""
90+
if not bazel_version:
91+
if "bazel_version" not in dir(native):
92+
fail("Current Bazel version is lower than 0.2.1; expected at least {}".format(
93+
minimum_bazel_version,
94+
))
95+
elif not native.bazel_version:
96+
# Using a non-release version, assume it is good.
97+
return
98+
else:
99+
bazel_version = native.bazel_version
100+
101+
if not _is_at_least(
102+
threshold = minimum_bazel_version,
103+
version = bazel_version,
104+
):
105+
fail("Current Bazel version is {}; expected at least {}".format(
106+
bazel_version,
107+
minimum_bazel_version,
108+
))
109+
110+
if maximum_bazel_version:
111+
if not _is_at_most(
112+
threshold = maximum_bazel_version,
113+
version = bazel_version,
114+
):
115+
fail("Current Bazel version is {}; expected at most {}".format(
116+
bazel_version,
117+
maximum_bazel_version,
118+
))
119+
120+
pass
121+
122+
versions = struct(
123+
get = _get_bazel_version,
124+
parse = _parse_bazel_version,
125+
check = _check_bazel_version,
126+
is_at_most = _is_at_most,
127+
is_at_least = _is_at_least,
128+
)

‎version.bzl

Copy file name to clipboardExpand all lines: version.bzl
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ version = "0.4.0"
2020
# This version should be updated together with the version of the Bazel
2121
# in .bazelversion.
2222
# TODO(alexeagle): assert this is the case in a test
23-
BAZEL_VERSION = "3.3.1"
23+
BAZEL_VERSION = "4.0.0"
2424

2525
# Versions of Bazel which users should be able to use.
2626
# Ensures we don't break backwards-compatibility,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.