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

Update ctexplain to run with bazel and newer python versions #17109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

torgil
Copy link
Contributor

@torgil torgil commented Jan 2, 2023

Use "bazel" instead of "blaze" as default binary.

Add option to specify bazel binary.

Import bazel_api, lib, util and summary from qualified path to avoid collisions for users using this as a module. It also requires fewer entries in PYTHONPATH.

Updated to run with Python 3.10. "Mapping" has been moved from collections to collections.abc.

Cope with spaces in label name for cquery output. Regular expression is used instead of split.

@torgil torgil force-pushed the run-ctexplain-with-bazel-and-newer-python-versions branch 2 times, most recently from a58a457 to 5be7ae1 Compare January 2, 2023 16:34
Use "bazel" instead of "blaze" as default binary.

Add option to specify bazel binary.

Detect label arguments that starts with "@".

Import bazel_api, lib, util and summary from qualified path to avoid collisions
for users using this as a module. It also requires fewer entries in PYTHONPATH.

Updated to run with Python 3.10. "Mapping" has been moved from collections to
collections.abc.

Use regular expression instead of split on space to cope with spaces in label
name for cquery output.
@torgil torgil force-pushed the run-ctexplain-with-bazel-and-newer-python-versions branch from 5be7ae1 to 4880721 Compare January 2, 2023 16:49
@sgowroji sgowroji added team-Rules-Python Native rules for Python awaiting-review PR is awaiting review from an assigned reviewer labels Jan 3, 2023
@gregestren gregestren self-assigned this Jan 4, 2023
@gregestren gregestren added team-Configurability platforms, toolchains, cquery, select(), config transitions and removed team-Rules-Python Native rules for Python labels Jan 4, 2023
@gregestren
Copy link
Contributor

Thank you for providing this.

I'd like to follow up on this and #14236 soon.

I'd really love to see a usable version of ctexplain checked in especially if people find if useful.

Copy link
Contributor

@gregestren gregestren left a comment

Choose a reason for hiding this comment

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

Overall this looks good to me. Thanks for the clear breakdown of changes.

I'm happy you're doing this and want to support a full landing of ctexplain into the repo in a truly helpful state. I do need to dust off the code and remember its details - it's been sitting unmonitored for a while - so forgive me as I bring myself back up to speed, and am uncertain about some details.

First and foremost, I can't remember if the ctexplain tests automatically run as part of the CI. I hope so, but am not sure. Let's verify?

Otherwise, this basically LGTM. When imported into Google's repo Google runs some of its own presubmit checks (linters particular). So we may both get some further feedback from there after first trying to import. It should all be manageable, though.

I'll follow up in a comment with other code to import, to make the tool more feature-full. You don't have to do specifically import it, but if you want to I'm all in for reviewing. Someone else once volunteered to help with importing too if I can find their Github handle.

config_hash = tokens[1][1:-1]
if config_hash == "null":
fragments = ()
result = CQUERY_RESULT_LINE_REGEX.search(line)
Copy link
Contributor

Choose a reason for hiding this comment

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

Implementing the TODO from line 139 would be a great followup, especially if it's not hard (not sure it is).

I know you're just expanding on the parsing logic already implemented, but this (existing) logic is way more brittle than it should be.

@@ -28,8 +30,12 @@
from tools.ctexplain.types import HostConfiguration
from tools.ctexplain.types import NullConfiguration

CQUERY_RESULT_LINE_REGEX = re.compile(r"^(.*?) \((\S+)\) \[([^[]*)\]$")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what official style recommendations are, but can this be colocated closer to its sole consumer for less context jumping?

@gregestren
Copy link
Contributor

I consolidated what I think are the steps to get all the current ctexplain logic checked in: #14236 (comment)

This is a generic tool so there are all kinds of ways we can imagine extending / enhancing that logic. But as the baseline I'd support landing all the above.

Some are already PRs. The main blocker is review. My ideal is someone else carries through the PRs and I review them. I'm also happy to reverse if either of you wanted to review. But I might be a bit slower on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants