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

Python: Build external extractor #15845

Merged
merged 9 commits into from
Mar 20, 2024
Merged

Conversation

tausbn
Copy link
Contributor

@tausbn tausbn commented Mar 7, 2024

At present, none of the code in this PR has any effect, as the internal copy is still used for the build and CI. However, the changes in this PR should enable us to build the external version instead.

I suggest reviewing commit-by-commit, as one of the commits consists of renaming the tree-sitter-python directory to something a bit shorter (due to path length issues on Windows).

Apart from that, all this PR does is fix up some references in the various build files. Because tests are still being run using the internal extractor, this PR is therefore completely safe to merge.

A later PR will take care of hooking up the internal machinery so that we build this external copy of the extractor instead.

@tausbn tausbn added the no-change-note-required This PR does not need a change note label Mar 7, 2024
@github-actions github-actions bot added the Python label Mar 7, 2024
@tausbn tausbn force-pushed the tausbn/python-extractor-fix-build branch 3 times, most recently from a867679 to f3d953d Compare March 8, 2024 15:31
@tausbn tausbn force-pushed the tausbn/python-extractor-fix-build branch from f3d953d to 278efb0 Compare March 19, 2024 12:44
@tausbn tausbn force-pushed the tausbn/python-extractor-fix-build branch 4 times, most recently from 795dcd4 to 4dbc742 Compare March 19, 2024 15:56
tausbn added 9 commits March 19, 2024 17:11
This is essentially the contents of `language-packs/python/tools` with some minor
modifications to account for the changed location.

Of note: we explicitly exclude the `recorded-call-graph-metrics` director that
was already present in `python/tools`. When we revisit this directory for some
cleanup (e.g. to get rid of the `lgtm` references), we'll probably want to switch
to an explicit list of sources to include.
Two issues:

- Tests relying on existing query machinery (i.e. `import python`) were not resolving
  correctly due to a bad `qlpack.yml` file.
- The diagnostics output tests needed an updated import to account for their new location.
The referenced file lives in the internal repo, so this is perhaps a bit
of a hack, but I think it should be fine in the short run.
This aligns us a bit more with Ruby.
The current name results in a path that is more than 260 characters long,
and this causes issues for the build on Windows.
@tausbn tausbn force-pushed the tausbn/python-extractor-fix-build branch from 4dbc742 to d12ac1e Compare March 19, 2024 17:11
@tausbn tausbn marked this pull request as ready for review March 19, 2024 22:24
@tausbn tausbn requested a review from a team as a code owner March 19, 2024 22:24
@criemen criemen self-requested a review March 20, 2024 08:34
Copy link
Collaborator

@criemen criemen left a comment

Choose a reason for hiding this comment

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

One question, otherwise the Bazel build part of this PR looks good.

Deferring approval of the entire PR to the python team.

srcs = glob(["**/*"]),
excludes = [
"BUILD.bazel",
] + glob(["recorded-call-graph-metrics/**"]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is a functional change compared to the previous build. Is this on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you mean the exclusion of the recorded-call-graph-metrics directory, then yes. The reason for this is that this directory already existed as a subdirectory of the tools directory, and hence without the exclusion would get included in the extractor distribution (which was silly).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I didn't ready properly - I thought it was an active inclusion of the directory, which is a functional change. Having an active exclusion for it is sensible, to keep the dist as it was previously. Thanks for the clarification!

@@ -12,5 +12,5 @@ codeql_rust_binary(
visibility = ["//visibility:public"],
deps = all_crate_deps(
normal = True,
) + ["//python/extractor/tsg-python/tree-sitter-python"],
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: tspy would probably have been better to avoid confusion with the Tool Status Page (TSP), but not a blocker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point. I'm hoping we can eventually get a better solution to this path problem anyway, and fixing this in a follow-up PR should be very doable.

Copy link
Contributor

@sidshank sidshank left a comment

Choose a reason for hiding this comment

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

🚀

@tausbn tausbn merged commit 1d38ca3 into main Mar 20, 2024
40 checks passed
@tausbn tausbn deleted the tausbn/python-extractor-fix-build branch March 20, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation no-change-note-required This PR does not need a change note Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants