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

Skip to content

refactor: stop using some deprecated Starlark APIs #2626

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

Merged
merged 2 commits into from
Feb 27, 2025

Conversation

EdSchouten
Copy link
Contributor

I am currently working on an analysis tool that is capable of parsing BUILD/*.bzl files. It currently fails to process some of the Python rules, due to the rules depending on some features that are deprecated on the Bazel side. Instead of adding implementations of these deprecated features to my brand new analysis tool, I thought I'd simply patch up the Python rules instead.

@EdSchouten EdSchouten force-pushed the eschouten/20250116-fixups branch 2 times, most recently from 3fc3d18 to d536802 Compare February 24, 2025 09:13
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.
@EdSchouten EdSchouten force-pushed the eschouten/20250116-fixups branch from d536802 to 78263dc Compare February 24, 2025 09:14
Copy link
Collaborator

@rickeylev rickeylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

TIL workspace_name is now deprecated. Do you know when .repo_name became available?

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it always make sense to load from the global root module context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that there are still some other places in this file that use @rules_python instead of @@{rules_python}? Well, I thought that looked a bit funky, but wasn't sure whether that was accidental/intentional. Happy to change the code either way.

@aignas
Copy link
Collaborator

aignas commented Feb 24, 2025

Bazel 7.0 which is the lowest version that we support does not have repo_name: https://bazel.build/versions/7.0.0/rules/lib/builtins/Label, but 7.1 has: https://bazel.build/versions/7.1.0/rules/lib/builtins/Label

I would propose to drop support for anything below 7.0 and merge this. We need a CHANGELOG item clearly stating it.

@EdSchouten
Copy link
Contributor Author

EdSchouten commented Feb 25, 2025

Hey @rickeylev @aignas,

Bazel 7.0 which is the lowest version that we support does not have repo_name: https://bazel.build/versions/7.0.0/rules/lib/builtins/Label, but 7.1 has: https://bazel.build/versions/7.1.0/rules/lib/builtins/Label

It's also backported to 6.5.0:

https://bazel.build/versions/6.5.0/rules/lib/Label

I would propose to drop support for anything below 7.0 and merge this. We need a CHANGELOG item clearly stating it.

I noticed CHANGELOG.md already contains this sentence, so I assume no further documentation changes are needed, right?

  • Bazel 6 support is dropped and Bazel 7.4.1 is the minimum supported
    version, per our Bazel support matrix. Earlier versions are not
    tested by CI, so functionality cannot be guaranteed.

@aignas
Copy link
Collaborator

aignas commented Feb 25, 2025

Thanks for the digging and the clarification, it sounds good to me then!

Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as is.

@aignas aignas added this pull request to the merge queue Feb 27, 2025
Merged via the queue into bazel-contrib:main with commit effdce8 Feb 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants