diff --git a/gazelle/manifest/defs.bzl b/gazelle/manifest/defs.bzl index 6c0072a48b..45fdb32e7d 100644 --- a/gazelle/manifest/defs.bzl +++ b/gazelle/manifest/defs.bzl @@ -161,7 +161,7 @@ AllSourcesInfo = provider(fields = {"all_srcs": "All sources collected from the _rules_python_workspace = Label("@rules_python//:WORKSPACE") def _get_all_sources_impl(target, ctx): - is_rules_python = target.label.workspace_name == _rules_python_workspace.workspace_name + is_rules_python = target.label.repo_name == _rules_python_workspace.repo_name if not is_rules_python: # Avoid adding third-party dependency files to the checksum of the srcs. return AllSourcesInfo(all_srcs = depset()) diff --git a/python/private/pypi/multi_pip_parse.bzl b/python/private/pypi/multi_pip_parse.bzl index 6e824f674c..60496c2eca 100644 --- a/python/private/pypi/multi_pip_parse.bzl +++ b/python/private/pypi/multi_pip_parse.bzl @@ -18,7 +18,7 @@ load("//python/private:text_util.bzl", "render") load(":pip_repository.bzl", pip_parse = "pip_repository") def _multi_pip_parse_impl(rctx): - rules_python = rctx.attr._rules_python_workspace.workspace_name + rules_python = rctx.attr._rules_python_workspace.repo_name load_statements = [] install_deps_calls = [] process_requirements_calls = [] @@ -69,7 +69,7 @@ def _process_requirements(pkg_labels, python_version, repo_prefix): wheel_name = Label(pkg_label).package if not wheel_name: # We are dealing with the cases where we don't have aliases. - workspace_name = Label(pkg_label).workspace_name + workspace_name = Label(pkg_label).repo_name wheel_name = workspace_name[len(repo_prefix):] _wheel_names.append(wheel_name) diff --git a/python/private/pypi/whl_library_alias.bzl b/python/private/pypi/whl_library_alias.bzl index d34b34a51a..66c3504d90 100644 --- a/python/private/pypi/whl_library_alias.bzl +++ b/python/private/pypi/whl_library_alias.bzl @@ -18,7 +18,7 @@ load("//python/private:full_version.bzl", "full_version") load(":render_pkg_aliases.bzl", "NO_MATCH_ERROR_MESSAGE_TEMPLATE") def _whl_library_alias_impl(rctx): - rules_python = rctx.attr._rules_python_workspace.workspace_name + rules_python = rctx.attr._rules_python_workspace.repo_name if rctx.attr.default_version: default_repo_prefix = rctx.attr.version_map[rctx.attr.default_version] else: diff --git a/python/private/pythons_hub.bzl b/python/private/pythons_hub.bzl index ac928ffc96..b448d53097 100644 --- a/python/private/pythons_hub.bzl +++ b/python/private/pythons_hub.bzl @@ -79,7 +79,7 @@ def _hub_build_file_content( return _HUB_BUILD_FILE_TEMPLATE.format( toolchains = toolchains, - rules_python = workspace_location.workspace_name, + rules_python = workspace_location.repo_name, ) _interpreters_bzl_template = """ diff --git a/python/private/toolchains_repo.bzl b/python/private/toolchains_repo.bzl index 5082047135..4e4a5de501 100644 --- a/python/private/toolchains_repo.bzl +++ b/python/private/toolchains_repo.bzl @@ -31,10 +31,6 @@ load( load(":repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils") load(":text_util.bzl", "render") -def get_repository_name(repository_workspace): - dummy_label = "//:_" - return str(repository_workspace.relative(dummy_label))[:-len(dummy_label)] or "@" - def python_toolchain_build_file_content( prefix, python_version, @@ -90,10 +86,10 @@ def _toolchains_repo_impl(rctx): # python_register_toolchains macro so you don't normally need to interact with # these targets. -load("@{rules_python}//python/private:py_toolchain_suite.bzl", "py_toolchain_suite") +load("@@{rules_python}//python/private:py_toolchain_suite.bzl", "py_toolchain_suite") """.format( - rules_python = rctx.attr._rules_python_workspace.workspace_name, + rules_python = rctx.attr._rules_python_workspace.repo_name, ) toolchains = python_toolchain_build_file_content( @@ -151,13 +147,13 @@ toolchain_aliases( rctx.file("defs.bzl", content = """\ # Generated by python/private/toolchains_repo.bzl -load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements") -load("{rules_python}//python/private:deprecation.bzl", "with_deprecation") -load("{rules_python}//python/private:text_util.bzl", "render") -load("{rules_python}//python:py_binary.bzl", _py_binary = "py_binary") -load("{rules_python}//python:py_test.bzl", _py_test = "py_test") +load("@@{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements") +load("@@{rules_python}//python/private:deprecation.bzl", "with_deprecation") +load("@@{rules_python}//python/private:text_util.bzl", "render") +load("@@{rules_python}//python:py_binary.bzl", _py_binary = "py_binary") +load("@@{rules_python}//python:py_test.bzl", _py_test = "py_test") load( - "{rules_python}//python/entry_points:py_console_script_binary.bzl", + "@@{rules_python}//python/entry_points:py_console_script_binary.bzl", _py_console_script_binary = "py_console_script_binary", ) @@ -185,7 +181,7 @@ def compile_pip_requirements(**kwargs): """.format( name = rctx.attr.name, python_version = rctx.attr.python_version, - rules_python = get_repository_name(rctx.attr._rules_python_workspace), + rules_python = rctx.attr._rules_python_workspace.repo_name, )) toolchain_aliases = repository_rule( @@ -301,20 +297,20 @@ this repo causes an eager fetch of the toolchain for the host platform. ) def _multi_toolchain_aliases_impl(rctx): - rules_python = rctx.attr._rules_python_workspace.workspace_name + rules_python = rctx.attr._rules_python_workspace.repo_name for python_version, repository_name in rctx.attr.python_versions.items(): file = "{}/defs.bzl".format(python_version) rctx.file(file, content = """\ # Generated by python/private/toolchains_repo.bzl -load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements") -load("{rules_python}//python/private:deprecation.bzl", "with_deprecation") -load("{rules_python}//python/private:text_util.bzl", "render") -load("{rules_python}//python:py_binary.bzl", _py_binary = "py_binary") -load("{rules_python}//python:py_test.bzl", _py_test = "py_test") +load("@@{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements") +load("@@{rules_python}//python/private:deprecation.bzl", "with_deprecation") +load("@@{rules_python}//python/private:text_util.bzl", "render") +load("@@{rules_python}//python:py_binary.bzl", _py_binary = "py_binary") +load("@@{rules_python}//python:py_test.bzl", _py_test = "py_test") load( - "{rules_python}//python/entry_points:py_console_script_binary.bzl", + "@@{rules_python}//python/entry_points:py_console_script_binary.bzl", _py_console_script_binary = "py_console_script_binary", ) @@ -343,14 +339,14 @@ def compile_pip_requirements(**kwargs): repository_name = repository_name, name = rctx.attr.name, python_version = python_version, - rules_python = get_repository_name(rctx.attr._rules_python_workspace), + rules_python = rules_python, )) rctx.file("{}/BUILD.bazel".format(python_version), "") pip_bzl = """\ # Generated by python/private/toolchains_repo.bzl -load("@{rules_python}//python:pip.bzl", "pip_parse", _multi_pip_parse = "multi_pip_parse") +load("@@{rules_python}//python:pip.bzl", "pip_parse", _multi_pip_parse = "multi_pip_parse") def multi_pip_parse(name, requirements_lock, **kwargs): return _multi_pip_parse( diff --git a/third_party/rules_pycross/pycross/private/wheel_library.bzl b/third_party/rules_pycross/pycross/private/wheel_library.bzl index 3d6ee32562..00d85f71b1 100644 --- a/third_party/rules_pycross/pycross/private/wheel_library.bzl +++ b/third_party/rules_pycross/pycross/private/wheel_library.bzl @@ -83,7 +83,7 @@ def _py_wheel_library_impl(ctx): # TODO: Is there a more correct way to get this runfiles-relative import path? imp = paths.join( - ctx.label.workspace_name or ctx.workspace_name, # Default to the local workspace. + ctx.label.repo_name or ctx.workspace_name, # Default to the local workspace. ctx.label.package, ctx.label.name, "site-packages", # we put lib files in this subdirectory.