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

Improve Python indexing example #227

Merged
merged 3 commits into from Mar 1, 2024

Conversation

eed3si9n
Copy link
Contributor

Problem

In the current example Python indexing only tracks 3rdparty libraries, but not Protobuf-generated sources.

Solution

This adjusts the scripts to index both 3rdparty pip targets and Protobuf-generated sources.

@eed3si9n eed3si9n requested a review from a team February 28, 2024 16:38
@@ -21,6 +18,14 @@ def _wheel_scanner_impl(target, ctx):
fail("Didn't have workspace prefix")
all_py_relative_paths.append(path[len(workspace_root) + 1:])
all_py_files.append(file)
elif ctx.rule.kind == "py_proto_library":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main changes are here. Instead of scanning for Python files in wheel, I'm grabbing the first file in DefaultInfo of the target.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why not add all files and let the command sort it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefaultInfo#files returns all Python files including from the dependency, so import would end up adding a bunch of unnecessary deps.

@@ -1,4 +1,5 @@
import pandas as pd
from com.example.aa_pb2 import A
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's a demo usage.

**Problem**
In the current example Python indexing only tracks
3rdparty libraries, but not Protobuf-generated sources.

**Solution**
This adjusts the scripts to index both 3rdparty pip targets
and Protobuf-generated sources.
@eed3si9n eed3si9n enabled auto-merge (squash) March 1, 2024 01:19
@eed3si9n eed3si9n merged commit 3ec38bd into bazeltools:main Mar 1, 2024
6 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.

None yet

2 participants