Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d536802

Browse files
committed
Stop using Label.relative(), as it is deprecated
According to the Bazel documentation, this method is deprecated: https://bazel.build/rules/lib/builtins/Label#relative In this specific case there is also no need to use it, as we can simply use .repo_name to obtain the repository's canonical name.
1 parent e5b01ac commit d536802

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

python/private/toolchains_repo.bzl

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ load(
3131
load(":repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils")
3232
load(":text_util.bzl", "render")
3333

34-
def get_repository_name(repository_workspace):
35-
dummy_label = "//:_"
36-
return str(repository_workspace.relative(dummy_label))[:-len(dummy_label)] or "@"
37-
3834
def python_toolchain_build_file_content(
3935
prefix,
4036
python_version,
@@ -90,7 +86,7 @@ def _toolchains_repo_impl(rctx):
9086
# python_register_toolchains macro so you don't normally need to interact with
9187
# these targets.
9288
93-
load("@{rules_python}//python/private:py_toolchain_suite.bzl", "py_toolchain_suite")
89+
load("@@{rules_python}//python/private:py_toolchain_suite.bzl", "py_toolchain_suite")
9490
9591
""".format(
9692
rules_python = rctx.attr._rules_python_workspace.repo_name,
@@ -151,13 +147,13 @@ toolchain_aliases(
151147
rctx.file("defs.bzl", content = """\
152148
# Generated by python/private/toolchains_repo.bzl
153149
154-
load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
155-
load("{rules_python}//python/private:deprecation.bzl", "with_deprecation")
156-
load("{rules_python}//python/private:text_util.bzl", "render")
157-
load("{rules_python}//python:py_binary.bzl", _py_binary = "py_binary")
158-
load("{rules_python}//python:py_test.bzl", _py_test = "py_test")
150+
load("@@{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
151+
load("@@{rules_python}//python/private:deprecation.bzl", "with_deprecation")
152+
load("@@{rules_python}//python/private:text_util.bzl", "render")
153+
load("@@{rules_python}//python:py_binary.bzl", _py_binary = "py_binary")
154+
load("@@{rules_python}//python:py_test.bzl", _py_test = "py_test")
159155
load(
160-
"{rules_python}//python/entry_points:py_console_script_binary.bzl",
156+
"@@{rules_python}//python/entry_points:py_console_script_binary.bzl",
161157
_py_console_script_binary = "py_console_script_binary",
162158
)
163159
@@ -185,7 +181,7 @@ def compile_pip_requirements(**kwargs):
185181
""".format(
186182
name = rctx.attr.name,
187183
python_version = rctx.attr.python_version,
188-
rules_python = get_repository_name(rctx.attr._rules_python_workspace),
184+
rules_python = rctx.attr._rules_python_workspace.repo_name,
189185
))
190186

191187
toolchain_aliases = repository_rule(
@@ -343,7 +339,7 @@ def compile_pip_requirements(**kwargs):
343339
repository_name = repository_name,
344340
name = rctx.attr.name,
345341
python_version = python_version,
346-
rules_python = get_repository_name(rctx.attr._rules_python_workspace),
342+
rules_python = rctx.attr._rules_python_workspace.repo_name,
347343
))
348344
rctx.file("{}/BUILD.bazel".format(python_version), "")
349345

0 commit comments

Comments
 (0)