fix(gazelle): ensure that gazelle helper modules are on PYTHONPATH#1590
Merged
fix(gazelle): ensure that gazelle helper modules are on PYTHONPATH#1590
Conversation
Before this change there was a bug in how the parsing helpers were being used in case we were using Python 3.11 toolchain, which is using a more strict version of the entrypoint template. This change moves the python code to a different location to ensure that the top level package is something more unique than just "python" and updates the non-bzlmod tests to run under 3.11. We also change ".bazelrc" to use explicit "__init__.py" definition to avoid non-reproducible errors in the future. Fixes #1589
This means that we are replicating the setup that would be used by our users more closely. Note, that there is a seemingly benign error message: ```console $ bazel run //:gazelle ... INFO: Running command line: bazel-bin/gazelle gazelle: .../rules_python/gazelle/python/lifecycle.go:26:3: pattern helper.zip: matched no files ```
Collaborator
Author
|
@rickeylev, what do you think about cherry-picking this into a |
7d67276 to
0ba7c9c
Compare
rickeylev
approved these changes
Dec 2, 2023
Collaborator
rickeylev
left a comment
There was a problem hiding this comment.
cherry-picking this into a 0.27.1 release?
+1, I agree
| import std_modules | ||
| import sys | ||
|
|
||
| # NOTE @aignas 2023-12-02: Use absolute imports with respect to WORKSPACE root. |
Collaborator
There was a problem hiding this comment.
It would be better to not rely on the repo root being added to sys.path -- that's a behavior I plan to disable once the Starlark impl can be enabled.
But, I can understand this is just a bugfix CL, so this is fine for now. Is Gazelle able to under PyInfo.imports, or have some equivalent?
Collaborator
Author
There was a problem hiding this comment.
This made me realize that I just needed to use imports = ["."] on the py_binary that is being used here to fix the error and no moving of files is actually needed. Thanks!
This reverts commit 75aa9cc. This is optional
Collaborator
Author
|
The build is failing on Windows with: |
aignas
added a commit
that referenced
this pull request
Dec 4, 2023
…1590) Before this change there was a bug in how the parsing helpers were being used in case we were using Python 3.11 toolchain, which is using a more strict version of the entrypoint template. This change adds `imports = ["."]` to ensure that the gazelle helper components are on PYTHONPATH and updates the non-bzlmod tests to run under 3.11. We also: * Change `.bazelrc` to use explicit `__init__.py` definition to avoid non-reproducible errors in the future. * Add a dedicated `gazelle_binary` that uses `DEFAULT_LANGUAGES` *and* `//python`. Fixes #1589
philsc
pushed a commit
to philsc/rules_python
that referenced
this pull request
Dec 5, 2023
…bazel-contrib#1527) Bazel at head enables bzlmod by default, but the requirements.bzl entry_point functions aren't supported under bzlmod. Until workspace support is entirely dropped, explicitly disable bzlmod for the pip_repository_entry_points test. Work towards bazel-contrib#1590
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this change there was a bug in how the parsing helpers were being
used in case we were using Python 3.11 toolchain, which is using a more
strict version of the entrypoint template. This change adds
imports = ["."]to ensure that the gazelle helper components are on PYTHONPATH and updates
the non-bzlmod tests to run under 3.11.
We also:
.bazelrcto use explicit__init__.pydefinition to avoidnon-reproducible errors in the future.
gazelle_binarythat usesDEFAULT_LANGUAGESand//python.Fixes #1589