--incompatible_enable_deprecated_label_apis #23144
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
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. Usenative.repo_name()
instead, which has a shorter name, and doesn't include a leading@
.Label.workspace_name
is removed. UseLabel.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 methodLabel.same_package_label()
, alongside the existingnative.package_relative_label()
andLabel()
.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 withLabel.repo_name
.Label.relative()
can be replaced with::foo
), useLabel.same_package_label('foo')
instaed.native.package_relative_label()
instead.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
The text was updated successfully, but these errors were encountered: