Skip to content
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

--incompatible_enable_deprecated_label_apis #23144

Open
2 of 5 tasks
Wyverald opened this issue Jul 29, 2024 · 4 comments
Open
2 of 5 tasks

--incompatible_enable_deprecated_label_apis #23144

Wyverald opened this issue Jul 29, 2024 · 4 comments
Assignees
Labels
incompatible-change Incompatible/breaking change migration-ready Incompatible flag is ready for migration with Bazel rolling releases or Bazel@last_green P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: process

Comments

@Wyverald
Copy link
Member

Motivation

Several old Starlark APIs related to labels had confusing names and/or behavior. This change deprecates those old APIs in favor of new ones with clearer names and intent.

Description

When --incompatible_enable_deprecated_label_apis is set to False:

  • native.repository_name() is removed. Use native.repo_name() instead, which has a shorter name, and doesn't include a leading @.
  • Label.workspace_name is removed. Use Label.repo_name instead, which has a clearer name, and behaves identically as the removed field.
  • Label.relative() is removed. It has never functioned well with repo mapping. Instead, use the new method Label.same_package_label(), alongside the existing native.package_relative_label() and Label().

Incompatible Flag

--incompatible_enable_deprecated_label_apis

Migration Guide

  • native.repository_name() can be replaced with '@' + native.repo_name().
  • Label.workspace_name can be replaced with Label.repo_name.
  • Depending on the use case, Label.relative() can be replaced with:
    • if the argument is always a package-relative label (such as :foo), use Label.same_package_label('foo') instaed.
    • if you're trying to relativize a label string from the context of a package in a macro, use native.package_relative_label() instead.
    • if you're trying to relativize a label string from the context of the .bzl file containing the currently running code, use Label() instead.

The newer APIs are only available in 7.1.0+. If backwards compatibility is a concern, use hasattr().

In which Bazel LTS version will this incompatible change be enabled?

Bazel 8

Additional Context

No response

TODO List

@Wyverald Wyverald added P1 I'll work on this now. (Assignee required) type: process team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. incompatible-change Incompatible/breaking change migration-ready Incompatible flag is ready for migration with Bazel rolling releases or Bazel@last_green labels Jul 29, 2024
@Wyverald Wyverald self-assigned this Jul 29, 2024
@fmeum
Copy link
Collaborator

fmeum commented Jul 29, 2024

I would like to get rid of workspace_root as well, with a suitably named replacement. Otherwise we would still have mentions of workspace stick around that would require another flag migration to get rid of.

@Wyverald
Copy link
Member Author

What's a good replacement? exec_root or some such?

@fmeum
Copy link
Collaborator

fmeum commented Jul 29, 2024

I would say repo_root or repo_path. I would prefer the latter as File#root returns a special starlark type, not a string.

@fmeum
Copy link
Collaborator

fmeum commented Jul 29, 2024

Also, aren't most incompatible flags set up so that they are flipped from off to on? I could see a "disable" version of this being a better fit for .bazelrc files.

@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) and removed P1 I'll work on this now. (Assignee required) labels Aug 27, 2024
@meteorcloudy meteorcloudy changed the title --incompatible_enable_deprecated_label_apis --incompatible_enable_deprecated_label_apis Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change migration-ready Incompatible flag is ready for migration with Bazel rolling releases or Bazel@last_green P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: process
Projects
None yet
Development

No branches or pull requests

3 participants