8000 fix(deps): declare our dependency on bazel_skylib (#1001) · tanan/rules_python@bd3a719 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd3a719

Browse files
authored
fix(deps): declare our dependency on bazel_skylib (bazel-contrib#1001)
1 parent 9662139 commit bd3a719

File tree

9 files changed

+40
-72
lines changed

9 files changed

+40
-72
lines changed

.github/workflows/workspace_snippet.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ Paste this snippet into your \`WORKSPACE\` file:
4646
4747
\`\`\`starlark
4848
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
49+
4950
http_archive(
5051
name = "rules_python",
5152
sha256 = "${SHA}",
5253
strip_prefix = "${PREFIX}",
5354
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz",
5455
)
56+
57+
load("@rules_python//python:repositories.bzl", "py_repositories")
58+
59+
py_repositories()
5560
\`\`\`
5661
EOF

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module(
55
)
66

77
bazel_dep(name = "platforms", version = "0.0.4")
8+
bazel_dep(name = "bazel_skylib", version = "1.3.0")
89

910
# Those are loaded only when using py_proto_library
1011
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

examples/multi_python_versions/WORKSPACE

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
workspace(name = "rules_python_multi_python_versions")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
6-
name = "bazel_skylib",
7-
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
8-
urls = [
9-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
10-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
11-
],
12-
)
13-
143
local_repository(
154
name = "rules_python",
165
path = "../..",
@@ -20,7 +9,9 @@ load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependen
209

2110
pip_install_dependencies()
2211

23-
load("@rules_python//python:repositories.bzl", "python_register_multi_toolchains")
12+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")
13+
14+
py_repositories()
2415

2516
default_python_version = "3.9"
2617

examples/pip_install/WORKSPACE

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
workspace(name = "rules_python_pip_install_example")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
6-
name = "bazel_skylib",
7-
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
8-
urls = [
9-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
10-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
11-
],
12-
)
13-
143
local_repository(
154
name = "rules_python",
165
path = "../..",
176
)
187

19-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
8+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
9+
10+
py_repositories()
2011

2112
python_register_toolchains(
2213
name = "python39",

examples/pip_parse/WORKSPACE

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
workspace(name = "rules_python_pip_parse_example")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
6-
name = "bazel_skylib",
7-
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
8-
urls = [
9-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
10-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
11-
],
12-
)
13-
143
local_repository(
154
name = "rules_python",
165
path = "../..",
176
)
187

19-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
8+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
9+
10+
py_repositories()
2011

2112
python_register_toolchains(
2213
name = "python39",

examples/pip_parse_vendored/WORKSPACE

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
workspace(name = "pip_repository_annotations_example")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
53
local_repository(
64
name = "rules_python",
75
path = "../..",
86
)
97

10-
http_archive(
11-
name = "bazel_skylib",
12-
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
13-
urls = [
14-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
15-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
16-
],
17-
)
8+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
189

19-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
10+
py_repositories()
2011

2112
python_register_toolchains(
2213
name = "python39",

examples/pip_repository_annotations/WORKSPACE

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
workspace(name = "pip_repository_annotations_example")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
53
local_repository(
64
name = "rules_python",
75
path = "../..",
86
)
97

10-
http_archive(
11-
name = "bazel_skylib",
12-
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
13-
urls = [
14-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
15-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
16-
],
17-
)
8+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
189

19-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
10+
py_repositories()
2011

2112
python_register_toolchains(
2213
name = "python39",

python/repositories.bzl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
For historic reasons, pip_repositories() is defined in //python:pip.bzl.
1818
"""
1919

20+
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive")
21+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
2022
load(
2123
"//python/private:toolchains_repo.bzl",
2224
"multi_toolchain_aliases",
@@ -32,9 +34,23 @@ load(
3234
"get_release_url",
3335
)
3436

37+
def http_archive(**kwargs):
38+
maybe(_http_archive, **kwargs)
39+
3540
def py_repositories():
36-
# buildifier: disable=print
37-
print("py_repositories is a no-op and is deprecated. You can remove this from your WORKSPACE file")
41+
"""Runtime dependencies that users must install.
42+
43+
This function should be loaded and called in the user's WORKSPACE.
44+
With bzlmod enabled, this function is not needed since MODULE.bazel handles transitive deps.
45+
"""
46+
http_archive(
47+
name = "bazel_skylib",
48+
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
49+
urls = [
50+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
51+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
52+
],
53+
)
3854

3955
########
4056
# Remaining content of the file is only used to support toolchains.

tests/pip_repository_entry_points/WORKSPACE

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
workspace(name = "pip_repository_annotations_example")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
6-
name = "bazel_skylib",
7-
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
8-
urls = [
9-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
10-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
11-
],
12-
)
13-
143
local_repository(
154
name = "rules_python",
165
path = "../..",
176
)
187

19-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
8+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
9+
10+
py_repositories()
2011

2112
# This toolchain is explicitly 3.10 while `rules_python` is 3.9 to act as
2213
# a regression test, ensuring 3.10 is functional

0 commit comments

Comments
 (0)
0