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

feat: add public API for analysis-phase logic #2252

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Sep 25, 2024

This adds a public API for rules (i.e. analysis-phase code) to use code from rules_python.
The main motivation for this is so that users can propagate PyInfo without having to know
all the fields of PyInfo and implement the merging logic. With upcoming PRs adding additional
fields to PyInfo, this becomes much more important.

The way the API is exposed is through a target. There are three reasons for this:

  1. It avoids loading phase costs when the implementation of the API functions change.
    Within Google, this makes changes to rules_python much cheaper and easier to submit
    and revert. This also allows us to worry less about the loading-phase impact of
    our code.
  2. Because a target can have dependencies, it allows us to hide some details
    from users. For example, if we want a flag to affect behavior, we can add it to the
    API target's attributes; users don't have to add it to their rule's attributes
  3. By having the API take the user's ctx as an argument, it allows us to capture it
    and use it as part of future API calls (this isn't used now, but gives us
    flexibility in the future).

Work towards #1647

@rickeylev rickeylev mentioned this pull request Sep 27, 2024
@rickeylev rickeylev force-pushed the feat.api branch 8 times, most recently from 8a66b6e to 821ae98 Compare October 3, 2024 03:38
@rickeylev rickeylev marked this pull request as ready for review October 3, 2024 03:47
@rickeylev rickeylev requested a review from aignas as a code owner October 3, 2024 03:47
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

python/private/api/api.bzl Show resolved Hide resolved
@rickeylev rickeylev enabled auto-merge October 7, 2024 21:43
@rickeylev rickeylev added this pull request to the merge queue Oct 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 7, 2024
@rickeylev rickeylev added this pull request to the merge queue Oct 7, 2024
Merged via the queue into bazelbuild:main with commit d85a392 Oct 7, 2024
4 checks passed
@rickeylev rickeylev deleted the feat.api branch October 8, 2024 17:58
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.

2 participants