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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rickeylev
Copy link
Contributor

@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 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
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.

1 participant