8000 feat(pip_parse)!: use user friendly aliases to pip repos in requirements arrays by aignas · Pull Request #966 · bazel-contrib/rules_python · GitHub
[go: up one dir, main page]

Skip to content

feat(pip_parse)!: use user friendly aliases to pip repos in requirements arrays #966

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

Closed
wants to merge 4 commits into from

Conversation

aignas
Copy link
Collaborator
@aignas aignas commented Jan 3, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Currently the labels in the all_requirements and all_whl_requirements are not useable, which is needed for gazelle bzlmod support.

Issue number: #965

What is the new behavior?

We change the labels to point to the aliases that are present when bzlmod is used.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@aignas aignas mentioned this pull request Jan 3, 2023
12 tasks
@aignas aignas changed the title feat: Store alias labels in requirements arrays if using bzlmod feat(pip_parse): Store alias labels in requirements arrays if using bzlmod Jan 3, 2023
@@ -14,7 +14,8 @@ py_library(
name = "lib",
srcs = ["__init__.py"],
deps = [
requirement("pylint"),
# You can reference libraries using plain text form or the 'requirement' macro
"@pip//:pylint_pkg",
Copy link
Contributor

Choose a reason for hiding this comment

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

can it just be @pip//pylint ? That's the nicest syntax users would enjoy most.
(we'd generate a external/pip/pylint/BUILD.bazel file with appropriate aliases)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would love to use this and would be willing to implement this if this approach was agreed universally. @rickeylev, any opinions here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@alexeagle, what do you think about the inclusion of the user friendly aliases?

Copy link
Contributor
@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

@groodt
Copy link
Collaborator
groodt commented Jan 11, 2023

What if gazelle was changed to use the requirement function?

That's how it works in Java:
https://github.com/bazelbuild/rules_jvm_external/blob/master/examples/bzlmod/java/src/com/github/rules_jvm_external/examples/bzlmod/BUILD#L7

I am working on a PR that refactors the external package artifact macros. Which would make things a lot simpler for both bzlmod and general maintenance of the rules. The artifact macros in rules_jvm_external work quite differently to the present repository rules in rules_python. The overuse of repository rules in rules_python is a bit of legacy tech-debt which I'm hoping to clean up.

@aignas
Copy link
Collaborator Author
aignas commented Jan 18, 2023

@groodt, should we wait for the #989 to be done before we think about this again?

I personally found that something like @pip//pylint would be much nicer than artifact("pylint") because I can easily query the external targets as there are fewer layers of abstraction here. Any opinions from others?

aignas and others added 2 commits January 27, 2023 12:23
This changes the label strings that the users would get when loading the
`all_requirements` and `all_whl_requirements` from the generated
`requirements.bzl`. Previous labels were not really useable under
bzlmod, because they would not be visible to the consumer.

Work towards bazel-contrib#965
This is related to bazel-contrib#814 as it is bringing user-friendly alias generation
and it is doing this in a breaking way for the `bzlmod` users who are
not using the `requirement` macro. The labels that they use will change
from `@@repo//:{name}_pkg` to `@@repo//{name}`.

I am intentionally leaving the requirement macros in the
requirements.bzl unchanged as bazel-contrib#989 might change the approach again.

Since these aliases can be used by bzlmod and non-bzlmod users, we can
then support the same generated `gazelle_python.yaml` for both bzlmod
and non-bzlmod users.
@aignas aignas changed the title feat(pip_parse): Store alias labels in requirements arrays if using bzlmod feat(pip_parse)!: use user friendly aliases to pip repos in requirements arrays Jan 27, 2023
@aignas
Copy link
Collaborator Author
aignas commented Feb 13, 2023

This is getting stale, so I'll close this in favour of something else in the somewhat near future. It was also a breaking change, and we should avoid making them.

@aignas aignas closed this Feb 13, 2023
@aignas aignas deleted the gazelle-bzlmod-1 branch February 13, 2023 05:28
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.

3 participants
0